How to insert discount code into URL so discount is auto-applied to all prices

Topic summary

The discussion centers on automatically applying discount codes via URL and displaying discounted prices throughout a Shopify store, not just at checkout.

Basic URL Method:

  • Standard approach: https://{shop_name}.myshopify.com/discount/{discount_code}
  • Can add redirects: ?redirect=/products/{product} to land on specific pages
  • Shareable links available in Shopify admin under Discounts > Promote

Key Limitations Identified:

  • Discount codes apply at checkout only, not during browsing
  • Cookies get cleared when using redirects, causing mobile/private browsing failures
  • No native Liquid/API method to display discounted prices on product pages
  • Cart page cannot accurately show applied discounts
  • Invalid codes are accepted in URLs but fail silently at checkout

Workarounds Discussed:

  • Custom JavaScript solutions to auto-apply codes (shared by HenryReith)
  • Manual cookie management for Plus customers
  • Third-party apps like Adsgun that display savings across all pages
  • Multiple discount codes now supported via cart permalinks (recent Shopify update)

Current Status:

  • The core request (showing discounted prices while browsing) remains unsolved natively
  • Community frustration noted over Shopify’s years-long lack of comprehensive solution
  • Various workarounds exist but require custom development or apps
Summarized with AI on November 2. AI used: claude-sonnet-4-5-20250929.

Have you all figured out yet that this is all broken?

  1. If you use the direct URL entry method, it happily accepts bogus coupon codes
  2. It saves said bogus coupon in the cookie, fooling you into thinking it’s valid
  3. If you proceed to checkout, coupon is not there, because it was bogus
  4. If you enter a different code a checkout, it will use it, but it doesn’t update the cookie
  5. If you enter a valid code that isn’t valid for the products, you get an error, but it remembers. Add a product that IS valid, suddenly you have the discount.
  6. Cart and ALL other pages have NO way to know accurately what coupons are applied and how much discount they give. NONE. PERIOD.

Shopify made a HUGE mistake in how they implemented this, but there are threads going back over 6 years that suggest to me that they will pay lip service to the need but have NO interest in fixing it. Shameful, Shopify, shameful!

4 Likes

If this is still a challenge, this free app could be a possible solution.

Automatic Discount Code Links applies storefront discounts. On top of this, it allows to generate discount codes that are auto-applied when a customer goes to your store using a specific link or manually applies a promo code on a product page.

Hope it will help.

Hey, thanks
But I am looking to create an app not use another app.
But I will take a look into it if needed.
So thanks again!

All of these answers miss the key point the OP asked, which is to display the reduced price on all pages while browsing this site. We just launched our Shopify store this week and that was a major downside for us. I ended up creating some custom logic on the checkout page (we’re Plus customers) and managed cookies myself. This was all in an effort to get a coupon box and message on the cart page, nevermind every other page. It works pretty well, though there are situations were it can get out of sync. We’d love to show the savings on every product page, and we may look into that, but only if the logic is reliable in the long term, which we don’t know yet.

The real problem is that Shopify has a complete disconnect between Checkout and every other page on the site, even including Cart. And for some strange reason, they did not implement coupon functionality in a way that customers want. People wanna see savings quickly and easily, and having to get all the way to checkout just to see it is terrible UX, but they just don’t seem to understand that. It’s been YEARS of this problem and they only pay lip service to addressing it :disappointed_face:

2 Likes

Thank you so much @Doug-from-Maine .. That works for our site..

Thanks for the lead doug

Hi,

It seems that it doesn’t work for me anymore. “?discount=XXX”

Do you have heard any news about that ?

Thanks

I’m curious. Now order discounts can be combined with shipping discounts, is there a stackable URL we can promote to auto apply at checkout for both codes

1 Like

Is it possible to add a discount code to the cookies of a segment of your customers (my email subscribers)?

Basically if customer=subscribers add discount code to URL/cookies.

Is it possible to do it when they sign in to their account?

Same here. I can get one code to work in a URL, but I want to offer free shipping plus an order discount.

@Ana_Gabi_Mannel @George_C

Now the cart permalink can support 2 discount codes: https://shopify.dev/docs/apps/channels/cart-permalinks/cart-permalinks#step-4-apply-discounts-optional

4 Likes

@jam_chan Thanks!!

TY for helping!

I have been searching around today to work out how to do this easily, without apps, and came up with just a few lines of JS that will do it. I’ve shared the JS here: https://henryreith.co/automatically-add-discount-codes-to-shopify-checkout/. Hope this help’s other people looking for a solution too.

2 Likes

Thanks a lot for this, Henry! Works like a charm.

1 Like

But this is only working if we have one discount. What if we have to apply multiple discounts?

:backhand_index_pointing_up: :backhand_index_pointing_up: :backhand_index_pointing_up: This is the way you should use it, works for a code on a specific variant as well.

The code won’t add multiple discount codes at present. But the code can easily to updated to include the ability to include multiple discounts.

How do you add multiple discount codes using the URL method: https://{shop_name}.myshopify.com/discount/{discount_code} or any other method you use?

Is it possible to stop it from navigating to the home page and to stay on the current page using this discount url somehow?

Hey Mike,

I’m not exactly sure of your question here.

Yes, you can deep link to a page while applying a discount e.g. https://{shop_name}.myshopify.com/discount/{discount_code}?redirect=/pages/page-url . This would make the user land on yourdomain.com/pages.page-url.

Or if you question how can you add a discount when someone visits a specific URL?

1 Like