Show Sale Percentage

Hi I am on symmetry theme and I want to replace the word “Sale” to instead show the percentage off

Website is cartolinanantucket.com - attaching image,


thank you!

Hello @jn10 ,

Find the existing code location.

Remove/Comment existing code.
And use this one

{%- unless product.price_varies == false and product.compare_at_price_varies %}
  
    {%- assign percent = compare_at_price | minus: price | times: 100 | divided_by: compare_at_price | round -%}
    {{ percent }}% off
  
    
  {%- endunless -%}

Note: Make sure do necessary changes in the code a/to the theme you are using.

Regards
Guleria

Hi - where would this be located? I am using symmetry theme

Hi @jn10

I hope you are well.

Please go to your theme and share with me the screenshot of this code part from your theme:

This code might be located in “price.liquid” file, “product.liquid” file, or “main-product.liquid” file. You can find it in any of 3 files I shared, we need the source code from the theme to customize it further.

Looking forward to hearing from you soon. Thank you!

Best,
Daisy - Avada Support Team.

Hi @jn10

Could you share your product-block.liquid file of your theme so I can check and give you the code?

Hi Dan - here you go:

{%- liquid
if collection and settings.prod_thumb_url_within_coll
assign product_url = product.url | within: collection
else
assign product_url = product.url
endif

assign product_images = product.media | where: ‘media_type’, ‘image’
if settings.prod_thumb_hover_image and product_images.size > 1
assign show_hover_image = true
else
assign show_hover_image = false
endif

assign cheapest_variant = product.variants | sort: ‘price’ | first
-%}

{% if product.featured_media %} {%- liquid assign aspect_ratios_same = true for media in product.media offset: 1 if media.preview_image.aspect_ratio != product.media.first.preview_image.aspect_ratio assign aspect_ratios_same = false break endif endfor -%}
{%- if show_hover_image -%}
{%- render 'responsive-image', image: product.media.first.preview_image, manual_image_load: manual_image_load, min_aspect_ratio: 0.6, aspect_ratio: custom_aspect_ratio, no_max_width: true, cover: settings.prod_thumb_crop -%}
{%- for media in product_images offset: 1 -%} {%- liquid assign image_state_class = '' if media.id == product.featured_media.id assign active_media_found = true assign image_state_class = 'product-block__image--active' else if active_media_found assign active_media_found = false assign image_state_class = 'product-block__image--show-on-hover product-block__image--inactivated' else assign image_state_class = 'product-block__image--inactivated' endif endif -%}
{%- endfor -%} {%- else -%}
{%- render 'responsive-image', image: product.featured_media.preview_image, manual_image_load: manual_image_load, min_aspect_ratio: 0.6, aspect_ratio: custom_aspect_ratio, no_max_width: true, cover: settings.prod_thumb_crop -%}
{%- endif -%}
{%- if show_hover_image -%} {%- unless no_swiping -%}
{%- if product_images.size > 2 -%}
{%- endif -%}
{%- endunless -%} {%- endif -%} {% render 'product-label', product: product, cheapest_variant: cheapest_variant %}
{%- if show_hover_image -%} {%- render 'svg-chevron-left', stroke_width: 1.3 -%} {%- render 'svg-chevron-right', stroke_width: 1.3 -%} {%- endif -%}

{% if settings.quickbuy_style == ‘button’ %}
{% unless no_quick_buy %}
{{ ‘products.quick_buy.launch’ | t }}
{% endunless %}
{% endif %}

{% else %}
{{ 'product-1' | placeholder_svg_tag }}
{% endif %}
{%- if section.settings.show_vendor -%}
{{ product.vendor }}
{%- endif -%}
{%- if product.metafields.accentuate.display_name -%} {{ product.metafields.accentuate.display_name }} {%- else -%} {{ product.title }} {%- endif -%} {%- if product.metafields.accentuate.display_name and product.metafields.accentuate.current_color_name -%} in {{ product.metafields.accentuate.current_color_name }} {%- endif -%}

{%- if settings.prod_thumb_show_subtitle and product.metafields.descriptors.subtitle != blank -%}

{{ product.metafields.descriptors.subtitle }}
{%- endif -%}
{% if product.price_varies %} {{ 'products.listing.from' | t }} {% endif %} {%- if settings.product_currency_code_enabled -%} {{ cheapest_variant.price | money_with_currency }} {%- else -%} {{ cheapest_variant.price | money }} {%- endif -%} {% if cheapest_variant.compare_at_price > cheapest_variant.price %} {{ cheapest_variant.compare_at_price | money }} {% endif %}

