A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Discount Code lookup endpoint REST API return 404 for discounts with new Buy X Get Y option with minimum purchase amount https://andrii-sh10.myshopify.com/admin/api/2019-10/discount_codes/lookup.json?code=SpendXBuyY
My discount code SpendXBuyY - "Spend £20.00, Get 1 item free"
Other discounts works fine.
Solved! Go to the solution
This is an accepted solution.
Hi @AndriiMeretskyi ,
The Buy X Get Y discount type with the set minimum purchase amount feature is only accessible via the GraphQL Admin API that is versioned for release 2020-01. Hope that helps.
To learn more visit the Shopify Help Center or the Community Blog.
This is an accepted solution.
Hi @AndriiMeretskyi ,
The Buy X Get Y discount type with the set minimum purchase amount feature is only accessible via the GraphQL Admin API that is versioned for release 2020-01. Hope that helps.
To learn more visit the Shopify Help Center or the Community Blog.
Hi,
The REST API returns an ID for a discount code when you hit the discount codes API at
/admin/api/2020-04/price_rules/#{price_rule_id}/discount_codes.json
Like so:
{ "discount_codes": [ { "id": 507328175, "price_rule_id": 507328175, "code": "SUMMERSALE10OFF", "usage_count": 0, "created_at": "2020-04-06T10:20:16-04:00", "updated_at": "2020-04-06T10:20:16-04:00" } ] }
What is the equivalent when using GraphQL? It seems in GraphQL API there is no id for discount codes that belong to a price rule. Am I missing something or is this no longer something we can access?
Hi @Enea ,
You could achieve the same query in GraphQL like this:
{ priceRule(id: "gid://shopify/PriceRule/298501144598") { discountCodes(first:50) { edges { node { id code usageCount } } } } }
However with the GraphQL API you can bypass PriceRules altogether and just query for the discount codes directly: https://shopify.dev/tutorials/create-and-manage-discounts-with-admin-api . So you can just directly get the discount codes without worrying about the price rules:
{ codeDiscountNodes (first:10) { edges { node { id codeDiscount { __typename } } } } }
To learn more visit the Shopify Help Center or the Community Blog.