Now we have Buy X Get Y / Order Discount / Product Discount.
But All of them can be used infinitely until deleted / cancelled.
I want to create a discount code that can only be applied once, then it’s deleted/ cancelled.
Any solution?
Now we have Buy X Get Y / Order Discount / Product Discount.
But All of them can be used infinitely until deleted / cancelled.
I want to create a discount code that can only be applied once, then it’s deleted/ cancelled.
Any solution?
Hey @Polarove, you can limit discount codes to specific customers or groups and restrict usage per customer using the discountCodeBasicCreate mutation. The key fields are:
context - Target specific customer segments or individual customersappliesOncePerCustomer: true - Limits the code to one use per customer (tracked by email/phone)usageLimit - Sets total uses across all customersHere’s an example targeting a customer segment:
mutation CreateSegmentDiscount($basicCodeDiscount: DiscountCodeBasicInput!) {
discountCodeBasicCreate(basicCodeDiscount: $basicCodeDiscount) {
codeDiscountNode {
id
}
userErrors {
field
message
}
}
}
Variables:
{
"basicCodeDiscount": {
"title": "One-Time Discount",
"code": "ONETIME10",
"context": {
"customerSegments": {
"add": ["gid://shopify/Segment/YOUR_SEGMENT_ID"]
}
},
"customerGets": {
"value": {
"percentage": 0.10
},
"items": {
"all": true
}
},
"appliesOncePerCustomer": true
}
}
For context, automatic deletion after use isn’t currently supported. The code remains in your admin after reaching usage limits (though it becomes inactive). Can you share more about your use case for needing automatic deletion? For example, are you trying to prevent code reuse, manage admin clutter, or implement a specific workflow? This would help me submit a more detailed feature request if needed.
Relevant docs:
Hey @Polarove, did the above help at all?