A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
With the example query giving free shipping here (also attached below): https://shopify.dev/docs/api/admin-graphql/2023-07/mutations/discountCodeFreeShippingCreate
I how would I modify it to apply to one customer: "gid://shopify/Customer/12345" ?
Thanks in advance!
{ data: { "query": `mutation discountCodeFreeShippingCreate($freeShippingCodeDiscount: DiscountCodeFreeShippingInput!) { discountCodeFreeShippingCreate(freeShippingCodeDiscount: $freeShippingCodeDiscount) { codeDiscountNode { id codeDiscount { ... on DiscountCodeFreeShipping { title startsAt endsAt maximumShippingPrice { amount } customerSelection { ... on DiscountCustomerAll { allCustomers } } destinationSelection { ... on DiscountCountryAll { allCountries } } minimumRequirement { ... on DiscountMinimumSubtotal { greaterThanOrEqualToSubtotal { amount } } } codes(first: 2) { nodes { code } } } } } userErrors { field code message } } }`, "variables": { "freeShippingCodeDiscount": { "startsAt": "2022-06-22T21:12:07.000Z", "appliesOncePerCustomer": false, "title": "FreeShipping", "code": "FreeShipping", "minimumRequirement": { "subtotal": { "greaterThanOrEqualToSubtotal": 20.0 } }, "customerSelection": { "all": true }, "destination": { "all": true } } }, }, }
Solved! Go to the solution
This is an accepted solution.
Hi there 👋
You would want to modify the variables to specify which customers you want this discount code to apply to.
It should look something like this.
{
"freeShippingCodeDiscount": {
"startsAt": "2022-06-22T21:12:07.000Z",
"appliesOncePerCustomer": false,
"title": "FreeShipping",
"code": "FreeShipping",
"minimumRequirement": {
"subtotal": {
"greaterThanOrEqualToSubtotal": 20
}
},
"customerSelection": {
"customers": {
"add": ["gid://shopify/Customer/1234567"]
}
},
"destination": {
"all": true
}
}
}
If you are not already using it, I would recommend using the Shopify GraphiQL app. It has autocomplete so it can be helpful when modify queries.
To learn more visit the Shopify Help Center or the Community Blog.
This is an accepted solution.
Hi there 👋
You would want to modify the variables to specify which customers you want this discount code to apply to.
It should look something like this.
{
"freeShippingCodeDiscount": {
"startsAt": "2022-06-22T21:12:07.000Z",
"appliesOncePerCustomer": false,
"title": "FreeShipping",
"code": "FreeShipping",
"minimumRequirement": {
"subtotal": {
"greaterThanOrEqualToSubtotal": 20
}
},
"customerSelection": {
"customers": {
"add": ["gid://shopify/Customer/1234567"]
}
},
"destination": {
"all": true
}
}
}
If you are not already using it, I would recommend using the Shopify GraphiQL app. It has autocomplete so it can be helpful when modify queries.
To learn more visit the Shopify Help Center or the Community Blog.