{%- comment -%}
Renders list of products in grid layout
Accepts:
- product: {Object} product (required)
- carousel: {Boolean} Show the product images in carousel. Default: false
- image_animation: {String} Type of the image animation
- text_animation: {String} Type of the text animation
- animation_delay: {Number} Factor based on grid items per row
- animation_anchor: {String} Hook for the AOS animation
- image_aspect_ratio_setting: {String} image aspect ratio setting from section settings
Usage:
{% render 'product-grid-item', product: product, carousel: carousel, animation: animation, animation_delay: animation_delay, image_aspect_ratio_setting: image_aspect_ratio_setting %}
{%- endcomment -%}
{%- liquid
assign columns = settings.products_per_row_on_desktop | plus: 0
assign columns_mobile = columns_mobile | default: settings.products_per_row_on_mobile | plus: 0
assign counter_even = mobile_counter | modulo: 2
assign counter_second_tablet = tablet_counter | plus: 1 | modulo: 3
assign counter_third_tablet = tablet_counter | modulo: 3
assign grid_item_class = ''
if counter_even == 0
assign grid_item_class = grid_item_class | append: ' grid-item--even'
endif
if columns > 2
if counter_second_tablet == 0
assign grid_item_class = grid_item_class | append: ' grid-item--second-tablet'
elsif counter_third_tablet == 0
assign grid_item_class = grid_item_class | append: ' grid-item--third-tablet'
endif
endif
case columns
when 1
assign size_desktop = 'one-whole'
when 2
assign size_desktop = 'one-half'
when 3
assign size_desktop = 'one-third'
when 4
assign size_desktop = 'one-quarter'
endcase
case columns_mobile
when 1
assign size_mobile = 'mobile--one-whole'
when 2
assign size_mobile = 'mobile--one-half'
endcase
if carousel
assign size_mobile = 'mobile--one-whole'
assign tabindex_hidden = true
endif
assign on_sale = false
assign sold_out = false
assign custom_badge_metafield = false
assign single_variant = false
if product.variants.size == 1 and product.selling_plan_groups.size == 0
assign single_variant = true
endif
if product.metafields.theme.badge != blank and product.metafields.theme.badge.type == 'single_line_text_field'
assign custom_badge_metafield = true
assign custom_badge_metafield_text = product.metafields.theme.badge.value
endif
# start Yagi app code
assign active_discount = true
assign product_price = product.price
assign product_compare_at_price = product.compare_at_price
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
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
if product_compare_at_price > product_price
assign on_sale = true
endif
unless product.available
assign sold_out = true
endunless
assign quick_buy = settings.quick_buy
assign current_variant = product.selected_or_first_available_variant
assign featured_media = product.featured_media
assign product_grid_hover = settings.product_grid_hover
assign product_grid_hover_animation = settings.product_grid_hover_animation
if product.media.size <= 1 or product_grid_hover == 'none'
assign product_grid_hover = false
endif
capture item_unique
echo 'product-item--' | append: section.id | append: '-' | append: product.id
endcapture
assign animations_enabled = settings.animations_enabled
assign image_animation = image_animation | default: 'zoom-out'
assign animation_anchor_default = item_unique | prepend: '#'
assign animation_anchor = animation_anchor | default: animation_anchor_default
assign text_animation = text_animation | default: 'fade'
assign currency_code_enable = settings.currency_code_enable
assign alignment_inline = false
assign product_alignment_class = ' product-grid-item__info--' | append: settings.content_alignment
if settings.content_alignment == 'inline'
assign alignment_inline = true
endif
assign has_colors = false
if settings.enable_color_swatches_collection and product.has_only_default_variant == false
capture swatch_translation
echo 'general.swatches.color' | t
endcapture
assign swatch_labels = swatch_translation | remove: ' ' | replace: ', ', ',' | replace: ' ,', ',' | split: ','
for label in swatch_labels
assign sanitized_label = label | strip
if product.options_by_name[sanitized_label].values.size > 0
assign color_label = label
assign has_colors = true
break
endif
endfor
endif
capture cart_icon
case settings.cart_icon
when 'bag'
render 'icon-shopping-bag'
when 'shopping_cart'
render 'icon-shopping-cart'
endcase
endcapture
-%}
{%- capture product_title -%}
1 %} tabindex="-1"{% endif %} data-grid-link>
{{- product.title | strip_html | escape -}}
{{ product.metafields.theme.cutline.value }}
{%- endif -%} {%- unless alignment_inline -%} {%- comment -%} Price {%- endcomment -%} {{ product_info_price }} {%- endunless -%} {%- if settings.show_rating and product.metafields.reviews != empty -%} 1 %} tabindex="-1"{% endif %} data-grid-link> {%- render 'rating', reviews: product.metafields.reviews, show_rating_count: settings.show_rating_count, tabindex_hidden: tabindex_hidden -%} {%- endif -%}