Ad

Can We Also Specify Quantity For Each Product For Multiple Products Using Permalinks?

- 1 answer

So if we want to add a single product to cart in shopify we can specify the quantity For Example - https://example.myshopify.com/cart/add?id=123456789&quantity=1

And if we want to add multiple products to cart we write: https://example.myshopify.com/cart/add?id[]=123456789&id[]=123456129

So can we specify the quantity for each product? like - https://example.myshopify.com/cart/add?id[]=123456789&quantiy=2&id[]=123456129&quantity=3

or can we add the same id in the id[] and we could achieve the same thing like - https://example.myshopify.com/cart/add?id[]=123456789&id[]=123456789

Is this possible?

Ad

Answer

What you do is change the URL slightly. So instead of cart/add you just use cart.

https://example.myshopify.com/cart/12345656:3,765432111:2

That will place 3 of one product and 2 of another in the cart and show the customer checkout.

If you just want to put products in the cart, then you just use your pattern with variant ID's and you just let the customer choose quantity in the cart, you don't preload the quantity.

Ad
source: stackoverflow.com
Ad