Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
How to Create a Shopify Permalink for Adding Multiple Products to Cart with Discounts (and Show the Cart Page Instead of Going Straight to Checkout)
If you’re trying to create a Shopify permalink to add multiple products to the cart, apply discount codes, and show the cart page instead of going straight to checkout, this guide is for you. I spent hours figuring this out, and neither Shopify Support nor existing community posts had the solution. Here’s what worked for me.
The Solution:
1.Show the Cart Page:
To display the cart page (not the checkout), you need to append ?storefront=true to the link.
2.Use Variant IDs, Not Product IDs:
Shopify permalinks require Variant IDs, even for products without variants. If you try to use a Product ID, it won’t work.
How to find the Variant ID:
- Open the product page in your store.
- Right-click and select Inspect (or “View Page Source”).
- Use CTRL+F (Windows) or CMD+F (Mac) and search for variant.
- Look for the Variant ID, which is a long numeric string (e.g., 12345678901234).
3.Apply Multiple Discount Codes:
While Shopify officially only supports one discount code per link, I found that adding multiple codes separated by commas does work in the cart permalink. For example:
&discount=CODE1,CODE2.
Example Permalink:
Here’s a working example with two products and two discount codes:
https://your-shopify-store.com/cart/12345678901234:1,98765432109876:1?storefront=true&discount=DISCOUNT1,DISCOUNT2
Replace:
- 12345678901234 and 98765432109876 with your Variant IDs.
- DISCOUNT1 and DISCOUNT2 with your discount codes.
Notes:
- If multiple discounts don’t work for you, try apps like Multi Discount Rocket. But it should work none the less with 2 codes
- Make sure all products and discounts are active in your Shopify Admin.
Final Thoughts:
This solution worked for me after a lot of trial and error. Shopify, I love your platform, but I was disappointed that neither support nor existing guides could provide a clear solution. I hope this post saves others time and frustration. You can Check this as solved and i hope i can save some people the hours I've wasted...
Good luck, Shopify developers and e-commerce managers! May your permalinks work flawlessly! 😊
Thanks for sharing this information. It's good to know!
Very nice thanks @dr_max_owl always incredibly refreshing to see new poster contribute something so useful to other merchants.
While shopify's docs have improved over the years there's still a LOT of a lot of unpolished edges from undocument/undiscussed behavior that is just the result of lack of merchant complaints, gatekept knowledge, or really just the sheer amount of effort it takes to do correctly.
It doesn't help that posts lock after ~3 hours.
Notes:
For editing and generating the actual permalinks consider using a custom-liquid section and some utility code like the below.
Optionally modifying the code so that when running in a product or collection template to get the variant ids from that resource
{%- comment -%}© 2025 Paul N. permalink maker, UNTESTED logic example, does not url encode strings etc{%- endcomment -%}
{% liquid #config
# show cart page instead of going to checkout; true or false
assign use_storefront = true
# add variant ids ; seperated by commas ; surrounded by quotes
# alternatively pull ids from a collection, metafield or metaobject
assign variantsIDs = '12345,54321'
# quantities for qty per variant but must be the same amount of entries as variantIDs; seperated by commas ; surrounded by quotes
# examples: quantities = '1' , quantities = '1,2,4,1'
assign quantities = '1,3'
# add discount codes or leave blank ; seperated by commas ; surrounded by quotes
assign discount_codes = 'DISCOUNT1,DISCOUNT2'
%}
{% liquid
assign variantsIDs_array = variantsIDs | split:','
if quantities == blank
assign quantities = 1
endif
assign quantities_array = quantities | split:','
%}
{%- comment -%}build slug i.e. website.com/pages/slug?queryStringParam1=value{%- endcomment -%}
{%- for vIDs in variantsIDs_array -%}
{%- capture slug -%}
{{- slug -}}{%- unless forloop.last -%},{%- endunless -%}
{{- vID -}}:{{- quantities_array[forloop.index] | default:quantities_array[0] -}}
{%- endcapture -%}
{%- endfor -%}
{% liquid #build querystring i.e. website.com/pages/slug?queryStringParam1=value&queryStringParam2=value
if use_storefront != blank or discount != blank
assign querystring = '?'
if use_storefront
assign querystring = querystring | append: 'storefront=true' | append: '&'
endif
if discount_codes != blank
assign querystring = querystring | append: 'discount=' | append: discount_codes
endif
endif
# when adding more parameters querystring should be strings with a delimiter then split to an array to be rejoined with an ampersand to avoid missing any ampersands
%}
{{ shop.domain | default: shop.permanent_domain }}{{ slug | strip }}{{- querystring | strip -}}
Contact paull.newton+shopifyforum@gmail.com for the solutions you need
Save time & money ,Ask Questions The Smart Way
Problem Solved? ✔Accept and Like solutions to help future merchants
Answers powered by coffee Thank Paul with a ☕ Coffee for more answers or donate to eff.org
Learn how to expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025Expand into selling wholesale with Shopify Academy’s learning path, B2B on Shopify: Lau...
By Shopify Jan 28, 2025