Applying discount codes in the cart (prior to checkout)

Highlighted
Tourist
10 0 0

We've been asked to add an (Apply) Discount Code text input to the client's side cart. I've done some discovery and found a couple apps what say they support this. On the other hand, we naturally want to be thorough and see if we can do it ourselves.  

I created a discount and used apply via link. 

https://help.shopify.com/en/manual/discounts/managing-discount-codes#promote-a-discount-using-a-shar...

When I get to the actual checkout page, the discount shows up (as it should). 

Then I added a get cart (via AJAX) to the side cart (prior to checkout):

https://shopify.dev/docs/themes/ajax-api/reference/cart#get-cart-js

And dump that via console.log() and the cart object returned doesn't show anything about a discount. No code. Nuttin'. 

Yet, if I continue on to checkout, the discount shows up again / still. 

Based on some additional research, evidently there's no way to apply a coupon code via AJAX. The last discussion I found was about a year old. Is there still no relatively easy way to apply a discount via Ajax? 

All that being said, if there are no other options, we'll go the app route. Does anyone have any suggestions for such apps?

 

 

 

 

 

0 Likes
Highlighted
Tourist
10 0 0

Bump. Anyone? Anything?

0 Likes