Search code examples
apishopifypermalinks

Can we also specify quantity for each product for multiple products using permalinks?


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?


Solution

  • 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.