PluginProbe
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant / 2.3.2
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant v2.3.2
2.3.2 2.3.1 2.3.0 2.2.8 2.2.7 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.11.0 1.11.1 1.11.2 1.6 1.7 1.8 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 1.9.10 1.9.11 All 60 releases
merchant / inc / compatibility / class-merchant-astra-theme.php

class-merchant-astra-theme.php in Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant 2.3.2, at inc/compatibility/class-merchant-astra-theme.php

83 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit; // Exit if accessed directly
4 }
5
6 /**
7 * Astra theme compatibility layer
8 */
9 if ( ! class_exists( 'Merchant_Astra_Theme' ) ) {
10 class Merchant_Astra_Theme {
11
12 /**
13 * Constructor.
14 */
15 public function __construct() {
16 add_filter( 'astra_woo_shop_product_structure', array( $this, 'fix_astra_shop_structure' ) );
17
18 if ( is_admin() && ! wp_doing_ajax() ) {
19 return;
20 }
21
22 // Custom CSS.
23 add_filter( 'merchant_custom_css', array( $this, 'frontend_custom_css' ) );
24 }
25
26 /**
27 * Frontend custom CSS.
28 *
29 * Names the theme here, not in the constructor: this class is built before the
30 * theme loads, so `ASTRA_THEME_VERSION` does not exist yet.
31 *
32 * @param string $css The custom CSS.
33 * @return string $css The custom CSS.
34 */
35 public function frontend_custom_css( $css ) {
36 if ( ! merchant_is_astra_active() ) {
37 return $css;
38 }
39
40 // Delivery & Pickup
41 if ( Merchant_Modules::is_module_active( Merchant_Delivery_Pickup::MODULE_ID ) ) {
42 // Astra makes `#order_review td.product-name` a wrapping flex row, where a
43 // collapsed control fits beside the product name.
44 $css .= '
45 body .merchant-dp-line {
46 width: 100%;
47 }
48 ';
49 }
50
51 return $css;
52 }
53
54 /**
55 * Disable the add to cart button in the shop loop while product swatches module is active.
56 *
57 * @param $shop_structure
58 *
59 * @return void
60 */
61 public function fix_astra_shop_structure( $shop_structure ) {
62 if ( ! Merchant_Modules::is_module_active( 'product-swatches' ) ) {
63 return $shop_structure;
64 }
65 if ( is_array( $shop_structure ) && ! empty( $shop_structure ) ) {
66 foreach ( $shop_structure as $key => $value ) {
67 if ( $value === 'add_cart' ) {
68 unset( $shop_structure[ $key ] );
69 }
70 }
71 }
72
73 return $shop_structure;
74 }
75 }
76
77 /**
78 * The class object can be accessed with "global $merchant_astra_compatibility", to allow removing actions.
79 * Improving Third-party integrations.
80 */
81 $merchant_astra_compatibility = new Merchant_Astra_Theme();
82 }
83