Have your say in Community Polls: What was/is your greatest motivation to start your own business?

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

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

Josh_MacDonald
Visitor
2 0 4

I want to inject a discount code into a URL. Beyond just filling in on the checkout page, I want the discounted prices to be shown while the user browses the site.

How do I code something like this?

Replies 41 (41)

LukaszWiktor
Shopify Partner
315 24 123

Hi Josh,

To automatically apply a discount code on the checkout page you need to prepare following URL

https://{shop_name}.myshopify.com/discount/{discount_code}

replacing shop_name and discount_code according to your needs.

You can also get this link from the admin panel:

Unfortunatelly, I don't know how to show the discounted prices on product pages. Would love to learn.

HTH,
Lukasz

I'm a software engineer. I make things happen automatically.
Check out my apps Exporteo, Fulfilleo, Stockeo, and Personal Discount.
abdullah_omar04
Excursionist
24 0 1

Hey @LukaszWiktor 

Can you please tell me where you got this link from? 

https://{shop_name}.myshopify.com/discount/{discount_code}


I have been looking for this in the docs but I couldn't find anything like this.

Thanks!

Sve_FB
Tourist
5 0 2

Go to DISCOUNTS --> Select active discount --> upper right corner you will see "Promote" and Get Shareable link...

FurtherRecords
Shopify Partner
37 1 18

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?

mikejohnp
Tourist
6 0 6

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

HenryReith
Shopify Partner
6 1 3

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?

mikejohnp
Tourist
6 0 6

Yes thank. That’s exactly what I needed, adding the redirect to the end of the discount url …?redirect=/path

 

Much appreciated

Josh_MacDonald
Visitor
2 0 4

Thanks for offering to help Lukasz but that's not what I want.

I want all prices to be slashed on the site and show the price after discount while users browse.

Mandelbrotian
Shopify Partner
140 1 23

Hi Josh,

The discount code is stored in the cookie so you could have variables defined in your site script that can be cross referenced to apply a discount. It does mean you would need to define your codes twice but it's better than not having the functionality at all.

You would still need to use the link that Lukasz pointed out above so that the code was stored in the first place, and it means you would need an obvisous notice so that users know why the store prices are changing in front of them.

As far as I'm aware there isn't a way to do this through liquid.

If you need a hand with implementation I'm available through elliot@mandelbrotian.com

Cheers,

Elliott

Feeling a bit lost? Contact elliott@mandelbrotian.com for help with theme setup, alterations, custom functionality, and app development.

StevoHoodDesign
Shopify Partner
30 2 31

All you have to do is add this to end of your URL:

 

?discount=your_discount

ex: http://www.yourshop.com/collections/all/my-product?discount=savefive

 

It's great for social media, cause you can take them right to the product without needing them to memorize a discount code til they checkout.

scott74
Shopify Partner
3 0 0

I am generating a an actiavation URL to activate account in FB mesenger... I would like to auto apply a discount after they set their password from the activating URL we send them... How would you append the discount to this URL?

 

https://apple.myshopify.com/account/activate/207119551/e002775fd4cda67d1a6bafcc8c132a1f-1571256934"

 
Ababusa
Excursionist
21 0 10

@Doug-from-Maine wrote:

Stevo, simply adding "?discount=your_discount" to the URL didn't work for me.

 

What does work is to use the discount permalink, with a redirect. For example:

https://<your shop url>/discount/<your discount code>?redirect=/products/<your product>


I'm a few months too late to the show Doug, but thanks for the solution, saved me such a headache here, you have no idea

TheMktngGeek
Shopify Partner
3 0 0

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

Alex263
Tourist
8 0 6

It works. I creted a discount code buy x get y, and a permalink with 2 producst and aded at the end of permalink ?discount=my_discount   code

GreatDealMate
Tourist
5 0 1

Easy ! Here is a code to add discount to actual page url inside liquid if it help someone : {{ shop.url }}/discount/<your discount code>?redirect={{ request.path }}

mahdad
Visitor
2 0 0

I'm trying to use this same structure to apply a discount code to a product that I'm adding to the cart via permalink URL. So basically from the URL I want to end up on the payment page with code applied. Without the code this structure works.

https://<domain.com>/cart/30884299341923:3

While this goes to the cart it doesn't add the discount code. Any ideas?

https://<domain.com>/cart/30884299341923:3?redirect=/discount/<discount-code>

 

GreatDealMate
Tourist
5 0 1

The disount is applied automatically in checkout, not in cart.

