<p>My suggestion:
The discounted price will only be shown for the item already ADDED to the cart.</p>
<pre><code>{% for lineItem in cart.lineItems %}
{{ dump(lineItem.total) }}
{% endfor %}
</code></pre>
<p><a href="https://i.sstatic.net/IwsZa.png" rel="nofollow noreferrer">https://i.sstatic.net/IwsZa.png</a></p>
<p><a href="https://docs.craftcms.com/commerce/api/v3/craft-commerce-models-lineitem.html#public-properties" rel="nofollow noreferrer">https://docs.craftcms.com/commerce/api/v3/craft-commerce-models-lineitem.html#public-properties</a></p>
<p>Therefore, I think you can get a <a href="https://docs.craftcms.com/commerce/api/v3/craft-commerce-elements-variant.html#sales" rel="nofollow noreferrer">saleModel</a> applicable to the iterable variant
and then use <a href="https://i.sstatic.net/Z760w.png" rel="nofollow noreferrer">these properties</a> to manually calculate and display the discount</p>
<p><a href="https://docs.craftcms.com/commerce/api/v3/craft-commerce-models-sale.html#public-properties" rel="nofollow noreferrer">https://docs.craftcms.com/commerce/api/v3/craft-commerce-models-sale.html#public-properties</a></p>

CC BY-SA 4.0
2022-07-01T13:59:26.660Z
2022-07-01T13:59:26.660Z
RomanAvr
<p>Craft shows the sale running, and can tell which products are on sale using a:</p>
<pre><code>{% set saleProducts = craft.products()
  .hasVariant({
    hasSales: true,
    hasStock: true
}).all() %}
</code></pre>
<p>loop, but on the product itself. However, <code>variant.onSale</code> doesn't detect the sale, and <code>variant.salePriceAsCurrency</code> brings up the original price.</p>
<p>In the CMS looks like things are set up correctly -- the sale is connected to the product/varient and the product is promotable.</p>
<p>What am I missing here?</p>

CC BY-SA 4.0
2022-06-30T20:52:03.853Z
Can you share your ``for`` code that spits out the ``saleProducts``?
RitterKnight
<craft3><plugin-craftcommerce><ecommerce>
Problem running a sale on the site
# Problem running a sale on the site

(Asked by: username_0 on 2022-06-29)

Craft shows the sale running, and can tell which products are on sale using a:
{% set saleProducts = craft.products()
  .hasVariant({
    hasSales: true,
    hasStock: true
}).all() %}

loop, but on the product itself. However, variant.onSale doesn't detect the sale, and variant.salePriceAsCurrency brings up the original price.
In the CMS looks like things are set up correctly -- the sale is connected to the product/varient and the product is promotable.
What am I missing here?

**Tags:** craft3, plugin-craftcommerce, ecommerce
> **Comments:**
> **username_1**: Can you share your ``for`` code that spits out the ``saleProducts``?  

---

## 1 answers

### Answer by username_2 on 2022-07-01. Score: 1

My suggestion:
The discounted price will only be shown for the item already ADDED to the cart.
{% for lineItem in cart.lineItems %}
{{ dump(lineItem.total) }}
{% endfor %}

https://i.sstatic.net/IwsZa.png
https://docs.craftcms.com/commerce/api/v3/craft-commerce-models-lineitem.html#public-properties
Therefore, I think you can get a saleModel applicable to the iterable variant
and then use these properties to manually calculate and display the discount
https://docs.craftcms.com/commerce/api/v3/craft-commerce-models-sale.html#public-properties


---

