Discount links that apply a code automatically
Share a Shopify link that applies a discount code automatically and lands on any page: /discount/CODE?redirect=/collections/summer, plus the QR code.
- Format
- /discount/<CODE>?redirect=/<path>
- Where
- Discounts > discount > Promote
- Limit
- One discount per link
- Plan
- Every plan
- Last checked
In short
A Shopify shareable discount link, your-store.com/discount/CODE, saves the code to the visitor’s cart and browser and opens the home page; the code applies at checkout. Add ?redirect=/collections/summer to land on another page. Get the link, with optional UTM tags and a QR code, from Discounts > the discount > Promote > Get a shareable link. It works for active discount codes on every plan.
How to use it
- Create and save the discount code first; only active discounts get a link.
- Open it under Discounts, click Promote and choose Get a shareable link; pick the landing page and, optionally, a marketing campaign for UTM tags.
- To land somewhere else, change /discount/CODE to /discount/CODE?redirect=/collections/your-collection.
- Test the link in a private window and check the code at checkout.
Code
discount-link-button.liquid{%- comment -%}
A banner button that applies a code and lands on a collection or product.
The code and target come from section settings (text + url), so marketing
can change them without a code edit. Uses the documented /discount/<code>
path with ?redirect=<relative path>.
{%- endcomment -%}
{%- assign code = section.settings.discount_code | strip -%}
{%- assign target = section.settings.target_url | default: routes.all_products_collection_url -%}
{%- if code != blank -%}
<a class="button" href="/discount/{{ code | url_encode }}?redirect={{ target }}">
Shop with {{ code }}
</a>
{%- endif -%}
links.txt# Shareable discount link: applies the code and opens the home page
https://your-store.com/discount/WELCOME10
# Same code, but land on a collection or product instead
https://your-store.com/discount/WELCOME10?redirect=/collections/summer
https://your-store.com/discount/WELCOME10?redirect=/products/example-product
# Get the link from the admin: Discounts > (discount) > Promote > Get a shareable link
# Optional: pick a marketing campaign there to add its UTM parameters.
# Need the cart filled too? Use a cart permalink with ?discount= instead
https://your-store.com/cart/12345678901234:1?discount=WELCOME10
Written by Lintel. MIT license: free to use in your own store and in client work.
Limits and edge cases
- The code stays on the cart and in the browser until the customer removes it at checkout or clears cookies; opening the link again re-applies it.
- The link combines with other discounts only as your combination settings allow, and the 5-code limit per order still applies.
- Codes created by an app don’t get a shareable link in the admin; check the app.
- To fill the cart and apply a code in one link, use a cart permalink with ?discount=CODE.
Questions
- How do I make a Shopify link that applies a discount code?
- Use your-store.com/discount/CODE. Get it from Discounts > the discount > Promote > Get a shareable link.
- Can a discount link go to a specific product or collection?
- Yes. Add ?redirect= with the path: /discount/CODE?redirect=/products/example-product.
- How does a customer remove a discount applied by a link?
- They click Remove beside the code at checkout, or clear the store’s cookies and come back without the link.
- Does the discount link work with automatic discounts?
- Shareable links are for discount codes. The code then combines with automatic discounts if both allow that combination.
Shopify documentation
- Checked on a Shopify store on the date shown. Shopify changes its admin often; if a step looks different, the idea usually still works.
- Examples use placeholder IDs and your-store.myshopify.com. Replace them with your own.
- MIT license for the code snippets.
Need this built, tested and maintained for your store? See Shopify development.