{% if settings.prod_sold_out_show and product.available == false %}
{{ ‘products.labels.sold_out’ | t }}
{% elsif settings.prod_pre_order_label_show and product.template_suffix contains ‘preorder’ %}
{{ ‘products.product.preorder’ | t }}
{% elsif settings.prod_sale_show and cheapest_variant.compare_at_price > cheapest_variant.price %}
{{ ‘products.labels.sale’ | t }}
{% endif %}

{% render ‘unit-price’, variant: cheapest_variant %}

{%- if settings.prod_thumb_show_options -%}
{%- liquid
assign option_limit = 3
assign options_to_show = settings.swatch_option_name | append: ‘,’ | append: settings.prod_thumb_options_names | replace: ', ', ‘,’ | split: ‘,’
-%}
{%- for product_option in product.options_with_values -%}
{%- if options_to_show contains product_option.name -%}
{%- liquid
if settings.swatch_enabled and settings.swatch_option_name contains product_option.name
assign is_swatch = true
else
assign is_swatch = false
endif
-%}

{%- if product.options.size == 1 -%} {%- for variant in product.variants -%} {%- liquid if is_swatch and settings.swatch_method == 'image' and variant.featured_media == blank continue endif -%} {{ variant.title }} {%- endfor -%} {%- if product.variants.size > option_limit and is_swatch -%} {%- assign remaining = product.variants.size | minus: option_limit -%} {{ 'collections.general.more_swatches' | t: count: remaining }} {%- endif -%} {%- else -%} {%- assign product_option_position_0index = product_option.position | minus: 1 -%} {%- for product_option_value in product_option.values -%} {%- liquid assign option_value_variant = false for variant in product.variants if variant.options[product_option_position_0index] == product_option_value assign option_value_variant = variant break endif endfor

if settings.prod_thumb_options_disable_unavailable
assign is_unavailable = true
for variant in product.variants
if variant.available and variant.options[product_option_position_0index] == product_option_value
assign is_unavailable = false
break
endif
endfor
else
assign is_unavailable = false
endif

if is_swatch and settings.swatch_method == ‘image’ and option_value_variant.featured_media == blank
continue
endif
-%}
<span class=“product-block-options__item{% if is_unavailable %} product-block-options__item–unavailable{% endif %}{% if forloop.index > option_limit and is_swatch %} product-block-options__item–truncated{% endif %}{% if is_swatch %} lazyload{% if manual_image_load %}–manual{% endif %}{% endif %}”
data-option-item=“{{ product_option_value | escape }}”
{% if option_value_variant.featured_media %}data-media=“{{ option_value_variant.featured_media.id }}”{% endif %}
{% if is_swatch %}
{%- if settings.swatch_method == ‘standard’ -%}
data-swatch=“{{ product_option_value | replace: '”', ‘’ | downcase }}"
{%- elsif settings.swatch_method == ‘image’ and option_value_variant.featured_media -%}
data-bgset=“{{ option_value_variant.featured_media.preview_image | img_url: ‘48x48’, crop: settings.swatch_crop_align }}”
{%- endif -%}
{% endif %}>{{ product_option_value }}
{%- endfor -%}
{%- if product_option.values.size > option_limit and is_swatch -%}
{%- assign remaining = product_option.values.size | minus: option_limit -%}
{{ ‘collections.general.more_swatches’ | t: count: remaining }}
{%- endif -%}
{%- endif -%}

{%- endif -%} {%- endfor -%} {%- endif -%}

{%- if settings.enable_product_reviews_collection and product.metafields.reviews.rating_count != blank -%}
{%- assign rating_count = product.metafields.reviews.rating_count | plus: 0 -%}
{%- if rating_count > 0 -%}

{% render 'rating', rating_value: product.metafields.reviews.rating.value %} {{ rating_count }} {{ 'products.product.reviews_link' | t: count: rating_count | downcase }}
{%- endif -%} {%- endif -%}

{%- if settings.quickbuy_style != ‘off’ -%}
{%- unless no_quick_buy_markup or no_quick_buy -%}

{%- endunless -%} {%- endif -%}

Please replace this line of code.

{{ 'products.labels.sale' | t }}

With this code

{%- assign percent = cheapest_variant.compare_at_price  | minus: cheapest_variant.price | times: 100 | divided_by: cheapest_variant.compare_at_price | round -%} 
{{ percent }}% OFF
1 Like

Hi @jn10

I’m not sure if you received my message.

Looking forward to hearing from you soon. Thank you!

Best,
Daisy - Avada Support Team.

Thank you Dan!

1 Like

Happy I could help!

Best regards,

Dan from Ryviu