Can I apply discount codes in the cart using the StoreFront API?

Can I apply discount codes in the cart using the StoreFront API?

hotsaucebg3
New Member
6 0 0

is it possible to apply discount codes in the cart, using the StoreFront API?

I've searched a lot for this, but didn't find a proper solution. Maybe create a checkout and modify it via the API?

Replies 7 (7)

hotsaucebg3
New Member
6 0 0

When I try to call /api/2021-01/graphql.json with jQuery (from the cart liquid template), it gives me CORS error.  how can I avoid that?

hotsaucebg3
New Member
6 0 0

noone?

I just need to apply discount on the cart with a private app/ or something

Jorge_Mosquera
Excursionist
16 1 2

If your store has a Shopify Plus Plan, you can apply a discount automatically by using javascript in the checkout.js file.

If not, you can add a discount code as a url paramenter. The discount will be automatically applied when the user reaches the checkout.

Startup Slang | Shopify Partners | Lead Shopify Developer
- Was my reply helpful? Please Like and Accept Solution.
- Feel free to contact us info@startupslang.com
dom_nguyen
Tourist
5 0 1

We've tried a couple different solutions (including KartDiscount).

KartDiscount essentially does a call to the checkout page and uses selectors to pull the discounted amount. This works for certain stores, but will eventually time the customer out due to Bot like activity.

We ended up just creating our own solution that hosted on our own server which takes in products & calculates the discount based on however you do discounts (tags/collections)

adevcoder
Shopify Partner
8 0 0

If you have Shopify plus then you can use the script editor for line item discount which will show up on the cart page. If you don't have Shopify plus then you can manipulate the cart page to display a discount and have a script that will auto-applied the discount code at the checkout page.

hopps
Tourist
44 0 1

Hi there! Here's an answer to your question: https://app.hopps.io/videos/how-do-i-apply-a-discount-on-the-cart-page-178663a7e21. If it doesn't make sense or you still have questions, one of the experts can walk you through the solution.

aahridoy
Shopify Partner
6 0 0

Looks like we couldn't find this video