Cart - Use permalinks to pre-load the cart

Topic summary

Cart permalinks allow pre-loading Shopify carts with specific products and quantities using URLs formatted as /cart/{variant_id}:{quantity}. The original tutorial explains this advanced technique can pre-fill checkout fields (email, shipping address) and include discount codes, though it’s unsupported by Shopify and requires technical knowledge.

Key URL patterns discovered:

  • Add to cart without redirect: /cart/add?id[]=variantid
  • Update quantities: /cart/update?updates[variant_id]=qty
  • Clear cart then add items: /cart/update?updates[variant_id]=0&updates[variant_id]=3
  • Apply discount and redirect: /cart/add?id[]=variant&return_to=/discount/code?redirect=/page

Common issues resolved:

  • Multiple query parameters require & not ? as separators
  • Must use variant IDs (not product IDs)
  • Encoding & as %26 needed when chaining parameters in return_to URLs
  • Province/state uses two-letter codes: &checkout[shipping_address][province]=NY

Unresolved questions:

  • Adding tags to orders via permalink (not currently supported)
  • Adding line item properties through URLs
  • Adding metafields
  • Applying discount codes to cart page (only works on checkout)

The discussion remains active with ongoing troubleshooting and workaround sharing.

Summarized with AI on October 31. AI used: claude-sonnet-4-5-20250929.

Does the cart URL (not checkout) support adding a coupon code?

The “discount=code” in the checkout URL format works fine but I can’t get it to work for any cart URLs.

Is it supported?

that’s a good question - pretty sure you wont’ be able to add a discount code to a cart permalink. however, this should solve your need: https://apps.shopify.com/permalinks

I summarized here

https://community.shopify.com/c/shopify-design/cart-use-permalinks-to-pre-load-the-cart/m-p/1038264/highlight/true#M262753

@chenster ya i saw your post and bookmarked it but it didn’t address coupons in the cart urls. Other posts on the web seems indicate the “discount=discount-code” parameter works but I’ve never had it work.

I guess you could use the coupon url then redirect to your cart URL?

STOREURL/discount/DISCOUNT_CODE?redirect=ENCODED-CART-URL

How can I add rag to that orders? Maybe there should be a parameter for that?

If you have found a solution, would be thankful if you share.

I noticed when using these links that the existing cart gets deleted.

Is there any way to use the links and also keep existing cart?

Same. I’m using this as a “hey dont leave yet, add this item to the cart and get a discount” kind of deal. I’m applying a discount and the item to cart. But this is clearing the existing items.

@chrisfloat @joshchretien you can use the Cart Add URL for this instead.

You can construct a URL like this:

https://example.myshopify.com/cart/add?id[]=5475&return_to=/discount/examplediscount%3fredirect=/pages/about-us

Which will add the product with the variant ID of “5475” to the cart, attempt to add the discount code “examplediscount”, and redirect the customer to “/pages/about-us”.

This approach is useful when you are live selling and want the customers to view content on an landing page for example to potentially add upsell products. Along those lines I would recommend using a redirect URL for it so that it conceals the contents of the URL and can be changed at a later date for other things like product drops.

Another thing to note about this approach is that you can add multiple products with varying quantities, line item properties, and subscription selling plans if you wanted to. Hosted Shopify is amazingly powerful and their Cart API is one of my favorite aspects!

Hope that helps!

1 Like

Hello thank you for all this information.

Is there a way to create a hyperlink that adds an item to the cart without taking them away from the current page? If a customer chooses a large variant on my site, a crate would needed to be added to cart. I have a box that appears that shows “hey a crate is required for this size Add to crate to cart ($50)”. I do not want to send my customer away from the current product page.

Thanks for all the help!

It may be best to use Shopify’s Cart API for that use case. See documentation here: https://shopify.dev/api/ajax/reference/cart

I wanted to give another mention for the app ZipLinks: https://apps.shopify.com/permalinks

One of my biggest clients is running a big radio campaign and we were able to use that app to make a short link that applied the coupon, added item to cart, tagged customer, and tagged the order. The tagging was essential so client could judge the ROI of radio campaign.

1 Like

In our app, you can build pre-filled cart links with/without discounts attached (or gifts or custom deals attached). This might help some merchant. See our demo store.

I know this is late but you have 2 (?) question marks in your url string and there should only be 1. Replace the 2nd (?) with an (&) ampersand. It should be:

/cart/{variant_id}:{quantity},{variant_id}:{quantity}?discount=discountName&ref=email@domain.com

In our .Net OMS, I worked around this problem by loading the checkout url inside a browser control and then running a javascript to hide the elements. The browser control I am using is:

Microsoft.Web.WebView2.WinForms.WebView2

The javascript I came up with is:

document.getElementsByClassName(‘step__footer__previous-link’)[0].style.display = ‘none’;

document.getElementsByClassName(‘breadcrumb__link’)[0].style.display = ‘none’;"

I execute this in the WebView2.NavigationCompleted event. Using the “WebView2.ExecuteScriptAsync()”

I think Shopify should update to the official doc: https://help.shopify.com/en/manual/products/details/checkout-link

Not sure if ref is still relevant since it’s not mentioned in the checkout link

1 Like

Hi all!

Just wanted to know if this is still working? It leads to an error in most of the stores we’re part of.

For example:

https://www.status.co/cart/7559522222338:1

https://www.status.co/cart/7559522222338:1,201493351170100:1

Hi Paula, you need to use the variant id, not the product id.
Try this link https://www.status.co/cart/36355177447590:1

Hi

Does anyone know how updating the input on the checkout page can work with Online Store 2.0 themes?

E.g. this works with a vintage theme e.g. Debut
https://a-vintage-theme-shop.myshopify.com/cart/31923935772751:1?checkout[shipping_address][address1]=MyAddress

But this does not work for a new theme e.g. Dawn

https://a-modern-theme-shop.myshopify.com/cart/43589128683771:7?checkout[shipping_address][address1]=MyAddress

It partially works by redirecting to the checkout page and populating the product, but not the address.

Thanks

Hi @Martin-NZPost both of your example shops are unavailable but if you test with the Shopify Dawn theme demo then you can see it does work on Dawn so it is likely something else going on with your test shops.

Try the link below to see that it does work with Dawn as the theme should have no impact on this behavior.

https://theme-dawn-demo.myshopify.com/cart/39577056936025:1?checkout[shipping_address][address1]=Martin%20St
1 Like