Discussing Shopify Functions development, deployment, and usage in Shopify apps.
I would like to create an order discount with a code that is created offline by our app in a flow that is triggered when a user clicks a button on a checkout extension. The use case is a loyalty program, where a user exchange loyalty points for a discount. So the button in the checkout extension calls our backend which uses the offline access to the store to create a discount code. Then, I want to have this discount code to be applied to the cart, so that the customer will get the discount. I heard that this can be done using Shopify Functions, but I can't find any way to do it, since the function logic only runs after the discount code is applied to cart. The checkout extension obviously can't do it since there's no "applyDiscountCode" API for the extensions. Can this be done using Functions?
Hi @hadar-romash,
I think it is difficult to create code offline then apply on your store.
To use online, we also have our Joy Loyalty app which help you create code and apply when they check out orders. https://apps.shopify.com/joyio
Hope it will help you!
Appreciate the help, but I'm a loyalty app developer as well (https://apps.shopify.com/swell).
You're correct that Functions can't mutate the cart, they can only apply discounts based on the cart state. Checkout extensions can't yet apply discount codes either, but I am told this is in their backlog.
Is there a user flow for your app that would allow you to use discount code permalinks instead?
https://<shop url>/discount/<discount code>?redirect=<url>
Nick Wesselman | 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
We are developing a small user flow that uses permalinks, but our main flow is creating discount codes at checkout and adding them to the cart.