Autofill Discount via URL - A Step by Step Walkthrough (eg. Auto Apply discount code using a Link!)

New Member
2 0 0

Hi, I am working with same app , evertything is working fine even form action is also showing 

<form action="/cart?discount=twopercent" method="post" id="cartform">

discount querystring but after that when its redirecting to checkout page, discount is not automatically applying on price and its not working. Please help to resolve this issue.

0 Likes
Shopify Staff
Shopify Staff
339 0 48

If anyone is uncomfortable implementing this and can't afford to hire an expert at the moment, I just wanted to pop-in and let you know there is an app that can help facilitate: https://apps.shopify.com/autofill-discount-from-url

But amazing guide! I'm going to be bookmarking it for myself. ;)

Alicia | Support Lead for Shopify
1 Like
Highlighted
Shopify Expert
195 0 23

@rvtech Is twopercent an active discount in your store? Also, what is your store url? That will help us investigate your issue. 

Stop Stressing About Shopify You’ve Got Better Things To Do => https://320ny.com/shopify/
0 Likes
New Member
2 0 0

Ok this all looks pretty straight forward. My quesion is how do I create the discount codes/urls themselves?

 

0 Likes
Shopify Partner
1659 48 169

Valeriy Volkov

https://help.shopify.com/manual/products/discount-codes

 

Problem Solved? ✔️Accept the solution so you can help others.
Confused? Busy? ? Get me to solve it paull.newton+shopifyforum@gmail.com.
Buy me a coffee? ☕ paypal.me/paulnewton or donate to eff.org
0 Likes
New Member
2 0 0

ok thanks Paul

I thought this should pull from our discount codes that we created in the admin panel.

 

I have gotten the discount to work if I set this line  <input id="discount_input" type="hidden" name="discount" value=" "> to a specific discount code in ("name="10percentoff" for example). How do I get this to automatically apply the discount code from the url? 

Maybe I missed this in the thread... but i'm not sure I saw anything about it.

0 Likes
Excursionist
34 0 9

Hi Valeriy, I would start completely over and make sure you are reading through every part of this tutorial correctly and that you understand what the code is actually doing. If any of these steps are confusing I would very strongly recommend hiring a Shopify Expert [I’m not one!] to help out. The whole point of this tutorial is to have the customer click a link, which then stores your discount code [which you should have already created on your Shopify backend] and applies it to the Shopify checkout URL once the customer reaches checkout. Manually hard-coding your discount into your website code [if that’s what you’re doing] defeats the whole purpose of the tutorial.   ;)

0 Likes
Shopify Partner
1659 48 169

Valeriy Volkov, hopefully all is right and you just have to read over this tutorial, but if you want to delegate and finish  then this is one of the customizations I provide, reach out to me by the email in my signature.

But if you do everything to the letter and still get problems remember to provide a storefront password so forum volunteers can take a look.

Problem Solved? ✔️Accept the solution so you can help others.
Confused? Busy? ? Get me to solve it paull.newton+shopifyforum@gmail.com.
Buy me a coffee? ☕ paypal.me/paulnewton or donate to eff.org
0 Likes
Excursionist
14 0 11

Thanks for this share -- 

Unfortunately, on the Retina theme, no love.

I made the edit to the cart script, to match the form id

document.getElementById('cart_form').action = "/cart?discount=" + sessionStorage.getItem("discount");

But still no love.

I also tried the two apps that claim to accomplish this, neither worked.

Anyone get this working with Retina (or other Out of the Sandbox theme) ?
Thx

 

0 Likes
Shopify Expert
122 0 19

Hey guys, I read all this thread and felt so much the pain that my team and I've decided to build it. Stop struggling with code or coupon code, try this free app instead: https://apps.shopify.com/automatic-discount-rules. The difference between our app and the one mentioned by the Shopify employee above is that it works :) You can apply a discount automatically from a link (Discount URL), but also based on the cart content (amount spent, total number of items or similar items, weight of the order and more to come based on your feedback). That means you can create discounts for customers buying more than $X or buy 2 items and get the 3rd one for free or if your order is really heavy, you get X% off. The app is in beta and we already received great feedbacks for future features. Check this out: https://apps.shopify.com/automatic-discount-rules

2 Likes