From 3bd887aaa1a4dc1fb618b83ad4b22d32fb8ba7b8 Mon Sep 17 00:00:00 2001 From: David Remer Date: Wed, 1 Jul 2020 08:41:08 +0300 Subject: [PATCH] change enable button on page functionality too meet the requirements of default behavior --- .../ppcp-button/src/Assets/SmartButton.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/modules.local/ppcp-button/src/Assets/SmartButton.php b/modules.local/ppcp-button/src/Assets/SmartButton.php index 53dbae251..1ffd7622b 100644 --- a/modules.local/ppcp-button/src/Assets/SmartButton.php +++ b/modules.local/ppcp-button/src/Assets/SmartButton.php @@ -75,10 +75,12 @@ class SmartButton implements SmartButtonInterface esc_html__('Pay with Card', 'woocommerce-paypal-commerce-gateway') ); }; + + $notEnabledOnCart = $this->settings->has('button_cart_enabled') && + !wc_string_to_bool($this->settings->get('button_cart_enabled')); if ( is_cart() - && $this->settings->has('button_cart_enabled') - && wc_string_to_bool($this->settings->get('button_cart_enabled')) + && !$notEnabledOnCart ) { add_action( 'woocommerce_proceed_to_checkout', @@ -97,10 +99,12 @@ class SmartButton implements SmartButtonInterface 20 ); } + + $notEnabledOnProductPage = $this->settings->has('button_single_product_enabled') && + !wc_string_to_bool($this->settings->get('button_single_product_enabled')); if ( is_product() - && $this->settings->has('button_single_product_enabled') - && wc_string_to_bool($this->settings->get('button_single_product_enabled')) + && !$notEnabledOnProductPage ) { add_action( 'woocommerce_single_product_summary', @@ -119,9 +123,10 @@ class SmartButton implements SmartButtonInterface 31 ); } + $notEnabledOnMiniCart = $this->settings->has('button_mini_cart_enabled') && + !wc_string_to_bool($this->settings->get('button_mini_cart_enabled')); if ( - $this->settings->has('button_mini_cart_enabled') - && wc_string_to_bool($this->settings->get('button_mini_cart_enabled')) + ! $notEnabledOnMiniCart ) { add_action( 'woocommerce_widget_shopping_cart_after_buttons',