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

New Member
2 0 0

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?

0 Likes

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.
0 Likes
New Member
2 0 0

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.

0 Likes
Shopify Partner
135 1 16

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 elliot@mandelbrotian.com for help with theme setup, alterations, custom functionality, and app development.
0 Likes
Highlighted
Excursionist
30 2 13

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.

1 Like
New Member
1 0 1

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. 

 

 

1 Like