How to display products with applied discount codes in React JS and GraphQL?

How to display products with applied discount codes in React JS and GraphQL?

ocianX
Shopify Partner
2 0 0

i want to show products with discount code coupon apply for this product automatically with code / react js /graphql

Reply 1 (1)

oscprofessional
Shopify Partner
16386 2441 3190

 

 

Hi @ocianX ,

Here is graphql to get products with discount code coupon.


 

query DISCOUNT {
  shop {
    name
  }
  codeDiscountNodes(first: 10) {
    edges {
      node {
        id
        codeDiscount {
          ... on DiscountCodeBasic {
            codes(first: 2) {
              edges {
                node {
                  id
                  code
                }
              }
            }
            customerGets {
              items {
                ... on DiscountProducts {
                  __typename
                  products(first: 10) {
                    edges {
                      node {
                        id
                        handle
                        title
                        
                      }
                    }
                  }
                }
              }
              value {
                ... on DiscountPercentage {
                  __typename
                  percentage     
                }
              }
            }
          }
        }
      }
    }
  }  
}

 

 

 

This will give you products with discount codes and value.

Let me know this worked for you or not.

 

Thanks....

Hire us | Pass Core Web Vital | B2B Wholesale Experts | Claim Your Free Website Review |
Connect with Us: WhatsApp | Skype: oscprofessionals-87 | Email: pallavi@oscprofessionals.com |
Custom Shopify SolutionsPrivate Apps, Theme Customization & SEO | Digital Marketing |
OSCP Apps: Discount Suite | Wholesale App | Bundle & Upsell | Shipping Discount | and more...