{% comment %} Inner content for a grid item {% endcomment %} {%- liquid assign on_sale = false assign product_price = product.price assign product_compare_at_price = product.compare_at_price comment start Yagi app code endcomment assign public_or_tags_matched = true if product.metafields.app--168074346497.segment_tags.value.size > 0 assign public_or_tags_matched = false endif for etag in product.metafields.app--168074346497.segment_tags.value if customer.tags contains etag assign public_or_tags_matched = true break endif endfor if public_or_tags_matched assign product_price = product.metafields.app--168074346497.min_auto_discounted_price.value | default: product.price assign product_compare_at_price = product.compare_at_price if shop.metafields.app--168074346497.discount_percentage.value > 0.005 assign discount_percentage = shop.metafields.app--168074346497.discount_percentage.value | times: 1.0 assign deducted_percentage = 1.0 | minus: discount_percentage assign product_price = product.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil endif if product_price < product.price and product_compare_at_price == 0 or product_compare_at_price == blank assign product_compare_at_price = product.price endif endif comment end Yagi app code endcomment 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 sellout_badge = false if sold_out and settings.badge_sellout assign sellout_badge = true endif assign sale_badge = false if on_sale and settings.badge_sale assign sale_badge = true assign sale_badge_content = 'products.product.sale' | t if settings.badge_sale_discount if settings.badge_sale_type == 'dollar' if settings.currency_code_enable assign sale_badge_content = product_compare_at_price | minus: product_price | money_with_currency else assign sale_badge_content = product_compare_at_price | minus: product_price | money_without_trailing_zeros endif else assign difference = product_compare_at_price | minus: product_price assign percent_off = difference | times: 1.0 | divided_by: product_compare_at_price | times: 100 assign sale_badge_content = percent_off | floor | append: '%' endif assign save_word = 'products.product.save' | t | append: ' ' assign sale_badge_content = sale_badge_content | prepend: save_word endif endif assign custom_badge = false if settings.badge_custom if product.metafields.theme.badge != blank and product.metafields.theme.badge.type == 'single_line_text_field' assign custom_badge = true assign custom_badge_content = product.metafields.theme.badge.value endif for tag in product.tags if tag contains "_badge_" assign tag_content = tag | remove: '_badge_' | replace: '_', ' ' if tag_content != '' assign custom_badge = true assign custom_badge_content = tag_content endif break endif endfor endif if badge_string and badge_string != '' assign custom_badge = true assign custom_badge_content = badge_string endif assign tagged = false if sellout_badge or sale_badge or custom_badge assign tagged = true endif comment Disqualify options that have more than 15 variants or are a combined length of > 90 characters endcomment if inline_variant_buttons.values.size > 15 assign inline_variant_buttons = nil endif if inline_variant_buttons assign all_characters = inline_variant_buttons.values | join: "" if all_characters.size >= 90 assign inline_variant_buttons = nil endif endif # Sellign plans can be added along with inline or instand buttons if # the product has exactly 1 selling plan with subscriptions required assign simple_selling_plan = nil if inline_variant_buttons or instant_add_button if product.requires_selling_plan and product.selling_plan_groups.size == 1 and product.selling_plan_groups[0].selling_plans.size == 1 # one variant, one required subscription, no choices to make assign simple_selling_plan = product.selected_or_first_available_selling_plan_allocation.selling_plan elsif product.selling_plan_groups.size > 0 # Abort instant and inline add buttons, subs choices must be made assign inline_variant_buttons = nil assign instant_add_button = nil endif endif # Catch case where first sibling has inline variants and subsequent do not if product.has_only_default_variant and inline_variant_buttons assign inline_variant_buttons = nil assign instant_add_button = true endif # Allow configuration of image sizing for different numbers of grid columns # Note: desktop/tablet are set to a default of 3 just in case the grid sizes are not set to prevent accidental gigantic full-width images from being loaded assign columns_desktop = columns_desktop | default: section.settings.grid_large | default: 3 assign columns_tablet = columns_tablet | default: section.settings.grid_medium | default: columns_desktop | default: 3 assign columns_mobile = columns_mobile | default: section.settings.grid_mobile | default: 1 assign section_width = section_width | default: section.settings.width | default: null -%} {%- capture badge -%} {%- if tagged %} {%- if custom_badge -%}
{{ custom_badge_content }}
{%- elsif sellout_badge -%}
{{ 'products.product.sold_out' | t }}
{%- elsif sale_badge -%}
{{ sale_badge_content }}
{%- endif -%} {%- endif -%} {%- endcapture -%} {%- liquid assign first_image = product.media[0].preview_image assign container_wh_ratio = settings.product_card_wh_ratio assign image_cover = true case settings.product_grid_image when 'crop' assign image_wh_ratio = container_wh_ratio when 'uneven' assign container_wh_ratio = first_image.aspect_ratio | default: settings.product_card_wh_ratio when 'scale' assign image_cover = false assign image_wh_ratio = first_image.aspect_ratio | default: settings.product_card_wh_ratio endcase # Behavior is inferred based on setting and passed into JS assign image_hover = 'disabled' assign images_limit = settings.cycle_images_limit case images_limit when 1 assign image_hover = 'disabled' when 2 assign image_hover = 'second_immediately' else assign image_hover = 'cycle_images' endcase -%} {%- capture sizes -%} {%- render 'image-grid-sizes', columns_desktop: columns_desktop, columns_tablet: columns_tablet, columns_mobile: columns_mobile, section_width: section_width %} {%- endcapture -%}