How to fetch applicable promotions on specific product using graphql

How to fetch applicable promotions on specific product using graphql

Khasim1
Shopify Partner
30 0 0

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
30 0 0

Can any one share their response on the above query?