Answers.Body: <p>the following query possibly produce the similar result</p>
  <pre><code>{% set variantsHasSales = craft.variants()
      .product(product)
      .hasSales(true)
      .all() 
  %}
  {% if variantsHasSales|length &gt; 0 %}
    code here for sales badge/message etc
  {% endif %}
  </code></pre>
  <p>reference : <a href="https://craftcms.com/docs/commerce/3.x/products-variants.html#variant-hassales" rel="nofollow noreferrer">https://craftcms.com/docs/commerce/3.x/products-variants.html#variant-hassales</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-19T16:50:12.073Z
Answers.LastActivityDate: 2021-08-19T16:50:12.073Z
Answers.UserDisplayName: Dzulfikar Adi Putra
Answers.Body: <p>So the only way I could seem to make this work was as follows:</p>
  <pre><code>{% set onSale = product.variants|filter(v =&gt; v.onSale())|length %}
  
  {% if onSale %}
     code here for sales badge/message etc
  {% endif %}
  </code></pre>
  <p>Not sure if there is a more direct method? If there is please let me know...</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-13T17:15:49.283Z
Answers.LastActivityDate: 2021-08-13T17:15:49.283Z
Answers.UserDisplayName: Terry Upton
Body: <p>I want to check if any variants (not the default variant) have any active sales applied.
  How can I do this at a product level when looping through products (think teasers).</p>
  
Tags: <plugin-craftcommerce>
Title: How can I check if a product has any variant that is on Sale?
ThreadText: # How can I check if a product has any variant that is on Sale?
  
  (Asked by: username_0 on 2021-08-13)
  
  I want to check if any variants (not the default variant) have any active sales applied.
  How can I do this at a product level when looping through products (think teasers).
  
  **Tags:** plugin-craftcommerce
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2021-08-19. Score: 1
  
  the following query possibly produce the similar result
  
  ```
  {% set variantsHasSales = craft.variants()
      .product(product)
      .hasSales(true)
      .all() 
  %}
  {% if variantsHasSales|length > 0 %}
    code here for sales badge/message etc
  {% endif %}
  
  ```
  
  reference : <https://craftcms.com/docs/commerce/3.x/products-variants.html#variant-hassales>
  
  
  ---
  
  ### Answer by username_0 on 2021-08-13. Score: 1
  
  So the only way I could seem to make this work was as follows:
  
  ```
  {% set onSale = product.variants|filter(v => v.onSale())|length %}
  
  {% if onSale %}
     code here for sales badge/message etc
  {% endif %}
  
  ```
  
  Not sure if there is a more direct method? If there is please let me know...
  
  
  ---
  
  