Adding multiple products to cart via one product page's "Add to Cart" button

ianRogers
Visitor
2 0 0

I am working on creating a bundle. Currently if XYZ skus are in the card, I have a script that will recognize that and Bundle them together and apply a discount for that bundle. On the other end, adding the products via 1 click.

Let's say that I create a Product page for bundle XYZ skus. I want to just click that "Add to Cart" button and it will automatically put XYZ skus in the cart. So one click can add 3 separate products in the cart. I also need to account for inventory. If one of the skus XYZ is out of inventory. This bundle would not be able to be added to the cart. After that my script can do the calculations for discounts and pricing.

Replies 3 (3)

jam_chan
Shopify Partner
898 23 181

You can use cart API to add individual items to the cart: https://shopify.dev/api/ajax/reference/cart

 

Just override the add to cart button to call the API

BYOB - Build Your Own Bundles, SPO - SEO App to research keywords & edit social link preview

Simonsron
Shopify Partner
699 87 122

First: you need to look at how the XYZ binding of three products, and get the three products id:

Second: you can call shopify provide API: / cart/add js items inside a parameter value is an array, and then added to this array
You can go to  https://shopify.dev/api/ajax/reference/cart ,If you have any do not understand, at any time consulting me.

banned

davehollister
Visitor
1 0 0

Hi Ian - I am looking to create a script to adds multiple products (a bundle) from a product page button click, with a discount for the bundle. Would you be willing to share some details about your script that does this? I'm hoping to not use an app do do this - and it sounds like you have done it. Any insight you can provide would be great. Thanks!

-Dave