{%- 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 -%} {%- if show_compare -%}
{%- endif -%}
{%- if product.featured_media -%} {%- capture attributes %}data-media-id="{{ product.featured_media.id }}"{% endcapture -%} {% render 'image', image: product.featured_media.preview_image, widths: '320, 460, 600, 700, 800, 900, 1200', src_width: 460, src_placeholder: true, sizes: sizes, class: class, attributes: attributes, disable_focal_point: true, quality: image_quality %} {%- if settings.card_colors_style == 'swatches' or settings.card_colors_style == 'variant-images' -%} {%- assign variant_media = product.variants | map: 'featured_media' -%} {%- for media in variant_media -%} {%- unless media == product.featured_media -%} {%- capture attributes %}data-media-id="{{ media.id }}" hidden{% endcapture -%} {% render 'image', image: media, widths: '320, 460, 600, 700, 800, 900, 1200', src_width: 460, sizes: sizes, class: class, attributes: attributes, disable_focal_point: true, quality: image_quality %} {%- endunless -%} {%- endfor -%} {%- endif -%} {%- if show_hover_image -%} {%- assign class = class | replace: 'card__main-image', 'card__hover-image' -%} {% render 'image', image: hover_image, widths: '320, 460, 600, 700, 800, 900, 1200', src_width: 460, src_placeholder: true, sizes: sizes, class: class, disable_focal_point: true, quality: image_quality %} {%- endif -%} {%- else -%} {{ 'image' | placeholder_svg_tag: 'media__placeholder img-fit' }} {%- endif -%} {%- liquid if settings.product_label_card_position != "none" render 'product-label', product: product, position: settings.product_label_card_position, is_product_card: true, limit: 2 endif -%}
{%- if settings.card_show_vendor -%}

{{- product.vendor -}}

{%- endif -%}

{{- product.title | escape -}}

{%- if settings.card_show_subtitle and product.metafields.descriptors.subtitle != blank -%}

{{ product.metafields.descriptors.subtitle }}

{%- endif -%} {%- if product.metafields.reviews.rating.value != blank and settings.card_show_rating -%}
{% render 'rating', rating_value: product.metafields.reviews.rating.value, rating_count: product.metafields.reviews.rating_count %}
{%- endif -%} {%- if settings.card_price_bottom == false -%} {%- render 'price', product: product, class: "price--top" -%} {%- endif -%} {%- if settings.card_colors_style != 'none' -%} {%- for option in product.options_with_values -%} {%- if settings.swatch_option_name contains option.name -%} {%- if settings.card_colors_style == 'swatches' or settings.card_colors_style == 'variant-images' -%} {%- liquid assign swatch_size = settings.card_swatch_size | times: 2 if settings.image_quality == 0.75 assign swatch_size = settings.card_swatch_size endif -%}
{%- capture option_id %}{{ section.id }}-{{ product.id }}-{{ option.name | handle }}{% endcapture -%} {%- assign variant_key = 'option' | append: option.position -%} {%- for value in option.values limit: swatch_limit -%} {%- liquid assign variant_value = product.variants | where: variant_key, value | first if option.selected_value == value assign selected_color = value endif -%} {%- endfor -%} {%- if option.values.size > swatch_limit -%} +{{ option.values.size | minus: swatch_limit }} {%- endif -%}
{%- else -%} {%- if option.values.size == 1 -%}

{{ 'sections.collection.colors_single' | t }}

{%- else -%}

{{ 'sections.collection.colors_count' | t: count: option.values.size }}

{%- endif -%} {%- endif -%} {%- endif -%} {%- endfor -%} {%- endif -%} {%- if settings.card_show_inventory and current_variant.inventory_management != blank -%} {%- liquid assign total = 0 assign inventory_policy = '' for variant in product.variants if variant.inventory_quantity > 0 assign total = total | plus: variant.inventory_quantity endif if variant.inventory_policy == 'continue' assign inventory_policy = 'continue' endif endfor if total <= 0 if inventory_policy == 'continue' if settings.hide_no_stock_backordered assign inventory_level = 'hide' else assign inventory_level = 'backordered' endif elsif product.available assign inventory_level = 'in_stock' else assign inventory_level = 'hide' endif elsif total <= settings.inventory_threshold_very_low assign inventory_level = 'very_low' elsif total <= settings.inventory_threshold_low assign inventory_level = 'low' else assign inventory_level = 'normal' endif if inventory_level == "normal" or inventory_level == "in_stock" if settings.inventory_show_notice == "low" assign inventory_level = 'hide' endif endif -%} {%- unless inventory_level == 'hide' -%}
{%- if inventory_level == 'very_low' -%} {{ 'products.inventory.very_low_stock' | t }} {%- if settings.inventory_show_count != "never" and total > 0 -%} ({{ 'products.inventory.available_count' | t: count: total }}) {%- endif -%} {%- elsif inventory_level == 'low' -%} {{ 'products.inventory.low_stock' | t }} {%- if settings.inventory_show_count != "never" and total > 0 -%} ({{ 'products.inventory.available_count' | t: count: total }}) {%- endif -%} {%- elsif inventory_level == 'backordered' -%} {{ 'products.inventory.backordered' | t }} {%- else -%} {{ 'products.inventory.in_stock' | t }} {%- if settings.inventory_show_count == "always" and total > 0 -%} ({{ 'products.inventory.available_count' | t: count: total }}) {%- endif -%} {%- endif -%}
{%- endunless -%} {%- endif -%} {%- if settings.card_price_bottom -%}
{%- render 'price', product: product, class: "price--bottom" -%}
{%- endif -%}
{%- if settings.enable_quick_add and disable_quickbuy != true -%}
{%- assign product_form_id = 'quick-add-' | append: section_id | append: product.id -%} {%- if product.has_only_default_variant and product_not_for_sale == false -%} {%- form 'product', product, class: 'js-product-form', id: product_form_id, novalidate: 'novalidate' -%} {%- capture button_text -%} {%- if product.template_suffix contains 'preorder' -%} {{- 'products.product.preorder' | t -}} {%- else -%} {{- 'products.product.add_to_cart' | t -}} {%- endif -%} {%- endcapture -%} {{- 'products.product.view_details' | t -}} {%- endform -%} {%- else -%}
{{- 'products.product.view_details' | t -}}
{%- endif -%}
{%- endif -%}
{%- else -%}
{%- capture placeholder_name -%}product-{{ 'now' | date: '%N' | modulo: 6 | plus: 1 }}{%- endcapture -%} {{ placeholder_name | placeholder_svg_tag: 'media__placeholder img-fit' }}

{{ 'onboarding.product.title' | t }}

{%- render 'price-as-money', price: 1234 -%}
{%- endif -%}