mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Check single product and mini card setting for displaying PayPal buttons
This commit is contained in:
parent
2efb300be8
commit
ab6f8a3c99
2 changed files with 24 additions and 20 deletions
|
@ -18,15 +18,17 @@ const bootstrap = () => {
|
||||||
const messageRenderer = new MessageRenderer(PayPalCommerceGateway.messages);
|
const messageRenderer = new MessageRenderer(PayPalCommerceGateway.messages);
|
||||||
const context = PayPalCommerceGateway.context;
|
const context = PayPalCommerceGateway.context;
|
||||||
if (context === 'mini-cart' || context === 'product') {
|
if (context === 'mini-cart' || context === 'product') {
|
||||||
const miniCartBootstrap = new MiniCartBootstap(
|
if (PayPalCommerceGateway.mini_card_buttons_enabled === '1') {
|
||||||
PayPalCommerceGateway,
|
const miniCartBootstrap = new MiniCartBootstap(
|
||||||
renderer
|
PayPalCommerceGateway,
|
||||||
);
|
renderer
|
||||||
|
);
|
||||||
|
|
||||||
miniCartBootstrap.init();
|
miniCartBootstrap.init();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context === 'product') {
|
if (context === 'product' && PayPalCommerceGateway.single_product_buttons_enabled === '1') {
|
||||||
const singleProductBootstrap = new SingleProductBootstap(
|
const singleProductBootstrap = new SingleProductBootstap(
|
||||||
PayPalCommerceGateway,
|
PayPalCommerceGateway,
|
||||||
renderer,
|
renderer,
|
||||||
|
|
|
@ -612,16 +612,16 @@ class SmartButton implements SmartButtonInterface {
|
||||||
|
|
||||||
$this->request_data->enqueue_nonce_fix();
|
$this->request_data->enqueue_nonce_fix();
|
||||||
$localize = array(
|
$localize = array(
|
||||||
'script_attributes' => $this->attributes(),
|
'script_attributes' => $this->attributes(),
|
||||||
'data_client_id' => array(
|
'data_client_id' => array(
|
||||||
'set_attribute' => ( is_checkout() && $this->dcc_is_enabled() ) || $this->can_save_vault_token(),
|
'set_attribute' => ( is_checkout() && $this->dcc_is_enabled() ) || $this->can_save_vault_token(),
|
||||||
'endpoint' => home_url( \WC_AJAX::get_endpoint( DataClientIdEndpoint::ENDPOINT ) ),
|
'endpoint' => home_url( \WC_AJAX::get_endpoint( DataClientIdEndpoint::ENDPOINT ) ),
|
||||||
'nonce' => wp_create_nonce( DataClientIdEndpoint::nonce() ),
|
'nonce' => wp_create_nonce( DataClientIdEndpoint::nonce() ),
|
||||||
'user' => get_current_user_id(),
|
'user' => get_current_user_id(),
|
||||||
),
|
),
|
||||||
'redirect' => wc_get_checkout_url(),
|
'redirect' => wc_get_checkout_url(),
|
||||||
'context' => $this->context(),
|
'context' => $this->context(),
|
||||||
'ajax' => array(
|
'ajax' => array(
|
||||||
'change_cart' => array(
|
'change_cart' => array(
|
||||||
'endpoint' => home_url( \WC_AJAX::get_endpoint( ChangeCartEndpoint::ENDPOINT ) ),
|
'endpoint' => home_url( \WC_AJAX::get_endpoint( ChangeCartEndpoint::ENDPOINT ) ),
|
||||||
'nonce' => wp_create_nonce( ChangeCartEndpoint::nonce() ),
|
'nonce' => wp_create_nonce( ChangeCartEndpoint::nonce() ),
|
||||||
|
@ -635,11 +635,11 @@ class SmartButton implements SmartButtonInterface {
|
||||||
'nonce' => wp_create_nonce( ApproveOrderEndpoint::nonce() ),
|
'nonce' => wp_create_nonce( ApproveOrderEndpoint::nonce() ),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'enforce_vault' => $this->has_subscriptions(),
|
'enforce_vault' => $this->has_subscriptions(),
|
||||||
'save_card' => $this->can_save_vault_token(),
|
'save_card' => $this->can_save_vault_token(),
|
||||||
'bn_codes' => $this->bn_codes(),
|
'bn_codes' => $this->bn_codes(),
|
||||||
'payer' => $this->payerData(),
|
'payer' => $this->payerData(),
|
||||||
'button' => array(
|
'button' => array(
|
||||||
'wrapper' => '#ppc-button',
|
'wrapper' => '#ppc-button',
|
||||||
'mini_cart_wrapper' => '#ppc-button-minicart',
|
'mini_cart_wrapper' => '#ppc-button-minicart',
|
||||||
'cancel_wrapper' => '#ppcp-cancel',
|
'cancel_wrapper' => '#ppcp-cancel',
|
||||||
|
@ -660,7 +660,7 @@ class SmartButton implements SmartButtonInterface {
|
||||||
'tagline' => $this->style_for_context( 'tagline', $this->context() ),
|
'tagline' => $this->style_for_context( 'tagline', $this->context() ),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'hosted_fields' => array(
|
'hosted_fields' => array(
|
||||||
'wrapper' => '#ppcp-hosted-fields',
|
'wrapper' => '#ppcp-hosted-fields',
|
||||||
'mini_cart_wrapper' => '#ppcp-hosted-fields-mini-cart',
|
'mini_cart_wrapper' => '#ppcp-hosted-fields-mini-cart',
|
||||||
'labels' => array(
|
'labels' => array(
|
||||||
|
@ -678,8 +678,8 @@ class SmartButton implements SmartButtonInterface {
|
||||||
),
|
),
|
||||||
'valid_cards' => $this->dcc_applies->valid_cards(),
|
'valid_cards' => $this->dcc_applies->valid_cards(),
|
||||||
),
|
),
|
||||||
'messages' => $this->message_values(),
|
'messages' => $this->message_values(),
|
||||||
'labels' => array(
|
'labels' => array(
|
||||||
'error' => array(
|
'error' => array(
|
||||||
'generic' => __(
|
'generic' => __(
|
||||||
'Something went wrong. Please try again or choose another payment source.',
|
'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' ) {
|
if ( $this->style_for_context( 'layout', 'mini-cart' ) !== 'horizontal' ) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue