Shopify URL for discount, adding a product, and redirect

Shopify URL for discount, adding a product, and redirect

ex-homedepot
Visitor
1 0 1

Hello, is there a url structure/permalink which supports adding a product to the cart with a discount code and redirects the user?

 

For instance:

this applies a discount and redirects to the specified page
http://site.com/discount/codegoeshere/?redirect=/collections/all

 

This adds an item and applies a discount but sends me directly to checkout. I'd like to redirect to another page on the site. Is this possible with this method?
http://site.com/cart/1234567:1?discount=codegoeshere

 

This adds an item and sends the user to the cart page.
http://site.com/cart/add?id=1234567&quantity=1

 

My end goal is to Add a product to the cart. Apply a discount and redirect the user. Can you point me in the right direction? thanks

 

Replies 4 (4)

Elias
Shopify Staff
3010 294 522

Hello, @ex-homedepot.

 

Elias here with Shopify Support. Thank you for reaching out and this is a great question!

 

There isn't a URL structure that supports this natively but there is a third-party app with the ability to create pre-filled cart links with discounts attached, called Automatic Discount. While going directly to checkout might not be possible, it’s possible to send them to the product pages or cart page. Automatic Discount app offers a 7 day free trial for you to try out. If you require assistance with this app, you can reach out to the developer directly through the contact information found in the Support section of the app’s page.

 

Let me know if this helps! If you have any further questions regarding this topic, feel free to reply to this thread and I’d be happy to help.

Elias | Social Care @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

resboss
Shopify Partner
34 0 6

Sorry just this solution dont work.

 

Can you please post real example here?

c_zagarskas
Excursionist
22 1 24
Simple Answer: YES you can "add a product to the cart with a discount code and redirect the user"
This adds items AND a discount AND redirects to a page
https://[SITE].com/cart/add?id=[VARIANT]&quantity=[QTY]&return_to=/discount/[CODE]?redirect=/pages/about-us
https://[SITE].com/cart/add?id=[VARIANT]&quantity=[QTY]&return_to=/discount/[CODE]?redirect=/collections/all
https://[SITE].com/cart/add?id=[VARIANT]&quantity=[QTY]&return_to=/discount/[CODE]?redirect=/products/some-product-name
 
========================
Cheat sheet: 
Important note, for those URLs to work you have to use the VARIANT ID, not the product id. 
Shopify has made this unnecessarily difficult and hard to find, note the instructions below
========================
Get Product variant ID of a SINGLE product that has no variants
by visiting admin edit page, and add .json to the url
 
For example, consider this url:
https:// admin.shopify.com /store /my-store /products /90000000009 
you have to add JSON to the end like this: 
https:// admin.shopify.com /store /my-store /products /90000000009.json
90000000009 is your product ID, but you need a VARIANT ID which will be 4000000004
 
search for the variant id on the json page
ctrl+f = "variants":[{"id":
 
Set up your Discount code
TENOFF for example
========================
Now you can use these:
========================
This applies a discount and redirects to the specified page
https:// [SITE].com/discount/[CODE]/?redirect=/collections/all
https:// [SITE].com/discount/[CODE]/?redirect=/products/some-product-name
 
This adds an item and applies a discount sends to CHECKOUT
https:// [SITE].com/cart/[VARIANT]:[QTY]?discount=[CODE]
 
This adds an item and sends the user to the CART page.
https:// [SITE].com/cart/add?id=[VARIANT]&quantity=[QTY]
 
This adds an item AND a discount AND redirects to a page
https:// [SITE].com/cart/add?id=[VARIANT]&quantity=[QTY]&return_to=/discount/[CODE]?redirect=/pages/about-us
https:// [SITE].com/cart/add?id=[VARIANT]&quantity=[QTY]&return_to=/discount/[CODE]?redirect=/collections/all
https:// [SITE].com/cart/add?id=[VARIANT]&quantity=[QTY]&return_to=/discount/[CODE]?redirect=/products/some-product-name
 
This simply adds X items to cart and sends to CHECKOUT
https:// [SITE].com/cart/[VARIANT]:[QTY]
 
This simply adds X items to cart and sends to CART
https:// [SITE].com/cart/add?id=[VARIANT]&quantity=[QTY]
 
========================
Outdated info, but semi valid
========================