commit 280c88a763d8a82e8ff4b96bbfbb69864e8e98c6 Author: Axel Date: Sat Nov 7 15:51:49 2026 +0800 Initial commit diff --git a/snippets/product-grid-item.liquid b/snippets/product-grid-item.liquid new file mode 100644 index 0000000..696b01b --- /dev/null +++ b/snippets/product-grid-item.liquid @@ -0,0 +1,287 @@ +{% comment %} + It's best to load images as JPG instead of PNG for faster + loading, so that is our default. If you upload + PNG files and want to keep them that way, set the line + below to false. +{% endcomment %} +{%- liquid + + unless grid_item_width + assign grid_item_width = 'medium-up--one-quarter small--one-half' + endunless +-%} + +{% liquid +# start Yagi app code +assign active_discount = true + +assign empty_array = "" | split: "" +assign dormant_discounts = shop.metafields.app--168074346497.dormant_discounts.value | default: empty_array +assign target_discount_id = product.metafields.app--168074346497.applied_discount_id.value +for dormant_discount in dormant_discounts + if dormant_discount == target_discount_id + assign active_discount = false + endif +endfor + +assign product_price = product.price +assign product_compare_at_price = product.compare_at_price + +if active_discount + assign product_price = 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 = product.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil + + assign product_compare_at_price = product.price + + if product.compare_at_price > product_compare_at_price + assign product_compare_at_price = product.compare_at_price + endif + endif + + if product_price < product.price and product_compare_at_price == blank + assign product_compare_at_price = product.price + endif +endif + +# end Yagi app code +%} + +{% comment %} + Do not output the quick shop modal if we're loading related products + through another quick shop modal. Determined by checking the product.ajax template suffix. + These are loaded for product.sections templates but quickly removed + in JS before appending the related section. +{% endcomment %} +{%- liquid + assign enable_quick_shop = settings.quick_shop_enable + if no_modal + assign enable_quick_shop = false + endif + if template == 'product.ajax' + assign enable_quick_shop = false + endif + + assign on_sale = false + if product_compare_at_price > product_price + assign on_sale = true + endif + + assign sold_out = true + if product.available + assign sold_out = false + endif + + assign product_tags = product.tags | join: ',' + assign has_custom_label = false + if product.metafields.theme.label and product.metafields.theme.label != blank + assign has_custom_label = true + assign custom_label = product.metafields.theme.label.value + elsif product_tags contains '_label_' + for tag in product.tags + if tag contains '_label_' + assign tag_starts_with = tag | slice: 0 + if tag_starts_with == '_' + assign has_custom_label = true + assign custom_label = tag | replace: '_label_', '' + endif + endif + endfor + endif +-%} + +
+
+ {%- if has_custom_label -%} +
+ {{ custom_label }} +
+ {%- else -%} + {%- if sold_out -%} +
+ {{ 'products.product.sold_out' | t }} +
+ {%- endif -%} + {%- if on_sale and sold_out == false -%} +
+ {%- if settings.product_save_amount -%} + {%- if settings.product_save_type == 'dollar' -%} + {%- capture saved_amount -%}{{ product_compare_at_price | minus: product_price | money }}{%- endcapture -%} + {%- else -%} + {%- capture saved_amount -%}{{ product_compare_at_price | minus: product_price | times: 100.0 | divided_by: product_compare_at_price | round }}%{%- endcapture -%} + {%- endif -%} + {{ 'products.general.save_html' | t: saved_amount: saved_amount }} + {%- else -%} + {{ 'products.general.sale' | t }} + {%- endif -%} +
+ {%- endif -%} + {%- endif -%} + + {%- liquid + assign fixed_aspect_ratio = false + unless settings.product_grid_image_size == 'natural' + assign fixed_aspect_ratio = true + endunless + + assign preview_image = product.featured_media.preview_image + + assign image_limit = 1 + assign image_count = 0 + if settings.product_hover_image + assign image_limit = 10 + endif + + assign slider_image_padding = '100%' + + if image_style == 'circle' + assign fixed_aspect_ratio = true + assign imageRatio = 'square' + endif + -%} + + +
+ {%- for media in product.media limit: image_limit -%} + {%- assign image_count = image_count | plus: 1 -%} +
+
+ {% capture img_class %}{%- if fixed_aspect_ratio -%}grid-product__image{% endif %} image-style--{{ image_style }}{% endcapture %} + {%- if forloop.first -%} + {%- if fixed_aspect_ratio -%} +
+ {%- render 'image-element', + img: preview_image, + classes: img_class, + sizes: sizes, + sizeVariable: sizeVariable, + fallback: fallback, + -%} +
+ {%- else -%} + {%- assign slider_image_padding = 100 | divided_by: preview_image.aspect_ratio | append: '%' -%} +
+ {%- render 'image-element', + img: preview_image, + classes: img_class, + sizes: sizes, + sizeVariable: sizeVariable, + fallback: fallback, + widths: '750, 900, 1080', + format: format, + -%} +
+ {%- endif -%} + {%- else -%} +
+ {%- render 'image-element', + img: media.preview_image, + classes: img_class, + sizes: sizes, + sizeVariable: sizeVariable, + fallback: fallback, + -%} +
+ {%- endif -%} +
+
+ {%- endfor -%} + {%- if product.media == blank -%} +
+ {%- capture placeholder -%}product-{% cycle 1, 2, 3, 4, 5, 6 %}{%- endcapture -%} +
{{ placeholder | placeholder_svg_tag: 'placeholder-svg' }}
+
+ {%- endif -%} +
+ + {%- if image_count > 1 -%} + {%- assign loader_duration = 1350 | times: image_count -%} + + {%- endif -%} + +
+
{{ product.title }}
+ {%- if settings.vendor_enable -%} +
{{ product.vendor }}
+ {%- endif -%} +
+ {%- if on_sale -%} + {{ 'products.general.regular_price' | t }} + {{ product_compare_at_price | money }} + {{ 'products.general.sale_price' | t }} + {%- endif -%} + {%- if product.price_varies -%} + {%- assign price = product_price | money -%} + + {{ 'products.general.from_text_html' | t: price: price }} + + {%- else -%} + + {{ product_price | money }} + + {%- endif -%} +
+ + {%- assign product_variant = product.selected_or_first_available_variant -%} + {%- if product_variant.unit_price_measurement -%} +
+ {%- capture unit_price_base_unit -%} + {%- if product_variant.unit_price_measurement -%} + {%- if product_variant.unit_price_measurement.reference_value != 1 -%} + {{ product_variant.unit_price_measurement.reference_value }} + {%- endif -%} + {{ product_variant.unit_price_measurement.reference_unit }} + {%- endif -%} + {%- endcapture -%} + + {{ product_variant.unit_price | money }}/{{ unit_price_base_unit }} +
+ {%- endif -%} + + {%- if settings.enable_swatches and type == 'horizontal' -%} + {%- render 'product-grid-item-swatches', product: product -%} + {%- endif -%} +
+ + {%- if settings.enable_swatches and type == blank -%} + {%- render 'product-grid-item-swatches', product: product -%} + {%- endif -%} +
+
+ + {%- if enable_quick_shop and type == blank -%} + {%- render 'quick-shop-modal', product: product -%} + {%- endif -%} +
diff --git a/snippets/search-results.liquid b/snippets/search-results.liquid new file mode 100644 index 0000000..e742b88 --- /dev/null +++ b/snippets/search-results.liquid @@ -0,0 +1,232 @@ +{% liquid + assign resources = predictive_search.resources + assign columnCount = resources.queries.size | plus: resources.pages.size | plus: resources.articles.size | plus: resources.collections.size + assign totalCount = resources.queries.size | plus: resources.pages.size | plus: resources.articles.size | plus: resources.collections.size | plus: resources.products.size +%} + + +{%- if predictive_search.performed -%} +
+ {% if totalCount > 0 %} +
+ {%- if predictive_search.resources.queries.size > 0 -%} +
+

