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.

Re: How to get on Sale product on storefont

How to get on Sale product on storefont

AlexBoy
Shopify Partner
27 0 10

hi team,

 

We need to get discounted products to display off the Homepage.
For example, get products with price > Compare-at price

We tried the query below but it didn't work as expected

products(first: 5, query:"is_price_reduced:true") { 
    edges{
      cursor
      node
      {
        id
        title
        description
        tags
        variants(first:10)
        {
          edges
          {
            node
            {
              availableForSale
              id
              compareAtPrice
              price
              title
            }
          }
        }
      }
    }
  }

Is there any API or solution?

 

 

Thanks

Hau

Replies 6 (6)

ShopifyDevSup
Shopify Staff
1453 238 525

Hi @AlexBoy 👋

 

Would you please try the query with `is_price_reduced:1` instead? 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us 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

AlexBoy
Shopify Partner
27 0 10

hi @ShopifyDevSup 

It didn't work for us, because some product appeared with "compareAtPrice": null

 

AlexBoy_0-1676343650613.png

 

ShopifyDevSup
Shopify Staff
1453 238 525

Would you please confirm that all of the variants of returned product have null `compareAtPrice` fields? It would be expected for the product to be returned if any one of its variants have a reduced price.

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us 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

AlexBoy
Shopify Partner
27 0 10

hi @ShopifyDevSup ,


@ShopifyDevSup wrote:

Would you please confirm that all of the variants of returned product have null `compareAtPrice` fields? It would be expected for the product to be returned if any one of its variants have a reduced price.


All variants compareAtPrice is null

phester17
Shopify Partner
22 1 14

Hi @ShopifyDevSup 

I am having the same issue, even when the compare_at_price is NULL. The "is_price_reduced" filter does not seem to work properly. Please see the results of this query:

 

phester17_1-1699294676054.png

 

I also have both a product and a product variant with reduced prices in the store that are NOT showing in the results:

phester17_2-1699294760204.png

phester17_3-1699294783204.png

 

 

Can you please help figure out what the issue is? This query is critical to our sale promotions.

phester17
Shopify Partner
22 1 14

Hi @ShopifyDevSup 

We are also having an issue with the is_price_reduced query. It doesn't return products with reduced prices and doesn't seem to change the results at all. When I remove the query I get the exact same products.

I've tried using "is_price_reduced:1" as well, but it returns the same results.

phester17_0-1698960226812.png

 

Is this a bug or am I doing something wrong?