commit 72bb66c65d49499dfe0d305bb554c5801678c1c6 Author: Axel Date: Tue Sep 16 13:13:01 2025 +0800 first commit diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..2f18a7f Binary files /dev/null and b/.DS_Store differ diff --git a/snippets/product-grid-price.liquid b/snippets/product-grid-price.liquid new file mode 100644 index 0000000..a627fc0 --- /dev/null +++ b/snippets/product-grid-price.liquid @@ -0,0 +1,76 @@ +{% comment %} + Renders Price on product grid item + + Accepts: + - product: {Object} product (required) + - current_variabt: {Object} Current variant (required) + + Usage: + {% render 'product-grid-price', product: product, current_variant: current_variant %} +{% endcomment %} + +{%- liquid + assign product_price_raw = product.price + assign product_price_min_raw = product.price_min + assign product_compare_at_price_raw = product.compare_at_price + + assign product_price_raw = product.metafields.app--168074346497.min_auto_discounted_price.value | default: product.price + + if product.metafields.app--168074346497.discount_percentage.value > 0.01 + assign deducted_percentage = 1.0 | minus: product.metafields.app--168074346497.discount_percentage.value + + assign product_price_raw = product.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil + assign product_price_min_raw = product_price_raw + endif + + if product_price_raw < product.price + assign product_compare_at_price_raw = product.price + + if product.compare_at_price > product_compare_at_price_raw + assign product_compare_at_price_raw = product.compare_at_price + endif + endif + + if settings.currency_code_enable + assign product_price_min = product_price_min_raw | money_with_currency + assign product_compare_at_price = product_compare_at_price_raw | money_with_currency + else + assign product_price_min = product_price_min_raw | money + assign product_compare_at_price = product_compare_at_price_raw | money + endif +-%} + + + {% if product.available or badge_soldout != '' %} + + {% if product.price_varies %} + {{ 'products.general.from' | t }} + {% endif %} + {%- if product_price_raw == 0 and product.price_varies == false -%} + {{ 'general.money.free' | t }} + {%- else -%} + {{ product_price_min }} + {%- endif -%} + + {% if product_compare_at_price_raw > product_price_raw %} + {{ product_compare_at_price_raw }} + {% endif %} + {% else %} + {{ 'products.product.sold_out' | t }} + {% endif %} + +{% if current_variant.unit_price %} + {% capture unit_price_separator %} + + {{ 'general.accessibility.unit_price_separator' | t }}  + {% endcapture %} + {% capture unit_price_base_unit %} + {% if current_variant.unit_price_measurement.reference_value != 1 %} + {{ current_variant.unit_price_measurement.reference_value }} + {% endif %} + {{ current_variant.unit_price_measurement.reference_unit }} + {% endcapture %} +
+ {{ 'products.product.unit_price_label' | t }} + {% if settings.currency_code_enable %}{{ current_variant.unit_price | money_with_currency }}{% else %}{{ current_variant.unit_price | money }}{% endif %}{{ unit_price_separator }}{{ unit_price_base_unit }} +{% endif %} \ No newline at end of file