Hey @Alan_G !
Thanks for helping out. Please check below details for more information.
Here is my function for creating the discount
async createAutomatic({
title,
functionId,
startsAt = new Date(),
endsAt = null,
metafields = [],
appliesOnSubscription = true,
recurringCycleLimit = 0,
combinesWith = {
orderDiscounts: false,
productDiscounts: false,
shippingDiscounts: false,
},
}) {
const mutation = `#graphql
mutation CreateAutomaticDiscount($discount: DiscountAutomaticAppInput!) {
discountCreate: discountAutomaticAppCreate(automaticAppDiscount: $discount) {
automaticAppDiscount {
discountId
}
userErrors {
code
message
field
}
}
}`;
const variables = {
discount: {
title,
functionId,
combinesWith,
appliesOnSubscription,
recurringCycleLimit: parseInt(recurringCycleLimit) || 0,
startsAt,
endsAt,
},
};
const response = await this.admin.graphql(mutation, { variables });
const { data: { discountCreate } } = await response.json();
this.handleUserErrors(discountCreate.userErrors, "create automatic discount");
const discountId = discountCreate.automaticAppDiscount.discountId;
if (metafields.length > 0) {
await this.setMetafields(discountId, metafields);
}
return discountCreate.automaticAppDiscount;
}
The function create the discount successfully and no error. When I query that the created discount, here is what I get with graphQL
Query
query DiscountByID{
discountNode(id: "gid://shopify/DiscountAutomaticNode/1274072694937"){
id
discount{
... on DiscountCodeApp{
appliesOnSubscription
appliesOnOneTimePurchase
appliesOncePerCustomer
}
... on DiscountAutomaticApp{
appliesOnSubscription
appliesOnOneTimePurchase
recurringCycleLimit
}
}
metafields(first: 10){
nodes{
key
namespace
value
}
}
}
}
Result
{
"data": {
"discountNode": {
"id": "gid://shopify/DiscountAutomaticNode/1274072694937",
"discount": {
"appliesOnSubscription": true,
"appliesOnOneTimePurchase": true,
"recurringCycleLimit": 0
},
"metafields": {
"nodes": [
{
"key": "$app:function",
"namespace": "app--154741309441--function-configuration",
"value": "json data placeholder"
}
]
}
}
},
"extensions": {
"cost": {
"requestedQueryCost": 8,
"actualQueryCost": 5,
"throttleStatus": {
"maximumAvailable": 2000,
"currentlyAvailable": 1995,
"restoreRate": 100
}
}
}
}
Hey @bkspace I’m using Shopify native subscription app for the subscription. I had a client who reported this and their customers are not getting discount in future orders despite having the options to recurringCycleLimit = 0
@Alan_G I’m not using subscriptionDraftDiscountAdd/Update
Not sure if you’ve access to my dev store but here is the first order with discount applied
https://admin.shopify.com/store/checkout-features-dev/orders/5982738743484
Here is the contract ID
https://admin.shopify.com/store/checkout-features-dev/apps/subscriptions-remix/app/contracts/30838128828
Thank you!