Skip to content

Commit 6aaf5ba

Browse files
authored
Merge pull request #341 from athemes/improvement/rt/single-product-layout-7
Single product layout 7 and Merchant reasons to buy
2 parents 1c8a1bf + 9816def commit 6aaf5ba

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

inc/plugins/merchant/class-merchant-single-product-elements.php

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,16 @@ public function __construct() {
163163
add_action( 'botiga_before_render_single_product_elements', array( $this, 'turn_on_merchant_modules_shortcode_functionality' ) );
164164

165165
// Some modules like the 'reasons-to-buy' are initialized in the 'wp' hook. So we have to rely on this hook to force the activation from the shortcode mode.
166-
add_action( 'wp', array( $this, 'turn_on_merchant_modules_shortcode_functionality_to_specific_modules' ) );
166+
add_action( 'wp', array( $this, 'turn_on_merchant_modules_shortcode_functionality_on_wp_hook' ) );
167+
}
168+
169+
/**
170+
* Get the single product gallery layout (from customizer).
171+
*
172+
* @return string
173+
*/
174+
public function get_single_product_gallery_layout() {
175+
return get_theme_mod( 'single_product_gallery', 'gallery-default' );
167176
}
168177

169178
/**
@@ -173,6 +182,10 @@ public function __construct() {
173182
*/
174183
public function turn_on_merchant_modules_shortcode_functionality() {
175184
foreach ( self::$modules_data as $module_id => $module ) {
185+
if ( 'gallery-full-width' === $this->get_single_product_gallery_layout() ) {
186+
continue;
187+
}
188+
176189
add_filter( "merchant_{$module_id}_is_shortcode_enabled", '__return_true' );
177190
}
178191
}
@@ -182,12 +195,16 @@ public function turn_on_merchant_modules_shortcode_functionality() {
182195
*
183196
* @return void
184197
*/
185-
public function turn_on_merchant_modules_shortcode_functionality_to_specific_modules() {
198+
public function turn_on_merchant_modules_shortcode_functionality_on_wp_hook() {
186199
foreach ( self::$modules_data as $module_id => $module ) {
187200
if ( ! in_array( $module_id, array( 'reasons-to-buy' ), true ) ) {
188201
continue;
189202
}
190203

204+
if ( 'gallery-full-width' === $this->get_single_product_gallery_layout() ) {
205+
continue;
206+
}
207+
191208
add_filter( "merchant_{$module_id}_is_shortcode_enabled", '__return_true' );
192209
}
193210
}
@@ -282,6 +299,10 @@ public function admin_field_wrapper_class( $classes, $settings, $value, $module_
282299
return $classes;
283300
}
284301

302+
if ( 'gallery-full-width' === $this->get_single_product_gallery_layout() ) {
303+
return $classes;
304+
}
305+
285306
$descriptions_map = self::get_module_admin_field_descriptions();
286307
if ( ! array_key_exists( $module_id, $descriptions_map ) || ! array_key_exists( $settings['id'], $descriptions_map[ $module_id ] ) ) {
287308
return $classes;
@@ -306,6 +327,10 @@ public function replace_module_field_description( $desc, $settings, $value, $mod
306327
return $desc;
307328
}
308329

330+
if ( 'gallery-full-width' === $this->get_single_product_gallery_layout() ) {
331+
return $desc;
332+
}
333+
309334
$descriptions_map = self::get_module_admin_field_descriptions();
310335
if ( ! array_key_exists( $module_id, $descriptions_map ) || ! array_key_exists( $settings['id'], $descriptions_map[ $module_id ] ) ) {
311336
return $desc;

0 commit comments

Comments
 (0)