Skip to content

Shopify 1-Click Add to Cart, the Easy Way

By GRAYBOX Alumni

Allowing customers to add a similar or related product to their cart from a product page on a Shopify site can easily be accomplished using URL parameters.

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:

  • You are selling those new shoes that everyone likes, but the trending laces aren’t included. There is no need to show a complete PDP of laces.
  • You are bundling a set of items for a discount, add all those with 1 click.

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.

Understanding the URL

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:

  • id - this id is the product variants id. {{ variant.id }} which can only be accessed through a loop
{% 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}}
  • quantity

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!

Blog & Events

Featured Work