August 29, 2022
Shopify 1-Click Add to Cart, the Easy Way

August 29, 2022

The idea behind adding a product with 1-click — versus forcing the customer to visit another PDP on a Shopify site — came from similar customer expectations around relative products… the basic “Users who bought … also got …”
Sometimes you don’t need to send them to a different PDP; for example:
After some research, all I got was a “Permalink that adds an item to the cart, then takes straight to checkout” community post that didn’t explain thoroughly how to actually get the required information from your site.
The usual 1 click add to cart URL looks like this: https://shop.myshopify.com/cart/add?id=32527592816702&quantity=1
This URL consists of 2 important parts:
Basic Shop URL: https://shop.myshopify.com/cart/add
Parameter Configuration:
{% for variant_stock in product.variants %}
{{variant_stock.title}} => {{ variant_stock.id }}
{% endfor %}
Which by the end of this, you don’t even know which one is which. Or if you know exactly the variant index in the array {{variant[0].id}}
These 2 parameters enable you to send any product or lists of products to the cart
https://shop.myshopify.com/car…?id=32527592816702&quantity=1” class=”redactor-autoparser-object”>https://shop.myshopify.com/car…
Basic URL + id=variant.id&quantity=# + id=variant.id&quantity=#
As far as I’ve tested there is no limit on how many items you can pre-add to the cart.
Have fun!