first commit
This commit is contained in:
commit
7609909121
6
README.md
Normal file
6
README.md
Normal file
@ -0,0 +1,6 @@
|
||||
# Prestige theme - Yagi Automatic Discount Helper app
|
||||
|
||||
This repository contains installation guide for Prestige theme (developed by Maestrooo).
|
||||
|
||||
This repository contains file in snippets folder, which you can copy paste and replace the existing file in your current Prestige theme, to display the automatic discounted price.
|
||||
|
231
snippets/price-list.liquid
Normal file
231
snippets/price-list.liquid
Normal file
@ -0,0 +1,231 @@
|
||||
{%- comment -%}
|
||||
----------------------------------------------------------------------------------------------------------------------
|
||||
PRODUCT PRICE
|
||||
----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Render a list of price for a product, variant or line item.
|
||||
|
||||
********************************************
|
||||
Supported variables
|
||||
********************************************
|
||||
|
||||
* product: if provided, the prices are rendered for the whole product
|
||||
* variant: if provided, then only the price from this variant is rendered
|
||||
* line_item: if provided, then the price from this line item are rendered (used on cart or order)
|
||||
* hide_unit_price: if set to true unit prices are hidden (mostly useful for size constrained elements)
|
||||
* context: can be "product", "line_item" or "card". This controls how the prices are displayed (using the correct sizes)
|
||||
{%- endcomment -%}
|
||||
|
||||
{%- liquid
|
||||
case context
|
||||
when 'card', 'line_item'
|
||||
assign base_text_class = ''
|
||||
|
||||
if settings.product_card_text_font == 'heading'
|
||||
assign base_text_class = 'h6 '
|
||||
endif
|
||||
|
||||
assign regular_price_classes = base_text_class | append: 'text-subdued'
|
||||
assign on_sale_price_classes = base_text_class | append: 'text-on-sale'
|
||||
assign compare_at_price_classes = base_text_class | append: 'text-subdued line-through'
|
||||
assign unit_price_classes = base_text_class | append: 'text-subdued'
|
||||
|
||||
|
||||
|
||||
when 'product'
|
||||
assign regular_price_classes = base_text_class | append: 'h4 text-subdued'
|
||||
assign on_sale_price_classes = base_text_class | append: 'h4 text-on-sale'
|
||||
assign compare_at_price_classes = base_text_class | append: 'h5 text-subdued line-through'
|
||||
assign unit_price_classes = base_text_class | append: 'h6 text-subdued'
|
||||
endcase
|
||||
-%}
|
||||
|
||||
<price-list class="price-list {% if context == 'product' %}price-list--product{% endif %}">
|
||||
{% assign variant_case_price = variant.price %}
|
||||
{% assign variant_case_compare_at_price = variant.compare_at_price %}
|
||||
|
||||
{% if variant.metafields.app--168074346497.auto_discounted_price.value %}
|
||||
{% if variant.metafields.app--168074346497.auto_discounted_price.value < variant_case_price %}
|
||||
{% assign variant_case_price = variant.metafields.app--168074346497.auto_discounted_price.value %}
|
||||
{% assign variant_case_compare_at_price = variant.price %}
|
||||
|
||||
{% if variant.compare_at_price > variant.price %}
|
||||
{% assign variant_case_compare_at_price = variant.compare_at_price %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{%- if variant != blank -%}
|
||||
{%- comment -%}
|
||||
--------------------------------------------------------------------------------------------------------------------
|
||||
VARIANT CASE (used on product page, quick view...)
|
||||
--------------------------------------------------------------------------------------------------------------------
|
||||
{%- endcomment -%}
|
||||
<sale-price class="{% if variant_case_compare_at_price > variant_case_price %}{{ on_sale_price_classes }}{% else %}{{ regular_price_classes }}{% endif %}">
|
||||
<span class="sr-only">{{ 'product.price.sale_price' | t }}</span>
|
||||
|
||||
{%- if settings.currency_code_enabled -%}
|
||||
{{- variant_case_price | money_with_currency -}}
|
||||
{%- else -%}
|
||||
{{- variant_case_price | money -}}
|
||||
{%- endif -%}
|
||||
</sale-price>
|
||||
|
||||
{%- if variant_case_compare_at_price > variant_case_price -%}
|
||||
<compare-at-price class="{{ compare_at_price_classes }}">
|
||||
<span class="sr-only">{{ 'product.price.regular_price' | t }}</span>
|
||||
|
||||
{%- if settings.currency_code_enabled -%}
|
||||
{{- variant_case_compare_at_price | money_with_currency -}}
|
||||
{%- else -%}
|
||||
{{- variant_case_compare_at_price | money -}}
|
||||
{%- endif -%}
|
||||
</compare-at-price>
|
||||
{%- endif -%}
|
||||
{%- elsif line_item != blank -%}
|
||||
{%- comment -%}
|
||||
--------------------------------------------------------------------------------------------------------------------
|
||||
LINE ITEM CASE (used on cart, order page...)
|
||||
--------------------------------------------------------------------------------------------------------------------
|
||||
{%- endcomment -%}
|
||||
<sale-price class="{% if line_item.original_price > line_item.final_price %}{{ on_sale_price_classes }}{% else %}{{ regular_price_classes }}{% endif %}">
|
||||
<span class="sr-only">{{ 'product.price.sale_price' | t }}</span>
|
||||
|
||||
{%- if settings.currency_code_enabled -%}
|
||||
{{- line_item.final_price | money_with_currency -}}
|
||||
{%- else -%}
|
||||
{{- line_item.final_price | money -}}
|
||||
{%- endif -%}
|
||||
{%- if line_item.properties.ccalc == "true" -%}
|
||||
<small class="custom-unit"> / per Total Sq Ft.</small>
|
||||
{%- endif -%}
|
||||
</sale-price>
|
||||
|
||||
{%- if line_item.original_price > line_item.final_price -%}
|
||||
<compare-at-price class="{{ compare_at_price_classes }}">
|
||||
<span class="sr-only">{{ 'product.price.regular_price' | t }}</span>
|
||||
|
||||
{%- if settings.currency_code_enabled -%}
|
||||
{{- line_item.original_price | money_with_currency -}}
|
||||
{%- else -%}
|
||||
{{- line_item.original_price | money -}}
|
||||
{%- endif -%}
|
||||
</compare-at-price>
|
||||
{%- endif -%}
|
||||
{%- elsif product != blank -%}
|
||||
{%- comment -%}
|
||||
--------------------------------------------------------------------------------------------------------------------
|
||||
PRODUCT CASE (used on card)
|
||||
--------------------------------------------------------------------------------------------------------------------
|
||||
{%- endcomment -%}
|
||||
{%- liquid
|
||||
if product.price_varies and settings.product_price_strategy != 'from_price'
|
||||
assign variant = product.variants | sort: 'price' | last | default: product.selected_or_first_available_variant
|
||||
else
|
||||
assign variant = product.variants | sort: 'price' | first | default: product.selected_or_first_available_variant
|
||||
endif
|
||||
|
||||
if settings.currency_code_enabled
|
||||
assign variant_price = variant.price | money_with_currency
|
||||
assign variant_compare_at_price = variant.compare_at_price | money_with_currency
|
||||
else
|
||||
assign variant_price = variant.price | money
|
||||
assign variant_compare_at_price = variant.compare_at_price | money
|
||||
endif
|
||||
|
||||
assign product_variant_price = variant.price
|
||||
assign product_variant_compare_at_price = variant.compare_at_price
|
||||
|
||||
if settings.product_price_strategy == 'from_price' and product.metafields.app--168074346497.min_auto_discounted_price.value
|
||||
if product.metafields.app--168074346497.min_auto_discounted_price.value < variant.price
|
||||
if settings.currency_code_enabled
|
||||
assign variant_price = product.metafields.app--168074346497.min_auto_discounted_price.value | money_with_currency
|
||||
assign variant_compare_at_price = variant.price | money_with_currency
|
||||
|
||||
if variant.compare_at_price > variant.price
|
||||
assign variant_compare_at_price = variant.compare_at_price | money_with_currency
|
||||
endif
|
||||
else
|
||||
assign variant_price = product.metafields.app--168074346497.min_auto_discounted_price.value | money
|
||||
assign variant_compare_at_price = variant.price | money
|
||||
|
||||
if variant.compare_at_price > variant.price
|
||||
assign variant_compare_at_price = variant.compare_at_price | money
|
||||
endif
|
||||
endif
|
||||
|
||||
assign product_variant_price = product.metafields.app--168074346497.min_auto_discounted_price.value
|
||||
assign product_variant_compare_at_price = variant.price
|
||||
|
||||
if variant.compare_at_price > variant.price
|
||||
assign product_variant_compare_at_price = variant.compare_at_price
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
-%}
|
||||
|
||||
{%- if product.price_varies -%}
|
||||
{%- assign is_variant_on_sale = false -%}
|
||||
|
||||
{%- if product_variant_price < product_variant_compare_at_price -%}
|
||||
{%- assign is_variant_on_sale = true -%}
|
||||
{%- endif -%}
|
||||
|
||||
{%- if settings.product_price_strategy == 'from_price' -%}
|
||||
<sale-price class="{% if is_variant_on_sale %}{{ on_sale_price_classes }}{% else %}{{ regular_price_classes }}{% endif %}">
|
||||
<span class="sr-only">{{ 'product.price.sale_price' | t }}</span>
|
||||
{{- 'product.price.from_price_html' | t: price_min: variant_price -}}
|
||||
</sale-price>
|
||||
{%- else -%}
|
||||
<sale-price class="{{ on_sale_price_classes }}">
|
||||
<span class="sr-only">{{ 'product.price.sale_price' | t }}</span>
|
||||
{{- variant_price -}}
|
||||
</sale-price>
|
||||
{%- endif -%}
|
||||
{%- else -%}
|
||||
<sale-price class="{% if product_variant_price < product_variant_compare_at_price %}{{ on_sale_price_classes }}{% else %}{{ regular_price_classes }}{% endif %}">
|
||||
<span class="sr-only">{{ 'product.price.sale_price' | t }}</span>
|
||||
{{- variant_price -}}
|
||||
</sale-price>
|
||||
{%- endif -%}
|
||||
|
||||
{%- if product_variant_price < product_variant_compare_at_price -%}
|
||||
<compare-at-price class="{{ compare_at_price_classes }}">
|
||||
<span class="sr-only">{{ 'product.price.regular_price' | t }}</span>
|
||||
{{- variant_compare_at_price -}}
|
||||
</compare-at-price>
|
||||
{%- endif -%}
|
||||
{%- else -%}
|
||||
{%- comment -%}
|
||||
--------------------------------------------------------------------------------------------------------------------
|
||||
PLACEHOLDER CASE (used on featured product section for instance)
|
||||
--------------------------------------------------------------------------------------------------------------------
|
||||
{%- endcomment -%}
|
||||
|
||||
<sale-price class="{{ regular_price_classes }}">
|
||||
<span class="sr-only">{{ 'product.price.sale_price' | t }}</span>
|
||||
|
||||
{%- if settings.currency_code_enabled -%}
|
||||
{{- 4999 | money_with_currency -}}
|
||||
{%- else -%}
|
||||
{{- 4999 | money -}}
|
||||
{%- endif -%}
|
||||
</sale-price>
|
||||
{%- endif -%}
|
||||
|
||||
{%- unless hide_unit_price -%}
|
||||
{%- assign unit_price_item = variant | default: line_item | default: product.selected_or_first_available_variant -%}
|
||||
|
||||
{%- if unit_price_item.unit_price -%}
|
||||
<unit-price class="{{ unit_price_classes }}">
|
||||
{%- assign unit_price_measurement = unit_price_item.unit_price_measurement -%}
|
||||
|
||||
{%- if unit_price_measurement.reference_value != 1 -%}
|
||||
{%- assign reference_value = unit_price_measurement.reference_value -%}
|
||||
{%- endif -%}
|
||||
|
||||
({{ unit_price_item.unit_price | money }}/{{ reference_value -}}
|
||||
{{- unit_price_measurement.reference_unit }})
|
||||
</unit-price>
|
||||
{%- endif -%}
|
||||
{%- endunless -%}
|
||||
</price-list>
|
119
snippets/product-badges.liquid
Normal file
119
snippets/product-badges.liquid
Normal file
@ -0,0 +1,119 @@
|
||||
{%- comment -%}
|
||||
----------------------------------------------------------------------------------------------------------------------
|
||||
PRODUCT BADGES COMPONENT
|
||||
----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
This component is used in product listing and product page to render the badges of a given product
|
||||
|
||||
********************************************
|
||||
Supported variables
|
||||
********************************************
|
||||
|
||||
* product: the product to render the badges
|
||||
* variant: the specific variant to show the badge from
|
||||
* vertical: if set to true, the badges are outputted vertically
|
||||
* types: the types of badge to output. Can be "custom", "sold_out" or "discount" (or a combination separated by comma). If nothing is set, all badges are outputted.
|
||||
* context: can be "product" or "card"
|
||||
{%- endcomment -%}
|
||||
|
||||
{%- liquid
|
||||
assign badge_types = types | default: 'custom, sold_out, discount' | split: ','
|
||||
assign variant = variant | default: product.selected_or_first_available_variant
|
||||
-%}
|
||||
|
||||
{%- capture badges -%}
|
||||
{%- for badge_type in badge_types -%}
|
||||
{%- assign stripped_badge_type = badge_type | strip -%}
|
||||
|
||||
{%- case stripped_badge_type -%}
|
||||
{%- when 'custom' -%}
|
||||
{%- assign custom_badges = product.metafields.custom.badges.value -%}
|
||||
|
||||
{%- for custom_badge in custom_badges -%}
|
||||
<span class="badge badge--custom badge--{{ custom_badge | handle }}">{{ custom_badge }}</span>
|
||||
{%- endfor -%}
|
||||
|
||||
{%- when 'sold_out' -%}
|
||||
{%- if settings.show_sold_out_badge and variant.available == false -%}
|
||||
<sold-out-badge class="badge badge--sold-out">
|
||||
{{- 'product.general.sold_out_badge' | t -}}
|
||||
</sold-out-badge>
|
||||
{%- endif -%}
|
||||
|
||||
{%- when 'discount' -%}
|
||||
{%- if settings.show_discount -%}
|
||||
{%- liquid
|
||||
assign show_on_sale_badge = false
|
||||
|
||||
assign variant_price = variant.price
|
||||
assign variant_compare_at_price = variant.compare_at_price
|
||||
|
||||
assign product_price = product.price
|
||||
assign product_compare_at_price = product.compare_at_price
|
||||
|
||||
if variant.metafields.app--168074346497.auto_discounted_price.value
|
||||
if variant.metafields.app--168074346497.auto_discounted_price.value < variant.price
|
||||
assign variant_price = variant.metafields.app--168074346497.auto_discounted_price.value
|
||||
assign variant_compare_at_price = variant.price
|
||||
|
||||
if variant.compare_at_price > variant.price
|
||||
assign variant_compare_at_price = variant.compare_at_price
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
if product.metafields.app--168074346497.min_auto_discounted_price.value
|
||||
if product.metafields.app--168074346497.min_auto_discounted_price.value < product.price
|
||||
assign product_price = product.metafields.app--168074346497.min_auto_discounted_price.value
|
||||
assign product_compare_at_price = product.price
|
||||
|
||||
if product.compare_at_price > product.price
|
||||
assign product_compare_at_price = product.compare_at_price
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
if context == 'product'
|
||||
if variant_compare_at_price > variant_price
|
||||
assign show_on_sale_badge = true
|
||||
endif
|
||||
elsif context == 'card'
|
||||
if product_compare_at_price > product_price
|
||||
assign show_on_sale_badge = true
|
||||
endif
|
||||
endif
|
||||
-%}
|
||||
|
||||
{%- if product_compare_at_price > product_price -%}
|
||||
{%- if settings.discount_mode == 'percentage' -%}
|
||||
{%- assign savings = variant_compare_at_price | minus: variant_price | times: 100.0 | divided_by: variant_compare_at_price | round | append: '%' -%}
|
||||
{%- else -%}
|
||||
{%- capture savings -%}{{ variant_compare_at_price | minus: variant_price | money }}{%- endcapture -%}
|
||||
{%- endif -%}
|
||||
|
||||
{%- if show_on_sale_badge -%}
|
||||
<on-sale-badge class="badge badge--on-sale">
|
||||
{%- liquid
|
||||
if context == 'product'
|
||||
echo 'product.general.discount_badge_html' | t: savings: savings
|
||||
elsif context == 'card'
|
||||
if product.compare_at_price_varies or variant_compare_at_price == blank
|
||||
echo 'product.general.on_sale_badge' | t
|
||||
else
|
||||
echo 'product.general.discount_badge_html' | t: savings: savings
|
||||
endif
|
||||
endif
|
||||
-%}
|
||||
</on-sale-badge>
|
||||
{%- endif -%}
|
||||
{%- endif -%}
|
||||
{%- endif -%}
|
||||
{%- endcase -%}
|
||||
{%- endfor -%}
|
||||
{%- endcapture -%}
|
||||
|
||||
{%- if badges != blank -%}
|
||||
<badge-list class="badge-list {% if vertical %}badge-list--vertical{% endif %}">
|
||||
{{- badges -}}
|
||||
</badge-list>
|
||||
{%- endif -%}
|
Loading…
x
Reference in New Issue
Block a user