Have your say in Community Polls: What was/is your greatest motivation to start your own business?
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.

Unable to fetch fixed amount off for Buy X get Y discounts using codeDiscountNodeByCode

Unable to fetch fixed amount off for Buy X get Y discounts using codeDiscountNodeByCode

Soumit_Kundu
Shopify Partner
1 0 2

Hi, I am using graphQL codeDiscountNodeByCode to fetch the detail of a discount code. My graphQL code as follows:

query {
  codeDiscountNodeByCode(code: "{discount_code}") {
    id
    codeDiscount {
    
    __typename
      ... on DiscountCodeBxgy {
        customerGets {
          value {
            __typename
            ... on DiscountAmount {
              amount {
                amount
                currencyCode
              }
              appliesOnEachItem
            }
            ... on DiscountOnQuantity {
              effect {
                ... on DiscountPercentage {
                  percentage
                }
              }
              quantity {
                quantity
              }
            }
            ... on DiscountPercentage {
              percentage
            }
          }
        }
        endsAt
        startsAt
        status
        title
        usesPerOrderLimit
      }      
    }
  }
}

This is working fine to fetch detail of a Buy X Get Y code when it is set as "Free" or "Percentage" discount on get item. But this is not working when the get item set as "Amount off each". It is throwing below error in this case:

{
  "errors": [
    {
      "message": "Internal error. Looks like something went wrong on our end.\nRequest ID: 6f8171e1-820a-43dc-b55c-29300da4d6c6 (include this in support requests).",
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "requestId": "6f8171e1-820a-43dc-b55c-29300da4d6c6"
      }
    }
  ]
}

However removing effect { ... } from customerGets.value.DiscountOnQuantity(line no 19 to 23), removes the error also, but in this case I am not able to fetch the value of amount or percentage for the get item. Is there any way to get those values?

Replies 3 (3)

lizk
Shopify Staff
246 58 78

Hi there 👋
This is a bug on our side. The team is aware of the issue and reviewing possible solutions.

To learn more visit the Shopify Help Center or the Community Blog.

Bentley_Sayer
Shopify Partner
6 0 0

This was fixed with the january 2024 version but is now again broken. I don't know how you guys keep breaking these types of codes but it is getting really irritating due to how many times I have had to debug your broken api.

sonchu
Shopify Partner
7 0 5

Having the same issue as well. 😞 

The error only happens when I include effect in the query