Currently works for Dawn v10
I know few peopled have been looking for this solution for awhile. I know I have. Even though, this won’t automatically terminate the sale but it is a solution that works.
First step is to create Metafield Integer called Sale.Discount under Products. Make sure it’s exposed to Storefront.
Then Look for this bit of code in Price.Liquid
{%- comment -%} No Compare Price
Explanation of description list:
- div.price__regular: Displayed when there are no variants on sale
- div.price__sale: Displayed when a variant is a sale
{%- endcomment -%}
And Copy this code below
{%- comment -%} No Compare Price {%- endcomment -%}
{{ 'products.product.price.regular_price' | t }}
{{ money_price }}
{%- comment -%} With Compare Price {%- endcomment -%}
{%- unless product.price_varies == false and product.compare_at_price_varies %}
{%- comment -%} This IF/ELSEIF checks if product has 'Sale' TAG. If it does, it generates promo price. {%- endcomment -%}
{% if product.tags contains 'Sale' %}
{%- comment -%} This code will use metafield discount amount to calculate the new price. {%- endcomment -%}
{% assign discount = product.metafields.sale.discount | times: product.price | divided_by: 100 %} {% assign discountedPrice = product.price | minus: discount %}
Sale Price: {{ discountedPrice | money }}
{% else %}{%- comment -%} This is the Original code for Compare Price {%- endcomment -%}
{{ 'products.product.price.regular_price' | t }}
<s>
{% if settings.currency_code_enabled %}
{{ compare_at_price | money_with_currency }}
{% else %}
{{ compare_at_price | money }}
{% endif %}
</s>
{% endif %}
{%- endunless -%}
{{ 'products.product.price.sale_price' | t }}
{%- comment -%} This bit of code check if item is on sale, if not, it will strike it out. Similar to how original code did to Compare price {%- endcomment -%}
{% if product.tags contains 'Sale' %}
~~Price:{{ money_price }}~~
{% else %}
{{ money_price }}
{% endif %}
to just above this line
<small>
Then change sale badge code
{%- if show_badges -%}
to
{%- if product.tags contains 'Sale' and show_badges -%}
This won’t be suitable for people with Buy 1, get 1 % OFF. Price.Liquid controls collection pages and Product pages. But you can still use it you add Promotion details. Just add separate metafield to Main-Product to something like
{{ product.metafields.sale.details }}
If anyone wants to tip me for this, just message me.