I am adding a custom code to add the discounted price of the products on my shopify product page.
Here is the code :
{% assign discount_percentage = 20 %} {% assign discounted_price = product.price | times: discount_percentage | divided_by: 100 %} {% assign final_price = product.price | minus: discounted_price %} {% assign rounded_final_price = final_price | floor %}
<div class="best-price">
<span>Best Price:</span>
<span class="discounted-price">{{ rounded_final_price | money_without_trailing_zeros }}</span>
</div>
It is working fine, but when different variation with different pricing is selected, it suppose to change the discounted price.
So I need help to make it ajax.
I tried script from this answer but it didn’t work : https://community.shopify.com/c/shopify-design/need-help-with-dynamic-liquid-code-update-for-variant-switching/m-p/2258140