Hi, I have the Envy theme and I want to replace the sales badge with the percentage, I tried with the code I find in the forum community but it has always had 0 as a percentage, how can I solve?
Thank you
Hi, I have the Envy theme and I want to replace the sales badge with the percentage, I tried with the code I find in the forum community but it has always had 0 as a percentage, how can I solve?
Thank you
Hello,
Use this one
{% if product.compare_at_price_max > product.price %}Save {{ product.compare_at_price_max | minus: product.price | times: 100.0 | divided_by: product.compare_at_price_max | money_without_currency | times: 100 | remove: '.0'}}%{% endif %}
Thanks
Hello,
thanks for your answer, i tried the code but it doesn’t give me the percentage, it just comes out empty.
This is the original code:
{% if liquidObject.available %}
{% if liquidObject.compare_at_price_max > liquidObject.price and settings.sale_badge %}
{{ 'products.general.sale' | t }}
{% endif %}
if i try to put this:
{{ current_variant.compare_at_price | minus: current_variant.price | times: 100.0 | divided_by: current_variant.compare_at_price | money_without_currency | times: 100 | remove: '.0'}}%
it gives me always 0%
This the the entire original code, can you help me?
{% if liquidObject.available %}
{% if liquidObject.compare_at_price_max > liquidObject.price and settings.sale_badge %}
{{ 'products.general.sale' | t }}
{% endif %}
{% elsif settings.sold_out_badge %}
{{ 'products.product.sold_out' | t }}
{% endif %}
For those who are looking to solve the issue, change the current variant or products to liquidObject, kinda like this :
{% if liquidObject.available %} {% if liquidObject.compare_at_price_max > liquidObject.price and settings.sale_badge %}
{{liquidObject.compare_at_price | minus: liquidObject.price | times: 100 | divided_by: liquidObject.compare_at_price }}% off
{% endif %} {% elsif settings.sold_out_badge %}
{{ ‘products.product.sold_out’ | t }}
{% endif %}