Is it possible to apply discount to all products automaticlly

Iam making promotion on all my products and i want to make price before and after available, i tried to use compare at function but it didn’t work well on my theme

Hi @samer157 ,

Do you want to add a discount to all products and display the price according to the discount?

First, you need to create ‘Automatic discount’, it will have an option for you to choose to apply to all products:

Then you need to change the code to show the discount price instead of the actual price of the product. Because when you add compare, it will still show discount based on compare price.

You can refer to the following code:

{%- assign price = product.price -%}
{%- assign percentage = 0.3 -%}
{%- assign price_discount = price | times: percentage -%}
{{ price | minus: price_discount | money }}

On the product page, you need to hire an expert for it, because it will need to check the JS also to show the price when changing variants.

Hope it helps!

1 Like