mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Add variable subscription variation support for cart page
This commit is contained in:
parent
a2e0f68f1b
commit
e1486deff8
3 changed files with 10 additions and 5 deletions
|
@ -9,11 +9,11 @@ class CartActionHandler {
|
|||
this.errorHandler = errorHandler;
|
||||
}
|
||||
|
||||
subscriptionsConfiguration() {
|
||||
subscriptionsConfiguration(subscription_plan_id) {
|
||||
return {
|
||||
createSubscription: (data, actions) => {
|
||||
return actions.subscription.create({
|
||||
'plan_id': this.config.subscription_plan_id
|
||||
'plan_id': subscription_plan_id
|
||||
});
|
||||
},
|
||||
onApprove: (data, actions) => {
|
||||
|
|
|
@ -12,7 +12,7 @@ class CheckoutActionHandler {
|
|||
this.spinner = spinner;
|
||||
}
|
||||
|
||||
subscriptionsConfiguration(subscription_plan) {
|
||||
subscriptionsConfiguration(subscription_plan_id) {
|
||||
return {
|
||||
createSubscription: async (data, actions) => {
|
||||
try {
|
||||
|
@ -22,7 +22,7 @@ class CheckoutActionHandler {
|
|||
}
|
||||
|
||||
return actions.subscription.create({
|
||||
'plan_id': subscription_plan
|
||||
'plan_id': subscription_plan_id
|
||||
});
|
||||
},
|
||||
onApprove: (data, actions) => {
|
||||
|
|
|
@ -90,7 +90,12 @@ class CartBootstrap {
|
|||
PayPalCommerceGateway.data_client_id.has_subscriptions
|
||||
&& PayPalCommerceGateway.data_client_id.paypal_subscriptions_enabled
|
||||
) {
|
||||
this.renderer.render(actionHandler.subscriptionsConfiguration());
|
||||
let subscription_plan_id = PayPalCommerceGateway.subscription_plan_id
|
||||
if(PayPalCommerceGateway.variable_paypal_subscription_variation_from_cart !== '') {
|
||||
subscription_plan_id = PayPalCommerceGateway.variable_paypal_subscription_variation_from_cart
|
||||
}
|
||||
|
||||
this.renderer.render(actionHandler.subscriptionsConfiguration(subscription_plan_id));
|
||||
|
||||
if(!PayPalCommerceGateway.subscription_product_allowed) {
|
||||
this.gateway.button.is_disabled = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue