Hi Shopify Community,
I’m a Shopify app engineer experiencing inconsistencies with the Discount API implementation and would appreciate your insights.
Issue Details
I’m currently utilizing the new Discount API with Shopify Functions and have noticed a discrepancy in how discount codes are applied to subscription products:
- When using DiscountCodeApp with
appliesOnSubscription
set to false
, the Shopify Functions Discount API still executes even when subscription products are in the cart.
- However, when using DiscountCodeBasic with the same
appliesOnSubscription: false
setting, discounts are correctly not applied when subscription products are present.
This suggests that DiscountCodeApp may not be properly evaluating the appliesOnOneTimePurchase
and appliesOnSubscription
flags before executing the Discount API.
Could the team please investigate this potential inconsistency in the implementation?
Thank you for your assistance.
Hey @ogasawarakyohei - thanks for reaching out and flagging this. That does sound like unexpected behaviour to me. I’m happy to look into this for you for sure, could you share the following just so we can do a bit more troubleshooting on our end?
- An example order ID where the issue with DiscountCodeApp popped up?
- The ID of the discount code/node where you observed this behaviour.
- If possible, any relevant Shopify Function execution logs (specifically for the
DiscountCodeApp
scenario where it ran unexpectedly). Here’s a bit more info on how to generate logs if needed: Test and debug Shopify Functions
Hope to hear from you soon 
Hi @Alan_G !
Thanks for your quick response and willingness to investigate this issue. Here’s the information you requested:
Store: ruffruff-order-bonus.myshopify.com
Order ID: gid://shopify/Order/11424980009331
Discount code: RUFFRUFF-YT7TX2ZRUWS9WEH
Discount node: gid://shopify/DiscountCodeNode/1676935496051
Shopify Function execution input logs
{
"cart": {
"buyerIdentity": null,
"cost": {
"subtotalAmount": {
"amount": "990.0",
"currencyCode": "JPY"
},
"totalAmount": {
"amount": "990.0",
"currencyCode": "JPY"
}
},
"lines": [
{
"merchandise": {
"__typename": "ProductVariant",
"id": "gid://shopify/ProductVariant/52549582356851",
"product": {
"id": "gid://shopify/Product/15084052349299",
"inCollections": []
}
},
"quantity": 1
}
]
},
"discount": {
"metafield": {
"value": "{\"bonus\":{\"type\":\"orderDiscount\",\"value\":{\"type\":\"percentage\",\"fixedAmount\":\"0\",\"percentage\":\"10\"}},\"collectionIds\":[],\"conditions\":[],\"conditionsOperator\":\"and\",\"customerMetafieldKey\":\"\",\"customerMetafieldNamespace\":\"\",\"customerTags\":[],\"type\":\"single\"}"
}
},
"presentmentCurrencyRate": "1.0",
"triggeringDiscountCode": "RUFFRUFF-YT7TX2ZRUWS9WEH"
}
Shopify Function execution output logs
{
"operations": [
{
"orderDiscountsAdd": {
"candidates": [
{
"associatedDiscountCode": {
"code": "RUFFRUFF-YT7TX2ZRUWS9WEH"
},
"targets": [
{
"orderSubtotal": {
"excludedCartLineIds": []
}
}
],
"value": {
"percentage": {
"value": "10.0"
}
}
}
],
"selectionStrategy": "MAXIMUM"
}
}
]
}
Let me know if you need anything else to assist with troubleshooting.
Thanks @ogasawarakyohei for all the detailed info there - digging into this further for you. I’ll loop back when I have more info to share 
Hey @ogasawarakyohei - just following up with some information here as I was able to work with the team on this.
I can confirm that the issue with appliesOnSubscription: false
with DiscountCodeApp
still applying to subscription products via Functions is a known issue on our side and we are looking at making the process more clear in the future.
For now, the best workaround we have is to build this check directly into your Function. You should be able to do this by looking for a sellingPlanAllocation
on each cart line to see if it’s a subscription item (more info here).
My understanding is that the general thinking for Shopify Functions is that the validations should have their logic live within the Function itself rather than relying on API fields specifically (unless necessary), and the workaround above would actually be our recommended method for applying discount logic in Functions.
Apologies as well for any confusion this has caused, happy to help further if you have questions about tweaking your Function - just let me know!
1 Like
Thank you for your thorough investigation, Alan. I appreciate the clear explanation regarding the known issue with discount codes on subscription products. I understand that building validation directly into the Function by checking for sellingPlanAllocation is the recommended approach, rather than relying on API fields. I’ll implement this workaround in my code. Your explanation of Shopify’s philosophy on Function-based validation logic is helpful context. I’ll reach out if I have any questions while making these adjustments.
1 Like