Hi!
May i how to calculate the percent of discount an round to integer? May i know it using what programming language? Python? or php?
{% float special_promotion = round ((product.compare_at_price_max - product.price) / product.compare_at_price_max * 100) %}
<p><font style="color:red;">(Special {{ special_promotion }}% Promotion)</font>
How to correct this statement coding of the calculation of the percentage of the discount from the product.compare_at_price_max and product.price?
i got error of the code below? May i know how to correct it? Thanks
..............................
{% float special_promotion = round ((product.compare_at_price_max - product.price) / product.compare_at_price_max * 100) %}
<p><font style="color:red;">(Special {{ special_promotion }}% Promotion)</font>
..............................
example as below:
<div class="product-single__prices{% if shop.taxes_included or shop.shipping_policy.body != blank %} product-single__prices--policy-enabled{% endif %}">
{% if product.compare_at_price > product.price %}
<span id="ComparePriceA11y" class="visually-hidden" aria-hidden="false">{{ 'products.product.sale_price' | t }}</span>
<s id="ComparePrice" class="product-single__sale-price">
{{ cart.currency.iso_code }} {{ product.compare_at_price_max | money }}
</s>
{% else %}
<span id="ComparePriceA11y" class="visually-hidden" aria-hidden="true">{{ 'products.product.sale_price' | t }}</span>
<s id="ComparePrice" class="product-single__sale-price hide">
{{ cart.currency.iso_code }} {{ product.compare_at_price_max | money }}
</s>
{% endif %}
<span id="PriceA11y" class="visually-hidden">{{ 'products.product.regular_price' | t }}</span>
<span id="ProductPrice" class="product-single__price" itemprop="price" content="{{ product.price | divided_by: 100.00 }}">
{{ product.price | money }}
</span>
{% if product.compare_at_price > product.price %}
<!-- start:add special discount code -->
<font style="color:red;">(Special ({{ product.compare_at_price_max | money }} - {{ product.price | money }}) / {{ product.compare_at_price_max | money }}% Promotion)</font>
<p>
<p>
{% float special_promotion = round ((product.compare_at_price_max - product.price) / product.compare_at_price_max * 100) %}
<p><font style="color:red;">(Special {{ special_promotion }}% Promotion)</font>
<!-- start:add special discount code -->
{% endif %}
{% include 'product-unit-price', variant: variant, available: true %}
</div>