Development discussions around Shopify APIs
Passing discount codes to the checkout
To pass a discount code to the checkout page app developers can use the "discount" query parameter. Example: sample.myshopify.com/checkout?discount=SUMMERSALE
To pass this discount code to the checkout different techniques can be used. The two key methods are: 1/ add the "discount" query parameter to the action of the form that is submitted by the "Checkout" button. Or 2/ add/update a hidden "discount" form field in that same form.
Using shareable discount links
The above technique can be used to automatically apply discount codes. Merchants can alternatively use the native shareable discount links which store the discount code in a cookie and ensure it is applied correctly.
The issue: how does one pass a discount code to "additional buttons" checkouts, e.g. PayPal?
Many shops provide the ability to check out from the cart page using PayPal (and sometimes Amazon, ...) from the CART page, instead of through the normal checkout page.
As explained above it is easy for apps to pass discount codes to the checkout.
However, when a visitor initiates the PayPal checkout immediately from the cart page (buttons added in liquid using "{{ content_for_additional_checkout_buttons }}") the above mentioned techniques (form field / query parameter on action url) do not work. PayPal will not pick up the discount code. Or better: Shopify will not process the discount first before invoking PayPal.
One could conclude that there is no way to achieve this then. But, shareable discount links prove that it is possible. Try the following scenario:
- Browse to the following shareable discount link: https://paypal-test-discountninja.myshopify.com/discount/SPRINGSALE
- Add one or more shirts to your cart
- Check out using PayPal from the cart (don't go to the checkout)
- Result: discount is applied (50%)
Question: how is this achieved by shareable discount links and how can app developers leverage this technique to ensure merchants can offer PayPal from the cart in combination with discount apps?
Hi Bart,
While I can't go into the details of our codebase, I can say that shareable discount links use a combination of cookies tied to the customer session and some backend code that runs once the link is visited.
We don't currently have any specific developer function with shareable links, aside from the use of them in their existing form you are already aware of.
Can you touch on what you are looking to do that can't be achieved by the shareable discount link in its current form? If you feel there's a gap in our offering, I'd love to bring that feedback to the relevant teams.
Cheers,
Andrew | 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
Hi Andrew,
Thanks for your reply. Apologies for getting back to you this late.
Thanks for sharing the approach to shareable discount links.
We have tried tapping into this mechanism by overriding the cookie placed by Shopify, but that doesn't seem to (always) work. Perhaps because the Shopify backend code checks the value of other cookies to ensure the discount cookie has the original value? Or perhaps we're just not setting the cookie right.
You asked what we want to do with this. We (and many other apps) extend the capabilities of the Shopify platform by providing smart ways to run special deals (the app is called Discount Ninja). Our app relies on the standard Shopify discounts (and Price Rule API) to have the correct discount applied at checkout. This works fine on 1000+ stores. However, what doesn't work fine is the ability to check out from the cart page (not the checkout page) using PayPal (see description above). We're looking for a supported way to tell Shopify to tell PayPal to apply the correct discount.
Should be pretty simple, but we can't find any information on it.
Looking forward to your reply!
Bump.
Any news on this?
Hi,
Still looking for information on how to apply the discount code in a PayPal checkout from the cart.
Best regards,
Bart
+1
Any update?
Bump
We ended up having to hide the additional payment buttons for customers - which our users are obviously less than thrilled about 😞
Any input from @shopify would be greatly appreciated here..
Thanks for your feedback Steve.
Would be great to hear from the Shopify product team indeed.
Any updates here @Shopify? 😞
Bump +1
Booster Apps user here and would love a fix for this. Any updates?
Hi there,
Any plans to address this one? As app developers, we (and our merchants) are having the exact same problem as our friends above.
Thanks,
Tom
Looking for an update! Thank you!
User | RANK |
---|---|
16 | |
7 | |
6 | |
6 | |
5 |
Learn these 5 things I had to learn the hard way with starting and running my own business
By Kitana Jan 27, 2023Would you love to unleash the unbridled power of the Google Shopping Channel into your sho...
By Gabe Jan 6, 2023How can you turn a hobby into a career? That’s what Emmanuel did while working as a wa...
By Skye Dec 30, 2022