Retrieve discount codes entered on the checkout screen using Shopify functions

Retrieve discount codes entered on the checkout screen using Shopify functions

yohei23
Shopify Partner
3 0 0

We are currently using the Shopify script to validate discount codes entered on the checkout screen, but we are in the process of migrating this to be handled by Shopify functions when the script is discontinued in the future.
However, I cannot find a way to get the discount code entered on the checkout screen in Shopify functions.
If anyone knows how to do this, please let me know.
Along with that, we also need to get the customer's tag in Shopify functions. Please let me know if anyone knows how to do that as well. Thank you in advance.

Replies 3 (3)

EdwardGoomba
Shopify Partner
74 1 9

You might be able to target it using the dev preview discount api. This at least makes it look like you can grab the code - from there you could do something with it.

 

Have not tried this out yet.

Have any questions about theme customization?
Feel free to email me: edward@honos.dev
Problem Solved? ✔Accept and Like solutions to help future merchants
yohei23
Shopify Partner
3 0 0

Thank you for your guidance.
But how can I use this API to get the code entered from the checkout screen?

https://shopify.dev/docs/api/functions/reference/order-discounts/graphql/common-objects/discount
I don't see any field in the documentation that would allow me to retrieve the code entered.

Nico4
Shopify Partner
25 0 12

Same question here. Did you find any solution? @yohei23