How-To

How to Auto-Add Products & Discount to Shopify Cart via URL

See how to quickly build custom links to use in emails, landing pages, and more to auto-add products and discounts to the cart.

Landing pages have been quite the craze with the growth of tools like Shogun, Zipify Pages, Click Funnels, etc. We’re seeing more and more prospecting campaigns driving traffic directly to these pages promoting only one (or a few) products vs a full collection page of products.

These can be very successful especially those with great storytelling like we’ve seen with Truvani (aka The Food Babe) and Ylonn.

Success on this type of landing page can vary widely. A big part of this is the audience you are sending here – how qualified are they for this specific offering?

If you have found yourself creating landing pages or thinking about it – then creating a seamless experience for the user to add to cart, apply a discount, and redirect to the checkout is a no-brainer.

This prevents the awkward experience where you are sending users to the product page to add from the landing page. Or gasp if you are trying to use the Buy Now button channel!

This quick tip shows how to auto-add a product to your cart and automatically redirect to the Shopify checkout page (Shopify calls it a cart permalink).

Step 1: Pick your product

Inside of your Shopify admin find your product that you want to auto-add to cart and go to your browser bar:

variant-url

Step 2: Add .xml to the end of your product URL

Once you’ve found your product then add .xml to the end of the URL and refresh your browser. This should bring up an XML (code) looking page:

variantid xml

Step 3: Find and save the variant ID

Once you’ve loaded the XML version of the page then look for the <id> nested under the variant details as shown highlighted in the image above.

Step 4: Build your Link

Now save this ID for one or more products and start building your link.

The link should be your myshopify.com store URL version like this:

http://brevitedesign.myshopify.com/cart/2942460854298:1

Where the bolded number is the variant ID from step 3 and then use a :1 for the quantity added. In this example above I am adding a quantity of 1 to the cart.

Step 5: Optionally add a discount code

If you want to auto-apply a discount then you can do this by adding a parameter to the end: ?checkout[reduction_code]=discountcode

Where discountcode is your discount code.

So in this example our URL would now be:

http://brevitedesign.myshopify.com/cart/2942460854298:1?checkout[reduction_code]=discountcode

Step 6: Test your link

Now test your link! Open a new browser window => paste your URL => and verify the product is added to the cart for you.

auto-add-to-shopify-cart

That’s it!

You can now auto-add products to the cart, with a discount, using a simple URL.

This can be done on blogs, landing pages, emails, etc.

Good luck!

Get Exclusive Elevar Insights directly to your inbox.

Get free analytics tips and resources delivered directly to your inbox.

Shopify Tagging Experts

Learn how Elevar helps Shopify brands scale with expert server side tagging.

Learn More

Brad Redding

Brad, Founder of Elevar, has lived in eCommerce for nearly 15 years. Today Elevar helps thousands of eCommerce brands like Rothys, Vuori, Cuts Clothing, and Vessi maximize the value of their onsite data collection. He specializes in data analytics and conversion optimization to help brands exceed their business goals.

  1. Amazing, now I want to do this for bundles eg buy 2 for $x can this be done and what additions would need to added? So clicking the link would add two of the same product to the cart with the discount applied.

    1. Hi Sebastian! I don’t believe this is possible to send users to the cart instead of checkout..

  2. Hi Brad, can we use this with two items in the cart/checkout? Because we are doing BOGO discount now and two items must be added.

  3. Can you do this on a product with different sizes? Is this only applicable on the sku?

    Not very customizable shopify is it? All people want me to do is buy an app for that specific query. what a joke.

  4. Has anyone got this “?checkout[reduction_code]=discountcode” part of the URL working as it does nothing for me

    Thanks

  5. Try “http://brevitedesign.myshopify.com/cart/2942460854298:1?[discount]=discountcode” with your website, your variant ID and your discount code.

  6. Hi Sam, this one works better:
    “https://www.your-website.com/discount/your-discount-code?redirect=%2Fcart/your-variant-ID:quantity”. Here’s an example with discount code “2for1″ and 2 of the product added to the cart:
    “https://www.brevitedesign.myshopify.com /discount/2for1?redirect=%2Fcart/2942460854298:2”

  7. Thanks, it is very useful.

    This type of link is directly to the checkout page:
    “https://www.your-website.com/discount/your-discount-code?redirect=/cart/your-variant-ID:quantity”

    This type of link is directly to the product page and will auto apply the discount when goes to the checkout page:
    “https://www.your-website.com/discount/your-discount-code?redirect=/products/your-product-handle”

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Articles