Passing discount codes to PayPal/Amazon on the cart page

Highlighted
Shopify Partner
87 1 22

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?

Bart Coppens | Limoni Apps | Building apps for Shopify since 2016
1 Like
Highlighted
Shopify Staff
Shopify Staff
619 48 94

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,

1 Like
Highlighted
Shopify Partner
87 1 22

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!

Bart Coppens | Limoni Apps | Building apps for Shopify since 2016
0 Likes
Highlighted
Shopify Partner
87 1 22

Bump.

Any news on this?

Bart Coppens | Limoni Apps | Building apps for Shopify since 2016
0 Likes
Highlighted
Shopify Partner
87 1 22

Hi,

Still looking for information on how to apply the discount code in a PayPal checkout from the cart.

Best regards,

Bart

Bart Coppens | Limoni Apps | Building apps for Shopify since 2016
0 Likes
Highlighted

+1

Stuart @ Booster Apps (https://apps.shopify.com/partners/booster-apps)
0 Likes
Highlighted
Shopify Partner
87 1 22

Any update?

Bart Coppens | Limoni Apps | Building apps for Shopify since 2016
0 Likes
Highlighted
Shopify Partner
87 1 22

Bump

Bart Coppens | Limoni Apps | Building apps for Shopify since 2016
0 Likes
Highlighted

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.. 

Stuart @ Booster Apps (https://apps.shopify.com/partners/booster-apps)
0 Likes
Highlighted
Shopify Partner
87 1 22

Thanks for your feedback Steve.

Would be great to hear from the Shopify product team indeed.

Bart Coppens | Limoni Apps | Building apps for Shopify since 2016
2 Likes