How to get on Sale product on storefont

How to get on Sale product on storefont

AlexBoy
Shopify Partner
27 0 8

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
1451 238 497

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 8

hi @ShopifyDevSup 

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

 

AlexBoy_0-1676343650613.png

 

ShopifyDevSup
Shopify Staff
1451 238 497

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 8

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 10

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 10

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?