+ {{ 'general.search.suggestions' | t }} +

+ +
+ {%- endif -%} + {%- if predictive_search.resources.pages.size > 0 -%} +
+

+ {{ 'general.search.pages' | t }} +

+ +
+ {%- endif -%} + {%- if predictive_search.resources.articles.size > 0 -%} +
+

+ {{ 'general.search.articles' | t }} +

+ +
+ {%- endif -%} + {%- if predictive_search.resources.collections.size > 0 -%} +
+

+ {{ 'general.search.collections' | t }} +

+ +
+ {%- endif -%} +
+ +
+ {%- if predictive_search.resources.products.size > 0 -%} +
+

+ {{ 'general.search.products' | t }} +

+ +
+ {%- endif -%} + {%- if predictive_search.resources.pages.size > 0 -%} +
+

+ {{ 'general.search.pages' | t }} +

+ +
+ {%- endif -%} + {%- if predictive_search.resources.articles.size > 0 -%} +
+

+ {{ 'general.search.articles' | t }} +

+ +
+ {%- endif -%} + {%- if predictive_search.resources.collections.size > 0 -%} +
+

+ {{ 'general.search.collections' | t }} +

+ +
+ {%- endif -%} +
+ {% else %} + + {% endif %} +
+ {% if totalCount > 0 %} + + {% endif %} +{%- endif -%}