Only display buttons in checkout if guest with subscription

This commit is contained in:
dinamiko 2022-01-17 14:35:25 +01:00
parent dce8a06953
commit 2f78bab9ca
2 changed files with 14 additions and 5 deletions

View file

@ -82,8 +82,16 @@ document.addEventListener(
console.error('PayPal button could not be configured.');
return;
}
const script = document.createElement('script');
if (
PayPalCommerceGateway.context !== 'checkout'
&& PayPalCommerceGateway.data_client_id.user === 0
&& PayPalCommerceGateway.data_client_id.has_subscriptions
) {
return;
}
const script = document.createElement('script');
script.addEventListener('load', (event) => {
bootstrap();
});

View file

@ -641,10 +641,11 @@ class SmartButton implements SmartButtonInterface {
$localize = array(
'script_attributes' => $this->attributes(),
'data_client_id' => array(
'set_attribute' => $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(),
'set_attribute' => $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(),
'has_subscriptions' => $this->has_subscriptions(),
),
'redirect' => wc_get_checkout_url(),
'context' => $this->context(),