How to dynamically create a product variant with ajax api

alealdev
Shopify Partner
5 0 0

I need to create a bundle product based on user's selection over multiple variants/options. So let's imagine the next scenario:

 

I have:

Product A - Size 10 - Price 100

Product B - Size 12 - Price 100

Product C - Size 15 - Price 100

 

User selects:

Product A - Size 10

Product B - Size 12

Product C - Size 15

 

(At this point I have loop through the user's selections, and created and array of items with this data)

 

My question is: 

Is it possible to dynamically create a new variant with the new total price (300) And add this new variant to the cart with "/cart/add.js" post call?

 

So new variant in cart would look something like:

 

New variant title

properties:

Product A - Size 10

Product B - Size 12

Product C - Size 15

Price: 300

 

Thanks in advance

sample.png

Replies 0 (0)