Updated saved percentage based on variant

Updated saved percentage based on variant

orhl1234
Shopify Partner
110 0 9

 I Have this code that display a percentage saved.

But if i have a variant with a diffrent price or compraed price, the number percantage wont update.

how can i make it update based on the variant?

                      {%- when 'price' -%}
                        <div class="{{ spacing_classes }}" style="--custom-margin-bottom: {{ block.settings.margin_bottom }}px" {{ block.shopify_attributes }}>
                          <div class="product-price-size--{{ block.settings.price_font }} product-price-group">
                            <span class="visually-hidden">{{ 'products.general.sale_price' | t }}</span>
<span style="color:#fff;background-color:#000;border-radius:20px;padding:0 7px;margin-left:4%;font-weight:bold;font-size:15px;margin-bottom:5px; height: 25px">
                {% 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 %}
                    </span>   

orhl1234_1-1714662456454.png

 

 

Replies 2 (2)

LuffyOnePiece
Shopify Partner
650 93 119

Hi @orhl1234 ,

 

We do need to add custom code for this.

 

Let me know if you need any assistance.

 

Thank you

Sandeep Pangeni
Need help with your store? sandeeppangeni17@gmail.com
For quick response, Contact In WhatsApp +9779867521184
orhl1234
Shopify Partner
110 0 9

i would love to