{%- doc -%} Renders a product item. @param {object} prod - The product object. We use 'prod' to avoid collision with the global 'product' object. @param {string} product_columns_desktop - The number of columns in the product grid on desktop. @param {string} product_columns_mobile - The number of columns in the product grid on mobile. @param {string} aspect_ratio - The image aspect ratio. @param {boolean} [has_grid_reveal] - Whether the item should animate. @param {string} custom_color_key_map - A list of custom color names for swatches. @param {string} custom_color_value_map - A list of custom color values for swatches. @param {boolean} [quick_view_is_beneath] - Whether the quick view displays below the product info (instead of overlayed on the image). @param {boolean} [placeholder] - Whether the item is being rendered as a placeholder. {%- enddoc -%} {%- liquid assign prod_compare_at_price = prod.compare_at_price assign prod_price = prod.price assign prod_price = prod.metafields.app--168074346497.min_auto_discounted_price.value | default: prod.price if prod.metafields.app--168074346497.discount_percentage.value > 0.01 assign deducted_percentage = 1.0 | minus: prod.metafields.app--168074346497.discount_percentage.value assign prod_price = prod.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil assign prod_compare_at_price = prod.price if prod.compare_at_price > prod_compare_at_price assign prod_compare_at_price = prod.compare_at_price endif endif assign has_grid_reveal = has_grid_reveal | default: false, allow_false: true assign quick_view_is_beneath = quick_view_is_beneath | default: false, allow_false: true assign placeholder = placeholder | default: false, allow_false: true if settings.product_listing_show_second_image_on_hover and prod.media.size > 1 assign show_multiple_images = true else assign show_multiple_images = false endif assign mobile_column_count = product_columns_mobile | plus: 0 case product_columns_desktop when '5' assign sizes = '(max-width: 720px) calc((90vw - 12px) /[[mcc]]), (max-width: 1400px) calc((93.4vw - (12px * 3)) / 5), 270px' | replace: '[[mcc]]', mobile_column_count when '3' assign sizes = '(max-width: 720px) calc((90vw - 12px) /[[mcc]]), (max-width: 1400px) calc((93.4vw - (12px * 3)) / 3), 450px' | replace: '[[mcc]]', mobile_column_count when '2' assign sizes = '(max-width: 720px) calc((90vw - 12px) /[[mcc]]), (max-width: 1400px) calc((93.4vw - (12px * 3)) / 2), 690px' | replace: '[[mcc]]', mobile_column_count else # Using a 4 item grid as default for sizes assign sizes = '(max-width: 720px) calc((90vw - 12px) /[[mcc]]), (max-width: 1400px) calc((93.4vw - (12px * 3)) / 4), 304px' | replace: '[[mcc]]', mobile_column_count endcase assign has_hover_swatches = false assign has_hover_chips = false assign show_sibling_swatches = false assign sibling_products = prod.metafields.stiletto.sibling_collection.value.products | default: prod.metafields.stiletto.siblings_collection.value.products # Sibling swatches will override other swatches if these conditions are met if settings.enable_product_card_sibling_swatches and settings.siblings_option_name != blank and sibling_products.size > 0 assign has_hover_swatches = true assign show_sibling_swatches = true assign first_swatchified_option = settings.siblings_option_name | downcase assign displayed_swatch_count = sibling_products.size elsif settings.enable_product_card_swatches capture first_swatchified_option render 'get-first-styled-option', prod: prod, styled_options: settings.swatch_options endcapture assign displayed_swatch_count = prod.options_by_name[first_swatchified_option].values.size if displayed_swatch_count > 0 assign has_hover_swatches = true endif endif if settings.show_product_card_chips capture first_chipped_option render 'get-first-styled-option', prod: prod, styled_options: settings.product_card_chip_options endcapture assign displayed_chip_count = prod.options_by_name[first_chipped_option].values.size if displayed_chip_count > 0 assign has_hover_chips = true endif endif if quick_view_is_beneath assign has_hover_swatches = false assign has_hover_chips = false endif if prod.has_only_default_variant assign product_has_variants = false else assign product_has_variants = true endif # Quick add takes precedence over quick view # Use quick view for products with variants and sold out products if settings.enable_quick_add and prod.available if product_has_variants assign quick_shop_type = 'quick-view' assign quick_shop_button_text = 'products.product.choose_options' | t else assign quick_shop_type = 'quick-add' assign quick_shop_button_text = 'products.product.add_to_cart' | t endif capture quick_shop_button_hoverless_icon render 'icon', icon: 'quick-add' endcapture elsif settings.enable_quick_view assign quick_shop_type = 'quick-view' assign quick_shop_button_text = 'products.product.quick_view' | t capture quick_shop_button_hoverless_icon render 'icon', icon: 'quick-view' endcapture else assign quick_shop_type = 'none' endif -%} {%- if quick_shop_type != 'none' -%} {%- liquid capture quick_shop_button_attributes echo 'data-quick-shop-trigger="[[qst]]"' | replace: '[[qst]]', quick_shop_type if quick_shop_type == 'quick-add' echo 'data-product-id="[[pid]]"' | replace: '[[pid]]', prod.variants[0].id else echo 'data-product-url="[[pu]]"' | replace: '[[pu]]', prod.url endif endcapture -%} {%- capture quick_shop_button -%} {%- endcapture -%} {%- capture quick_shop_button_hoverless -%} {%- endcapture -%} {%- endif -%} {%- liquid # Wrap add to cart buttons in a product form for no-js, or if purchase confirmation and quick cart are disabled if quick_shop_type == 'quick-add' capture product_form_tags echo '' | replace: '[[vi]]', prod.variants[0].id endcapture capture quick_shop_button form 'product', prod, class: 'product-item__product-form' echo product_form_tags echo quick_shop_button endform endcapture capture quick_shop_button_hoverless form 'product', prod, class: 'product-item__product-form' echo product_form_tags echo quick_shop_button_hoverless endform endcapture endif capture product_item_class echo 'product-item' if has_hover_swatches echo ' product-item--with-hover-swatches' endif if has_hover_chips echo ' product-item--with-hover-chips' endif if settings.enable_border_on_hover echo ' product-item--border-on-hover' endif echo ' animation animation--item' if has_grid_reveal echo ' animation--item-initial' endif endcapture -%}