Enable buttons when cart contains only one subscription product

This commit is contained in:
Emili Castells Guasch 2023-08-09 15:38:46 +02:00
parent 4d8302be45
commit 4260dce97b
3 changed files with 6 additions and 5 deletions

View file

@ -87,7 +87,7 @@ class CartBootstrap {
) { ) {
this.renderer.render(actionHandler.subscriptionsConfiguration()); this.renderer.render(actionHandler.subscriptionsConfiguration());
if(!PayPalCommerceGateway.subscription_plan_id) { if(!PayPalCommerceGateway.subscription_product_allowed) {
this.gateway.button.is_disabled = true; this.gateway.button.is_disabled = true;
this.handleButtonStatus(); this.handleButtonStatus();
} }

View file

@ -107,7 +107,7 @@ class CheckoutBootstap {
) { ) {
this.renderer.render(actionHandler.subscriptionsConfiguration(), {}, actionHandler.configuration()); this.renderer.render(actionHandler.subscriptionsConfiguration(), {}, actionHandler.configuration());
if(!PayPalCommerceGateway.subscription_plan_id) { if(!PayPalCommerceGateway.subscription_product_allowed) {
this.gateway.button.is_disabled = true; this.gateway.button.is_disabled = true;
this.handleButtonStatus(); this.handleButtonStatus();
} }

View file

@ -828,9 +828,9 @@ class SmartButton implements SmartButtonInterface {
'has_subscriptions' => $this->has_subscriptions(), 'has_subscriptions' => $this->has_subscriptions(),
'paypal_subscriptions_enabled' => $this->paypal_subscriptions_enabled(), 'paypal_subscriptions_enabled' => $this->paypal_subscriptions_enabled(),
), ),
'redirect' => wc_get_checkout_url(), 'redirect' => wc_get_checkout_url(),
'context' => $this->context(), 'context' => $this->context(),
'ajax' => array( 'ajax' => array(
'simulate_cart' => array( 'simulate_cart' => array(
'endpoint' => \WC_AJAX::get_endpoint( SimulateCartEndpoint::ENDPOINT ), 'endpoint' => \WC_AJAX::get_endpoint( SimulateCartEndpoint::ENDPOINT ),
'nonce' => wp_create_nonce( SimulateCartEndpoint::nonce() ), 'nonce' => wp_create_nonce( SimulateCartEndpoint::nonce() ),
@ -869,6 +869,7 @@ class SmartButton implements SmartButtonInterface {
), ),
'subscription_plan_id' => $this->subscription_helper->paypal_subscription_id(), 'subscription_plan_id' => $this->subscription_helper->paypal_subscription_id(),
'variable_paypal_subscription_variations' => $this->subscription_helper->variable_paypal_subscription_variations(), 'variable_paypal_subscription_variations' => $this->subscription_helper->variable_paypal_subscription_variations(),
'subscription_product_allowed' => $this->subscription_helper->checkout_subscription_product_allowed(),
'enforce_vault' => $this->has_subscriptions(), 'enforce_vault' => $this->has_subscriptions(),
'can_save_vault_token' => $this->can_save_vault_token(), 'can_save_vault_token' => $this->can_save_vault_token(),
'is_free_trial_cart' => $is_free_trial_cart, 'is_free_trial_cart' => $is_free_trial_cart,