简体   繁体   中英

Shopify API: Retrieve Orders with a specific DiscountCode

I am currently working on a project that creates Discount Codes via API and I need to retrieve which orders have used a specified Discount Code (ex: TESTCODE123). I couldn't find the documentation or API endpoint mentioned in the Shopify API pages. Is it possible to guide me on this?

You will need to use Admin GraphQL for this and rely on the query parameter to filter them out.

Example:

{
  orders(first: 10, query:"discount_code:TESTCODE123"){
    edges {
      node {
        id
      }
    }
  }
}

You can refer the docs here: https://shopify.dev/docs/admin-api/graphql/reference/queryroot?api[version]=2020-01

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM