Check single product and mini card setting for displaying PayPal buttons

This commit is contained in:
dinamiko 2021-07-12 17:16:26 +02:00
parent 2efb300be8
commit ab6f8a3c99
2 changed files with 24 additions and 20 deletions

View file

@ -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,

View file

@ -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' ) {