Astra_Woocommerce::astra_shop_summary_box_alignment()

Shop summary box wrapper alignment.


Description


Return

(string)


Source

File: inc/compatibility/woocommerce/class-astra-woocommerce.php

		public function astra_shop_summary_box_alignment() {
			$shop_product_alignment = astra_get_option( 'shop-product-align-responsive' );
			$desktop_alignment      = ( isset( $shop_product_alignment['desktop'] ) ) ? $shop_product_alignment['desktop'] : '';
			$tablet_alignment       = ( isset( $shop_product_alignment['tablet'] ) ) ? $shop_product_alignment['tablet'] : '';
			$mobile_alignment       = ( isset( $shop_product_alignment['mobile'] ) ) ? $shop_product_alignment['mobile'] : '';

			$is_site_rtl = is_rtl();
			$ltr_left    = $is_site_rtl ? 'right' : 'left';
			$ltr_right   = $is_site_rtl ? 'left' : 'right';

			$tablet_breakpoint = astra_get_tablet_breakpoint();
			$mobile_breakpoint = astra_get_mobile_breakpoint();

			$desktop_css = '';
			$tablet_css  = '';
			$mobile_css  = '';

			switch ( $desktop_alignment ) {
				case 'align-left':
					$desktop_css = '
						.woocommerce ul.products li.product.desktop-align-left, .woocommerce-page ul.products li.product.desktop-align-left {
							text-align: ' . $ltr_left . ';
						}
						.woocommerce ul.products li.product.desktop-align-left .star-rating,
						.woocommerce ul.products li.product.desktop-align-left .button,
						.woocommerce-page ul.products li.product.desktop-align-left .star-rating,
						.woocommerce-page ul.products li.product.desktop-align-left .button {
							margin-left: 0;
							margin-right: 0;
						}
					';
					break;
				case 'align-center':
					$desktop_css = '
						.woocommerce ul.products li.product.desktop-align-center, .woocommerce-page ul.products li.product.desktop-align-center {
							text-align: center;
						}
						.woocommerce ul.products li.product.desktop-align-center .star-rating,
						.woocommerce-page ul.products li.product.desktop-align-center .star-rating {
							margin-left: auto;
							margin-right: auto;
						}
					';
					break;
				case 'align-right':
					$desktop_css = '
						.woocommerce ul.products li.product.desktop-align-right, .woocommerce-page ul.products li.product.desktop-align-right {
							text-align: ' . $ltr_right . ';
						}
						.woocommerce ul.products li.product.desktop-align-right .button,
						.woocommerce-page ul.products li.product.desktop-align-right .button {
							margin-left: 0;
							margin-right: 0;
						}

						.woocommerce ul.products li.product.desktop-align-right .star-rating,
						.woocommerce-page ul.products li.product.desktop-align-right .star-rating {
							margin-' . $ltr_left . ': auto;
							margin-' . $ltr_right . ': 0;
						}
					';
					break;
				default:
					// code...
					break;
			}

			switch ( $tablet_alignment ) {
				case 'align-left':
					$tablet_css = '
						.woocommerce ul.products li.product.tablet-align-left, .woocommerce-page ul.products li.product.tablet-align-left {
							text-align: ' . $ltr_left . ';
						}
						.woocommerce ul.products li.product.tablet-align-left .star-rating,
						.woocommerce ul.products li.product.tablet-align-left .button,
						.woocommerce-page ul.products li.product.tablet-align-left .star-rating,
						.woocommerce-page ul.products li.product.tablet-align-left .button {
							margin-left: 0;
							margin-right: 0;
						}
					';
					break;
				case 'align-center':
					$tablet_css = '
						.woocommerce ul.products li.product.tablet-align-center, .woocommerce-page ul.products li.product.tablet-align-center {
							text-align: center;
						}
						.woocommerce ul.products li.product.tablet-align-center .star-rating,
						.woocommerce-page ul.products li.product.tablet-align-center .star-rating {
							margin-left: auto;
							margin-right: auto;
						}
					';
					break;
				case 'align-right':
					$tablet_css = '
						.woocommerce ul.products li.product.tablet-align-right, .woocommerce-page ul.products li.product.tablet-align-right {
							text-align: ' . $ltr_right . ';
						}
						.woocommerce ul.products li.product.tablet-align-right .button,
						.woocommerce-page ul.products li.product.tablet-align-right .button {
							margin-left: 0;
							margin-right: 0;
						}

						.woocommerce ul.products li.product.tablet-align-right .star-rating,
						.woocommerce-page ul.products li.product.tablet-align-right .star-rating {
							margin-' . $ltr_left . ': auto;
							margin-' . $ltr_right . ': 0;
						}
					';
					break;
				default:
					// code...
					break;
			}

			switch ( $mobile_alignment ) {
				case 'align-left':
					$mobile_css = '
						.woocommerce ul.products li.product.mobile-align-left, .woocommerce-page ul.products li.product.mobile-align-left {
							text-align: ' . $ltr_left . ';
						}
						.woocommerce ul.products li.product.mobile-align-left .star-rating,
						.woocommerce ul.products li.product.mobile-align-left .button,
						.woocommerce-page ul.products li.product.mobile-align-left .star-rating,
						.woocommerce-page ul.products li.product.mobile-align-left .button {
							margin-left: 0;
							margin-right: 0;
						}
					';
					break;
				case 'align-center':
					$mobile_css = '
						.woocommerce ul.products li.product.mobile-align-center, .woocommerce-page ul.products li.product.mobile-align-center {
							text-align: center;
						}
						.woocommerce ul.products li.product.mobile-align-center .star-rating,
						.woocommerce-page ul.products li.product.mobile-align-center .star-rating {
							margin-left: auto;
							margin-right: auto;
						}
					';
					break;
				case 'align-right':
					$mobile_css = '
						.woocommerce ul.products li.product.mobile-align-right, .woocommerce-page ul.products li.product.mobile-align-right {
							text-align: ' . $ltr_right . ';
						}
						.woocommerce ul.products li.product.mobile-align-right .button,
						.woocommerce-page ul.products li.product.mobile-align-right .button {
							margin-left: 0;
							margin-right: 0;
						}

						.woocommerce ul.products li.product.mobile-align-right .star-rating,
						.woocommerce-page ul.products li.product.mobile-align-right .star-rating {
							margin-' . $ltr_left . ': auto;
							margin-' . $ltr_right . ': 0;
						}
					';
					break;
				default:
					// code...
					break;
			}

			/** @psalm-suppress InvalidOperand */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort
			return $desktop_css . '@media(max-width: ' . $tablet_breakpoint . 'px){' . $tablet_css . '}' . '@media(max-width: ' . $mobile_breakpoint . 'px){' . $mobile_css . '}'; // phpcs:ignore Generic.Strings.UnnecessaryStringConcat.Found
			/** @psalm-suppress InvalidOperand */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort
		}

Changelog

Changelog
Version Description
3.9.2 Introduced.


User Contributed Notes

You must log in before being able to contribute a note or feedback.