diff --git a/modules/ppcp-button/resources/js/button.js b/modules/ppcp-button/resources/js/button.js index 067bc5347..7d3b1484d 100644 --- a/modules/ppcp-button/resources/js/button.js +++ b/modules/ppcp-button/resources/js/button.js @@ -18,15 +18,17 @@ const bootstrap = () => { const messageRenderer = new MessageRenderer(PayPalCommerceGateway.messages); const context = PayPalCommerceGateway.context; if (context === 'mini-cart' || context === 'product') { - const miniCartBootstrap = new MiniCartBootstap( - PayPalCommerceGateway, - renderer - ); + if (PayPalCommerceGateway.mini_card_buttons_enabled === '1') { + const miniCartBootstrap = new MiniCartBootstap( + PayPalCommerceGateway, + renderer + ); - miniCartBootstrap.init(); + miniCartBootstrap.init(); + } } - if (context === 'product') { + if (context === 'product' && PayPalCommerceGateway.single_product_buttons_enabled === '1') { const singleProductBootstrap = new SingleProductBootstap( PayPalCommerceGateway, renderer, diff --git a/modules/ppcp-button/src/Assets/class-smartbutton.php b/modules/ppcp-button/src/Assets/class-smartbutton.php index 016028d4d..ffcdf1bb6 100644 --- a/modules/ppcp-button/src/Assets/class-smartbutton.php +++ b/modules/ppcp-button/src/Assets/class-smartbutton.php @@ -612,16 +612,16 @@ class SmartButton implements SmartButtonInterface { $this->request_data->enqueue_nonce_fix(); $localize = array( - 'script_attributes' => $this->attributes(), - 'data_client_id' => array( + 'script_attributes' => $this->attributes(), + 'data_client_id' => array( 'set_attribute' => ( is_checkout() && $this->dcc_is_enabled() ) || $this->can_save_vault_token(), 'endpoint' => home_url( \WC_AJAX::get_endpoint( DataClientIdEndpoint::ENDPOINT ) ), 'nonce' => wp_create_nonce( DataClientIdEndpoint::nonce() ), 'user' => get_current_user_id(), ), - 'redirect' => wc_get_checkout_url(), - 'context' => $this->context(), - 'ajax' => array( + 'redirect' => wc_get_checkout_url(), + 'context' => $this->context(), + 'ajax' => array( 'change_cart' => array( 'endpoint' => home_url( \WC_AJAX::get_endpoint( ChangeCartEndpoint::ENDPOINT ) ), 'nonce' => wp_create_nonce( ChangeCartEndpoint::nonce() ), @@ -635,11 +635,11 @@ class SmartButton implements SmartButtonInterface { 'nonce' => wp_create_nonce( ApproveOrderEndpoint::nonce() ), ), ), - 'enforce_vault' => $this->has_subscriptions(), - 'save_card' => $this->can_save_vault_token(), - 'bn_codes' => $this->bn_codes(), - 'payer' => $this->payerData(), - 'button' => array( + 'enforce_vault' => $this->has_subscriptions(), + 'save_card' => $this->can_save_vault_token(), + 'bn_codes' => $this->bn_codes(), + 'payer' => $this->payerData(), + 'button' => array( 'wrapper' => '#ppc-button', 'mini_cart_wrapper' => '#ppc-button-minicart', 'cancel_wrapper' => '#ppcp-cancel', @@ -660,7 +660,7 @@ class SmartButton implements SmartButtonInterface { 'tagline' => $this->style_for_context( 'tagline', $this->context() ), ), ), - 'hosted_fields' => array( + 'hosted_fields' => array( 'wrapper' => '#ppcp-hosted-fields', 'mini_cart_wrapper' => '#ppcp-hosted-fields-mini-cart', 'labels' => array( @@ -678,8 +678,8 @@ class SmartButton implements SmartButtonInterface { ), 'valid_cards' => $this->dcc_applies->valid_cards(), ), - 'messages' => $this->message_values(), - 'labels' => array( + 'messages' => $this->message_values(), + 'labels' => array( 'error' => array( 'generic' => __( 'Something went wrong. Please try again or choose another payment source.', @@ -687,7 +687,9 @@ class SmartButton implements SmartButtonInterface { ), ), ), - 'order_id' => 'pay-now' === $this->context() ? absint( $wp->query_vars['order-pay'] ) : 0, + 'order_id' => 'pay-now' === $this->context() ? absint( $wp->query_vars['order-pay'] ) : 0, + 'single_product_buttons_enabled' => $this->settings->has( 'button_product_enabled' ) && $this->settings->get( 'button_product_enabled' ), + 'mini_card_buttons_enabled' => $this->settings->has( 'button_mini-cart_enabled' ) && $this->settings->get( 'button_mini-cart_enabled' ), ); if ( $this->style_for_context( 'layout', 'mini-cart' ) !== 'horizontal' ) {