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.

How to fetch applicable promotions on specific product using graphql

How to fetch applicable promotions on specific product using graphql

Khasim1
Shopify Partner
32 0 3

Hi 

 

I am trying to display applicable promotions for a product on PDP, is there any way where we can get promotions applicable to a product by passing handle or id of the product using graphql. Currently I am able to get all the discounts present in the store and the products but it returns all the promotions and all products  which have promotions. Can I pass the product handle and get promotions on PDP for that specific product without fetching data which is not required ?

 

Below I am sharing the query which I ran for getting discounts:

query {
  codeDiscountNodes(first: 10) {
    nodes {
      id
      codeDiscount{
        ... on DiscountCodeBasic {
          title
          summary
          shortSummary
          customerGets{
            items {
            ... on DiscountProducts{
              products(first:2){
                edges{
                  node{
                    id
                    handle
                  }
                }
              }
            }
            }
          }
          codes(first:1){
            nodes{
              code
            }
          }
        }
      }
    }
  }
 
}
Reply 1 (1)

Khasim1
Shopify Partner
32 0 3

Can any one share their response on the above query?