2

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?

1
  • Can you share your for code that spits out the saleProducts? Jun 30, 2022 at 20:52

1 Answer 1

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.stack.imgur.com/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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.