how can I set or remove a selling plan using update.js

Krasho
New Member
1 0 0

I am creating a custom theme using the Ajax Cart API

I have a product and the customer can chose the option to get a subscription or buy once. when the cart is empty I am using this code:

 

 

product = {
id: productVariant,
quantity: productQty,
selling_plan: sellingPlanId
}

 

The sellingPlanId could be a number or empty

if the customer return to change the options, he can remove or set the subscription and I am using the update cart option (POST /cart/update.js) 

 

jQuery.post('/cart/update.js',
  "updates[794864053]=2&updates[794864233]=3"
);

 

 

 is it possible to set the new value to selling plan?

 

thanks

 

Replies 3 (3)
rb_sss
Tourist
6 0 1

Hi there,

 

did you ever figure out how to do this?

 

Best

Krasho4298
New Member
1 0 0

Hello Rb_SS

 

I created a JS object this:

product = {
id: productVariant,
quantity: productQty,
selling_plan: sellingPlanId
}
...
// More code Here
 
products.push(product)
SellingPlanId could be a number or empty. I couldn't find a way to update that value, so I did two requests
 
- First Request removes the items from the Cart. For me I should check the specific cart line to remove
- Second Request to Insert the items(products array) again, with or without selling plan.
 
That was my solution
 
regards
 
 
rb_sss
Tourist
6 0 1

Great, thank you! 🙂