{%- comment -%}theme-check-disable LiquidTag{%- endcomment -%}
{%- comment -%}
Parameters:
- product {Object} - Product object.
- collection {Object} - Collection object (optional).
- image_ratio {Number} - Aspect ratio for the image(s).
- disable_quickbuy {Boolean} - Force disables quickbuy (even if enabled in settings)
Usage:
{% render 'product-card', product: product %}
{%- endcomment -%}
{%- liquid
if collection and settings.card_url_within_coll and product.collections contains collection
assign product_url = product.url | within: collection
else
assign product_url = product.url
endif
if product_url contains "?"
assign product_url = product_url | split: "?" | first
endif
assign current_variant = product.selected_or_first_available_variant
assign product_images = product.media | where: 'media_type', 'image'
if settings.card_show_hover_image and product_images.size > 1
assign show_hover_image = true
if product_images.size >= product.featured_media.position
assign hover_image = product_images[product.featured_media.position]
else
assign hover_image = product_images[0]
endif
else
assign show_hover_image = false
endif
if image_ratio == nil
if settings.prod_card_image_ratio == 'shortest' or settings.prod_card_image_ratio == 'tallest'
assign image_ratio = 1
else
assign image_ratio = settings.prod_card_image_ratio
endif
elsif image_ratio == 0 or image_ratio == 99
assign image_ratio = 1
endif
if section.settings.card_size == 'small'
assign swatch_limit = 4
else
assign swatch_limit = 7
endif
if product.featured_media
if section.settings.card_size == 'small'
capture sizes
render 'sizes-attribute', grid: true, min: 2, sm: 3, md: 4, xl: 5
endcapture
elsif section.settings.card_size == 'large'
capture sizes
render 'sizes-attribute', grid: true, min: 1, sm: 2, xl: 3
endcapture
else
capture sizes
render 'sizes-attribute', grid: true, min: 1, sm: 3, md: 4
endcapture
endif
if settings.prod_card_image_fit == 'contain'
assign class = 'img-fit img-fit--contain card__main-image'
else
assign class = 'img-fit card__main-image ' | append: settings.prod_card_image_align
endif
if product.featured_media.preview_image == product_images.last
assign show_hover_image = false
endif
endif
assign image_quality = 1
if product.featured_media.preview_image.aspect_ratio > 1 and settings.prod_card_image_ratio != "1.77" and settings.prod_card_image_fit == "cover"
assign image_quality = 2
endif
assign product_not_for_sale = false
if product.template_suffix contains 'coming-soon' or product.template_suffix contains 'countdown'
assign product_not_for_sale = true
endif
assign card_class = ""
if product.template_suffix contains 'preorder'
assign card_class = " card--product-preorder"
elsif product.template_suffix contains 'coming-soon'
assign card_class = " card--product-coming-soon"
elsif product.template_suffix contains 'countdown'
assign card_class = " card--product-countdown"
endif
-%}
{%- if product and product != empty -%}
{{- product.vendor -}}
{{- product.title | escape -}}
{{ product.metafields.descriptors.subtitle }}
{{ 'sections.collection.colors_single' | t }} {{ 'sections.collection.colors_count' | t: count: option.values.size }}
{{ 'onboarding.product.title' | t }}