Not great and bit desorienteing for customer but the simplest is to tell them the discount will be deducted in the next step.

Sve_FB
Tourist
5 0 2

I spoke to Shopify about this --> It turns out that when adding redirect, platform clears cookies and this is why it would never work.

abdullah_omar04
Excursionist
24 0 1

oh no...
so there is no way to do this? 

LukaszWiktor
Shopify Partner
315 24 123

Hi @abdullah_omar04,

As @Sve_FB already replied, you can find it under Discount > Promot > Get a sharable link

LukaszWiktor_0-1610642594388.png

LukaszWiktor_1-1610642970554.png

In the Shopify docs, it's described in the article titled Managing discount codes.

I just tested the link on mobile (Android/Chrome), and it worked correctly.

I'm a software engineer. I make things happen automatically.
Check out my apps Exporteo, Fulfilleo, Stockeo, and Personal Discount.
abdullah_omar04
Excursionist
24 0 1

Thank you so much for the screenshot!
@LukaszWiktor 

BrianVPS
Excursionist
13 0 11

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!

Tenler
Shopify Partner
6 0 3

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.

abdullah_omar04
Excursionist
24 0 1
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!
BrianVPS
Excursionist
13 0 11

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 😞

 

Apache_Douh
Visitor
1 0 0

Thanks Man 🙂

Sve_FB
Tourist
5 0 2

Actually the discount is added on Desktop automatically, but not working in this sequence on mobile... unfortunatelly.

e.g.

<site_url>/discount/<discount_code>?redirect=/cart/<product_unique_id>:1?channel=buy_button 

All works fine on Desktop - Chrome & Mozzila

Doesn't work when in Private mode & on Safari (no matter if Private or not)

Mobile - I have tested only on iPhone and it doesn't work.

*By not working - I mean that product is added to cart, but discount is not applied automatically.

So - if someone has updated or working option for Mobile devices or without redirect (because this won't work in general on Private browsing) - would be strongly appreciated 🙂

MonCoco
New Member
4 0 0

Hi, 

It seems that it doesn't work for me anymore. "?discount=XXX"

Do you have heard any news about that ? 

Thanks

Doug-from-Maine
Tourist
4 0 24

Stevo, simply adding "?discount=your_discount" to the URL didn't work for me.

 

What does work is to use the discount permalink, with a redirect. For example:

https://<your shop url>/discount/<your discount code>?redirect=/products/<your product>

or

https://<your shop url>/discount/<your discount code>?redirect=/collections/<your collection>/products/<your product>

 

I tested this works for Shopify checkout, including Amazon and Paypal express checkout. It doesn't work for our recurring checkout through ReCharge, though, which is a bummer. Not sure if it would work with other 3rd party / app checkouts. 

 

 

Sai_Teja_Netha
Visitor
1 0 0

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

 

robot_tr
New Member
6 0 0

TY for helping!

IliaZ
Shopify Partner
11 3 1

Thanks for the lead doug

Ana_Gabi_Mannel
Tourist
3 0 2

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

George_C
Trailblazer
162 2 150

@Ana_Gabi_Mannel wrote:

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


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

Monster, creature & cryptozoology patches, buttons & stickers.
jam_chan
Shopify Partner
927 23 190

@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-option...

 

BYOB - Build Your Own Bundles, SPO - SEO App to research keywords & edit social link preview
George_C
Trailblazer
162 2 150

@jam_chan Thanks!!

Monster, creature & cryptozoology patches, buttons & stickers.

HenryReith
Shopify Partner
6 1 3

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. 

Bae6
Visitor
2 0 1

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

usmanakram
Shopify Partner
1 0 0

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

HenryReith
Shopify Partner
6 1 3

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? 

StephenEngineer
Shopify Partner
3 0 0

Hello @usmanakram @HenryReith 

I wanted to suggest Adsgun as a potential solution for your needs. Adsgun enables you to add multiple code applications.

With Adsgun, you can apply discount codes through the URL parameter "?adsguncode=[CODE1],[CODE2]". This feature is highly beneficial for marketing efforts, as it allows Adsgun to auto-apply and display savings on every relevant page, including:

  • Collection Page Product Cards
  • Product Page
  • Related Products Section
  • Cart Page
  • Cart Drawer
  • Any Custom Page

Additionally, Adsgun provides discount input for multiple code applications to place anywhere in your theme, similar to the input on the checkout page.

The app also includes live chat support directly from the dashboard, ensuring you can get any questions answered quickly.

You can learn more about Adsgun here:

Shopify App & Theme Developer - Problem Resolver.