change enable button on page functionality too meet the requirements of default behavior

This commit is contained in:
David Remer 2020-07-01 08:41:08 +03:00
parent f6a3746d1a
commit 3bd887aaa1

View file

@ -75,10 +75,12 @@ class SmartButton implements SmartButtonInterface
esc_html__('Pay with Card', 'woocommerce-paypal-commerce-gateway') 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 ( if (
is_cart() is_cart()
&& $this->settings->has('button_cart_enabled') && !$notEnabledOnCart
&& wc_string_to_bool($this->settings->get('button_cart_enabled'))
) { ) {
add_action( add_action(
'woocommerce_proceed_to_checkout', 'woocommerce_proceed_to_checkout',
@ -97,10 +99,12 @@ class SmartButton implements SmartButtonInterface
20 20
); );
} }
$notEnabledOnProductPage = $this->settings->has('button_single_product_enabled') &&
!wc_string_to_bool($this->settings->get('button_single_product_enabled'));
if ( if (
is_product() is_product()
&& $this->settings->has('button_single_product_enabled') && !$notEnabledOnProductPage
&& wc_string_to_bool($this->settings->get('button_single_product_enabled'))
) { ) {
add_action( add_action(
'woocommerce_single_product_summary', 'woocommerce_single_product_summary',
@ -119,9 +123,10 @@ class SmartButton implements SmartButtonInterface
31 31
); );
} }
$notEnabledOnMiniCart = $this->settings->has('button_mini_cart_enabled') &&
!wc_string_to_bool($this->settings->get('button_mini_cart_enabled'));
if ( if (
$this->settings->has('button_mini_cart_enabled') ! $notEnabledOnMiniCart
&& wc_string_to_bool($this->settings->get('button_mini_cart_enabled'))
) { ) {
add_action( add_action(
'woocommerce_widget_shopping_cart_after_buttons', 'woocommerce_widget_shopping_cart_after_buttons',