commit a8a405ea90918a9f27d94267019079c5311a101e Author: Axel Date: Wed Mar 26 17:35:46 2025 +0800 first commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..5f5108f --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# Icon theme - Yagi Automatic Discount Helper app + +This repository contains installation guide for Icon theme (developed by Dolce). + +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. \ No newline at end of file diff --git a/snippets/product-price-listing.liquid b/snippets/product-price-listing.liquid new file mode 100644 index 0000000..c9e4332 --- /dev/null +++ b/snippets/product-price-listing.liquid @@ -0,0 +1,114 @@ +{% comment %} + Renders a list of product's price (regular, sale, unit) + Accompanies product listings (collection page, search result) and not updated dynamically + Accepts: + - variant: {Object} Variant Liquid object (optional) + - product: {Object} Product Liquid object (optional) + - show_vendor: {Boolean} Show the product's vendor depending on the section setting (optional) + + Usage: + {% include 'product-price-listing', product: product %} +{% endcomment %} +{%- liquid + if product.title + assign compare_at_price = product.compare_at_price + assign price = product.price + assign available = product.available + assign variant = product.variants.first + else + assign compare_at_price = 1999 + assign price = 1999 + assign available = true + endif + + if product.title and product.metafields.app--168074346497.min_auto_discounted_price.value and product.metafields.app--168074346497.discount_percentage.value > 0.01 + assign deducted_percentage = 1.0 | minus: product.metafields.app--168074346497.discount_percentage.value + assign price = product.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil + + assign compare_at_price = product.price + if product.compare_at_price > compare_at_price + assign compare_at_price = product.compare_at_price + endif + endif + + assign money_price = price | money +-%} + +
+ + {%- comment -%} + 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 + - div.price__unit: Displayed when the first variant has a unit price + - div.price__availability: Displayed when the product is sold out + {%- endcomment -%} +
+
+ {{ 'products.general.regular_price' | t }} +
+
+ + {%- if product.price_varies -%} + {{ 'products.product.from_lowest_price_html' | t: lowest_price: money_price }} + {%- else -%} + {{ money_price }} + {%- endif -%} + +
+
+
+
+ {{ 'products.general.sale_price' | t }} +
+
+ + {%- if product.price_varies -%} + {{ 'products.product.from_lowest_price_html' | t: lowest_price: money_price }} + {%- else -%} + {{ money_price }} + {%- endif -%} + +
+
+ {{ 'products.general.regular_price' | t }} +
+
+ + {{ compare_at_price | money }} + +
+
+
+ + {{ 'products.product.sold_out' | t }} + +
+
+
+ {{ 'products.product.unit_price_label' | t }} +
+
+ {%- capture unit_price_separator -%} + {{ 'general.accessibility.unit_price_separator' | t }}  + {%- endcapture -%} + {%- capture unit_price_base_unit -%} + + {%- if variant.unit_price_measurement -%} + {%- if variant.unit_price_measurement.reference_value != 1 -%} + {{- variant.unit_price_measurement.reference_value -}} + {%- endif -%} + {{ variant.unit_price_measurement.reference_unit }} + {%- endif -%} + + {%- endcapture -%} + + {{ variant.unit_price | money }}{{- unit_price_separator -}}{{- unit_price_base_unit -}} +
+
+