first commit
This commit is contained in:
@@ -0,0 +1 @@
|
||||
.yagi-price-container{display: flex; gap: 0.5em; align-items: center;} .yagi-price-container .price__sale { display: flex; flex-direction: row !important; justify-content: flex-end; gap: 0.5em; align-items: center;} .yagi-discounted-price { font-size: 14px; color: var(--color-error); } .yagi-original-price { font-size: 14px; } .yagi-sale-badge { font-size: 14px; color: var(--color-error); }
|
||||
@@ -0,0 +1,251 @@
|
||||
{% comment %}
|
||||
Renders a list of product's price (regular, sale)
|
||||
Accepts:
|
||||
- product_ref: {Object} Product Liquid object
|
||||
- use_variant: {Boolean} Renders selected or first variant price instead of overall product pricing (optional)
|
||||
- price_class: {String} Adds a price class to the price element (optional)
|
||||
- price_extra_info: {Boolean} Show extra info about price (optional)
|
||||
Usage:
|
||||
{% render 'price', product_ref: product %}
|
||||
{% endcomment %}
|
||||
|
||||
{%- liquid
|
||||
if use_variant
|
||||
assign target = product_ref.selected_or_first_available_variant
|
||||
else
|
||||
assign target = product_ref
|
||||
endif
|
||||
|
||||
assign variant = product_ref.selected_or_first_available_variant
|
||||
|
||||
assign compare_at_price = target.compare_at_price
|
||||
assign price = target.price | default: 1999
|
||||
|
||||
if target == product_ref and product_ref.price_varies == false
|
||||
assign compare_at_price = target.compare_at_price_max
|
||||
endif
|
||||
|
||||
if use_variant
|
||||
assign price = target.metafields.app--168074346497.auto_discounted_price.value | default: target.price
|
||||
|
||||
if target.metafields.app--168074346497.discount_type.value != nil and target.metafields.app--168074346497.discount_type.value != "fixed" and product_ref.metafields.app--168074346497.discount_percentage.value > 0.01
|
||||
assign deducted_percentage = 1.0 | minus: product_ref.metafields.app--168074346497.discount_percentage.value
|
||||
|
||||
if target.metafields.app--168074346497.discount_percentage.value > 0.01
|
||||
assign deducted_percentage = 1.0 | minus: target.metafields.app--168074346497.discount_percentage.value
|
||||
endif
|
||||
|
||||
assign price = target.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil
|
||||
|
||||
assign compare_at_price = target.price
|
||||
|
||||
if target.compare_at_price > compare_at_price
|
||||
assign compare_at_price = target.compare_at_price
|
||||
endif
|
||||
endif
|
||||
|
||||
if shop.metafields.app--168074346497.discount_percentage.value > 0.005
|
||||
assign discount_percentage = shop.metafields.app--168074346497.discount_percentage.value | times: 1.0
|
||||
assign deducted_percentage = 1.0 | minus: discount_percentage
|
||||
|
||||
assign price = target.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil
|
||||
|
||||
assign compare_at_price = target.price
|
||||
|
||||
if target.compare_at_price > compare_at_price
|
||||
assign compare_at_price = target.compare_at_price
|
||||
endif
|
||||
endif
|
||||
|
||||
if price < target.price and compare_at_price == blank
|
||||
assign compare_at_price = target.price
|
||||
endif
|
||||
else
|
||||
assign price = product_ref.metafields.app--168074346497.min_auto_discounted_price.value | default: product_ref.price
|
||||
|
||||
if product_ref.metafields.app--168074346497.discount_percentage.value > 0.01
|
||||
assign deducted_percentage = 1.0 | minus: product_ref.metafields.app--168074346497.discount_percentage.value
|
||||
|
||||
assign price = product_ref.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil
|
||||
|
||||
assign compare_at_price = product_ref.price
|
||||
|
||||
if product_ref.compare_at_price > compare_at_price
|
||||
assign compare_at_price = product_ref.compare_at_price
|
||||
endif
|
||||
endif
|
||||
|
||||
if shop.metafields.app--168074346497.discount_percentage.value > 0.005
|
||||
assign discount_percentage = shop.metafields.app--168074346497.discount_percentage.value | times: 1.0
|
||||
assign deducted_percentage = 1.0 | minus: discount_percentage
|
||||
|
||||
assign price = product_ref.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil
|
||||
|
||||
assign compare_at_price = product_ref.price
|
||||
|
||||
if product_ref.compare_at_price > compare_at_price
|
||||
assign compare_at_price = product_ref.compare_at_price
|
||||
endif
|
||||
endif
|
||||
|
||||
if price < product_ref.price and compare_at_price == blank
|
||||
assign compare_at_price = product_ref.price
|
||||
endif
|
||||
endif
|
||||
|
||||
assign available = target.available | default: false
|
||||
assign money_price = price | money
|
||||
assign price_extra_info = price_extra_info | default: false
|
||||
|
||||
if settings.show_currency_codes
|
||||
assign money_price = price | money_with_currency
|
||||
endif
|
||||
|
||||
|
||||
-%}
|
||||
|
||||
<div class="price
|
||||
{%- if price_class %} {{ price_class }}{% endif -%}
|
||||
{%- if available == false %} price--sold-out {% endif -%}
|
||||
{%- if compare_at_price > price %} price--on-sale {% endif -%}
|
||||
{%- if product_ref.price_varies == false and product_ref.compare_at_price_varies %} price--no-compare{% endif -%}
|
||||
{%- if show_badges %} price--show-badge{% endif -%}
|
||||
">
|
||||
<div class="price__container">
|
||||
{%- if product_ref -%}
|
||||
{%- if target == product_ref and product_ref.price_varies -%}
|
||||
{%- liquid
|
||||
assign money_price_min = product_ref.price_min
|
||||
assign money_price_max = product_ref.price_max
|
||||
|
||||
assign compare_at_price_max = product_ref.compare_at_price_max
|
||||
|
||||
if compare_at_price < price
|
||||
assign min_price_class = 'class="sale"'
|
||||
assign money_price_min = product_ref.compare_at_price_min
|
||||
endif
|
||||
-%}
|
||||
|
||||
{%- if compare_at_price_max > money_price_max -%}
|
||||
|
||||
{%- assign sale_container_class = 'price__sale' -%}
|
||||
|
||||
{%- if show_sale_badge -%}
|
||||
{%- assign sale_container_class = sale_container_class | append: ' price__sale--has-badge' -%}
|
||||
|
||||
{%- capture sale_text_html -%}
|
||||
<span class="text-navigation-button sale">
|
||||
{{- 'products.product.price.sale_badge' | t -}}
|
||||
</span>
|
||||
{%- endcapture -%}
|
||||
{%- endif -%}
|
||||
|
||||
<div class="{{ sale_container_class }}">
|
||||
<div class="price__sale-inner">
|
||||
<span class="visually-hidden">{{- 'products.product.price.regular_price' | t -}}</span>
|
||||
<del>{{- compare_at_price_max | money -}}</del>
|
||||
|
||||
<ins>
|
||||
{{- 'products.product.price.from_price' | t -}}
|
||||
<span class="visually-hidden">{{- 'products.product.price.min_price' | t -}}</span>
|
||||
<span {{ min_price_class }}>{{- money_price_min | money -}}</span>
|
||||
|
||||
<span aria-hidden="true">-</span>
|
||||
|
||||
<span class="visually-hidden">{{- 'products.product.price.max_price' | t -}}</span>
|
||||
<span>{{- money_price_max | money -}}</span>
|
||||
</ins>
|
||||
</div>
|
||||
|
||||
{{ sale_text_html }}
|
||||
</div>
|
||||
|
||||
{% else %}
|
||||
<div class="price__regular">
|
||||
<span class="visually-hidden">{{- 'products.product.price.min_price' | t -}}</span>
|
||||
<span>{{- product_ref.price_min | money -}}</span>
|
||||
|
||||
<span aria-hidden="true">-</span>
|
||||
|
||||
<span class="visually-hidden">{{- 'products.product.price.max_price' | t -}}</span>
|
||||
<span>{{- product_ref.price_max | money -}}</span>
|
||||
</div>
|
||||
{%- endif -%}
|
||||
|
||||
|
||||
|
||||
{%- elsif compare_at_price > price -%}
|
||||
{%- assign sale_container_class = 'price__sale' -%}
|
||||
|
||||
{%- if show_sale_badge -%}
|
||||
{%- assign sale_container_class = sale_container_class | append: ' price__sale--has-badge' -%}
|
||||
|
||||
{%- capture sale_text_html -%}
|
||||
<span class="text-navigation-button sale">
|
||||
{{- 'products.product.price.sale_badge' | t -}}
|
||||
</span>
|
||||
{%- endcapture -%}
|
||||
{%- endif -%}
|
||||
|
||||
<div class="{{ sale_container_class }}">
|
||||
<div class="price__sale-inner">
|
||||
<span class="visually-hidden">{{- 'products.product.price.regular_price' | t -}}</span>
|
||||
<del>{{- compare_at_price | money -}}</del>
|
||||
<span class="visually-hidden">{{- 'products.product.price.sale_price' | t -}}</span>
|
||||
<ins>{{- money_price -}}</ins>
|
||||
</div>
|
||||
|
||||
{{ sale_text_html }}
|
||||
</div>
|
||||
{%- else -%}
|
||||
<div class="price__regular">
|
||||
<span class="visually-hidden">{{- 'products.product.price.regular_price' | t -}}</span>
|
||||
<span>{{- money_price -}}</span>
|
||||
</div>
|
||||
{%- endif -%}
|
||||
|
||||
|
||||
{%- if variant.unit_price_measurement -%}
|
||||
<div class="product__notice caption caption--small">
|
||||
<span class="visually-hidden">
|
||||
{{- 'products.product.price.unit_price' | t -}}
|
||||
</span>
|
||||
|
||||
{%- if settings.show_currency_codes -%}
|
||||
{{- variant.unit_price | money_with_currency -}}
|
||||
{%- else -%}
|
||||
{{- variant.unit_price | money -}}
|
||||
{%- endif -%}
|
||||
|
||||
<span aria-hidden="true">/</span>
|
||||
|
||||
{%- if variant.unit_price_measurement.reference_value != 1 -%}
|
||||
{{- variant.unit_price_measurement.reference_value -}}
|
||||
{%- endif -%}
|
||||
|
||||
{{- variant.unit_price_measurement.reference_unit -}}
|
||||
</div>
|
||||
{%- endif -%}
|
||||
|
||||
{%- if price_extra_info and cart.taxes_included or shop.shipping_policy.body != blank -%}
|
||||
<div class="price__notice caption caption--small">
|
||||
{% liquid
|
||||
assign taxes_text = ''
|
||||
|
||||
if cart.taxes_included
|
||||
assign taxes_text = 'products.product.include_taxes' | t | append: ' '
|
||||
endif
|
||||
|
||||
if shop.shipping_policy.body != blank
|
||||
assign shipping_text = 'products.product.shipping_policy_html' | t: link: shop.shipping_policy.url
|
||||
assign taxes_text = taxes_text | append: shipping_text
|
||||
endif
|
||||
%}
|
||||
{{- taxes_text -}}
|
||||
</div>
|
||||
{%- endif -%}
|
||||
{%- else -%}
|
||||
<span>{{- 9999 | money -}}</span>
|
||||
{%- endif -%}
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user