• Skip to primary navigation
  • Skip to main content
  • Skip to footer

Merchant Labs

Helping online merchants succeed is what we do best!

  • About
  • Contact
  • My Account

Shopify, Useful Code / August 24, 2020

Shopify – How to empty cart, prefill cart with products and start checkout

Have you ever wanted to share a link to your Shopify store that puts items in your cart and starts the checkout, but found that if the user already had items in their cart they end up with the wrong quantity or more items than you wanted.

This is a very common trick for Shopify owners that are looking to share a link via WhatsApp, Messenger, SMS, etc.

It turns out it’s very easy to do by utilizing a combination of special Shopify URLs and parameters.

Here’s an example:

https://mywebsite.myshopify.com/cart/clear?return_to=/cart/update?updates[123456789]=1

The first part is a special URL that clears the cart. Then you add a special parameter, return_to, which allows you to specify another URL. The value for the parameter is another special URL in which you can add product variant IDs and a quantity.

Put it all together and you end up with a cart that only has exactly what you want and gets the customer straight to the checkout.

I found this solution along with many others in the Shopify Forums

NEED HELP?

Enter just the numbers without spaces or dashes.

Filed Under: Shopify, Useful Code Tagged With: Shopify Liquid

Reader Interactions

Leave a Reply Cancel reply

You must be logged in to post a comment.

Footer

Shopify Partner

Let Merchant Labs, with over 15 years experience in ecommerce, help you SUCCEED online! From …

Read More about Shopify Development Services

  • Twitter
  • YouTube

Ajax-Cart Coming Soon

What is Ajax-cart for Shopify? Ajax-cart for Shopify is a big project to bring some of the most wanted features to the Shopify cart page. This page is also known as the basket screen. Its …

more about Ajax-Cart for Shopify

Tags

Apps Script Coding Documentation Javascript MySQL PHP Shopify Liquid

Contact Us

Merchant Labs
Los Angeles, California

P: 424-236-0372
E: mngr@merchantlabs.com

Proud Partners For

Copyright © 2023 · Digital Pro on Genesis Framework · WordPress · Log in