What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Graphql API → How to query discounts by their types?

Solved

Graphql API → How to query discounts by their types?

Zolbayar
Shopify Partner
47 1 10

I've been using the following graphql query to retrieve Bxgy discounts, but it's returning nothing even though I have a bunch of Bxgy discounts retrievable by query:"status:active"

Is this syntax correct to query by discount type? Is there any other key other than DiscountCodeBxgy for the Bxgy discount type? 

 

{
    codeDiscountNodes (first: 2 query:"discount_type:DiscountCodeBxgy") {
        pageInfo {
            hasNextPage
        }
        edges {
            cursor
            node {
                id
                codeDiscount {
                    __typename
                    ... on DiscountCodeBxgy  {
                        createdAt 
                        endsAt
                        startsAt 
                        status 
                        summary 
                        title 
                    }
                }
            }
        }
    }
}

 

 

Accepted Solution (1)

Kevin_A
Shopify Staff
318 42 61

This is an accepted solution.

Hey @Zolbayar 

The documentation lists the valid options for discount_type as "bogo, fixed_amount, free_shipping, percentage". See here: https://shopify.dev/docs/admin-api/graphql/reference/queryroot

Kevin_A | Solutions Engineer @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Replies 3 (3)

Zolbayar
Shopify Partner
47 1 10

Any idea? 

Kevin_A
Shopify Staff
318 42 61

This is an accepted solution.

Hey @Zolbayar 

The documentation lists the valid options for discount_type as "bogo, fixed_amount, free_shipping, percentage". See here: https://shopify.dev/docs/admin-api/graphql/reference/queryroot

Kevin_A | Solutions Engineer @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Zolbayar
Shopify Partner
47 1 10

Thanks, @Kevin_A!

I completely overlooked that! Now it works

 

query:"status:active discount_type:bogo"