Can I replace the sale label with a discount percentage on the Dawn theme?

Hello,

I use DAWN theme and I want to ask you can I change the sale label with the with label that showing the percentage of the sale?

Hope you can help me?

Hello,

If you want to show the sale in percentage on products listing page then you can use the code below in file “product-card.liquid” under snippets :


          {%- if product_card_product.available == false -%}
          {{ 'products.product.sold_out' | t }}
          {%- elsif product_card_product.compare_at_price > product_card_product.price and product_card_product.available -%}
          
            {% comment %}{{ 'products.product.on_sale' | t }}{% endcomment %}
            {% if product_card_product.compare_at_price_max > product_card_product.price %}
            {{ product_card_product.compare_at_price_max | minus: product_card_product.price | times: 100.0 | divided_by: product_card_product.compare_at_price_max | money_without_currency | times: 100 | remove: '.0'}}% off
            {% endif %}
          
          {%- endif -%}
        

and

if you want to show the sale in percentage on product detail page then you need to add this code in “price.liquid” under snippets:


      {%- if product.available == false -%}
      {{ 'products.product.sold_out' | t }}
      {%- elsif product.compare_at_price > product.price and product.available -%}
      
        {% comment %}{{ 'products.product.on_sale' | t }}{% endcomment %}
        {% if product.compare_at_price_max > product.price %}
        {{ 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'}}% off
        {% endif %}
      
      {%- endif -%}

Thank you.

Thank you for sharing this info.

Do you know if there’s a code to change “Sale” with “Save ”?