Update snippets/product-grid-item.liquid
This commit is contained in:
1 parent
6f73cf95e0
commit
60677c59f6
1 file changed
+72
-50
@@ -15,7 +15,7 @@
|
|||||||
{%- endcomment -%}
|
{%- endcomment -%}
|
||||||
|
|
||||||
{%- liquid
|
{%- liquid
|
||||||
assign columns = columns | default: settings.products_per_row_on_desktop | plus: 0
|
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 columns_mobile = columns_mobile | default: settings.products_per_row_on_mobile | plus: 0
|
||||||
|
|
||||||
assign counter_even = mobile_counter | modulo: 2
|
assign counter_even = mobile_counter | modulo: 2
|
||||||
@@ -71,23 +71,46 @@
|
|||||||
assign custom_badge_metafield_text = product.metafields.theme.badge.value
|
assign custom_badge_metafield_text = product.metafields.theme.badge.value
|
||||||
endif
|
endif
|
||||||
|
|
||||||
assign product_price = product.metafields.app--168074346497.min_auto_discounted_price.value | default: product.price
|
# start Yagi app code
|
||||||
|
assign active_discount = true
|
||||||
|
|
||||||
|
assign product_price = product.price
|
||||||
assign product_compare_at_price = product.compare_at_price
|
assign product_compare_at_price = product.compare_at_price
|
||||||
|
|
||||||
if product_price < product.price and product_compare_at_price == 0 or product_compare_at_price == blank
|
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
|
assign product_compare_at_price = product.price
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
# end Yagi app code
|
||||||
|
|
||||||
if product_compare_at_price > product_price
|
if product_compare_at_price > product_price
|
||||||
assign on_sale = true
|
assign on_sale = true
|
||||||
endif
|
endif
|
||||||
|
|
||||||
assign money_product_price = product_price | money
|
|
||||||
|
|
||||||
if settings.currency_code_enable
|
|
||||||
assign money_product_price = product_price | money_with_currency
|
|
||||||
endif
|
|
||||||
|
|
||||||
unless product.available
|
unless product.available
|
||||||
assign sold_out = true
|
assign sold_out = true
|
||||||
endunless
|
endunless
|
||||||
@@ -150,34 +173,33 @@
|
|||||||
|
|
||||||
{%- capture product_title -%}
|
{%- capture product_title -%}
|
||||||
<a class="product-grid-item__title" href="{{ product.url | within: collection }}" aria-label="{{ product.title | strip_html | escape }}"{% if index > 1 %} tabindex="-1"{% endif %} data-grid-link>
|
<a class="product-grid-item__title" href="{{ product.url | within: collection }}" aria-label="{{ product.title | strip_html | escape }}"{% if index > 1 %} tabindex="-1"{% endif %} data-grid-link>
|
||||||
{{- product.title | strip_html | escape -}}
|
<h3 class="p m-0">{{- product.title | strip_html | escape -}}</h3>
|
||||||
</a>
|
</a>
|
||||||
<!-- Start of Judge.me code -->
|
|
||||||
<div style='{{ jm_style }}' class='jdgm-widget jdgm-preview-badge' data-id='{{ product.id }}' data-auto-install='false'>
|
<div class="gw-rv-listing-average-placeholder" style="display: block" data-product_id={{ product.id }}></div>
|
||||||
{{ product.metafields.judgeme.badge }}
|
|
||||||
</div>
|
|
||||||
<!-- End of Judge.me code -->
|
|
||||||
{%- endcapture -%}
|
{%- endcapture -%}
|
||||||
|
|
||||||
{%- capture info_separator -%}
|
{%- capture info_separator -%}
|
||||||
<span class="product-grid-item__info-separator"></span>
|
<span class="product-grid-item__info-separator"></span>
|
||||||
{%- endcapture -%}
|
{%- endcapture -%}
|
||||||
|
|
||||||
|
<!-- start automatic discounted price label code -->
|
||||||
|
<!--{% render 'auto-discounted-price', product: product %}-->
|
||||||
|
<!-- end automatic discounted price label code -->
|
||||||
|
|
||||||
{%- capture product_info_price -%}
|
{%- capture product_info_price -%}
|
||||||
<a class="product-grid-item__price price" href="{{ product.url | within: collection }}"{% if index > 1 %} tabindex="-1"{% endif %} data-grid-link>
|
<a class="product-grid-item__price price" href="{{ product.url | within: collection }}"{% if index > 1 %} tabindex="-1"{% endif %} data-grid-link>
|
||||||
{%- liquid
|
{%- liquid
|
||||||
# product.price is equivalent to product.price_min
|
if product_price == 0 and product.price_varies == false
|
||||||
assign raw_product_price = product.metafields.app--168074346497.min_auto_discounted_price | default: product.price
|
|
||||||
|
|
||||||
if product.price == 0 and product.price_varies == false
|
|
||||||
assign product_price = 'products.product.free' | t
|
assign product_price = 'products.product.free' | t
|
||||||
assign product_price_min = 'products.product.free' | t
|
assign product_price_min = 'products.product.free' | t
|
||||||
elsif currency_code_enable
|
elsif currency_code_enable
|
||||||
assign product_price = raw_product_price | money_with_currency
|
assign product_price = product_price | money_with_currency
|
||||||
assign product_price_min = raw_product_price | money_with_currency
|
assign product_price_min = product_price | money_with_currency
|
||||||
else
|
else
|
||||||
assign product_price = raw_product_price | money
|
assign product_price = product_price | money
|
||||||
assign product_price_min = raw_product_price | money
|
assign product_price_min = product_price | money
|
||||||
endif
|
endif
|
||||||
-%}
|
-%}
|
||||||
|
|
||||||
@@ -185,7 +207,7 @@
|
|||||||
{{- 'products.general.from_text_html' | t: price: product_price_min -}}
|
{{- 'products.general.from_text_html' | t: price: product_price_min -}}
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
{%- if on_sale -%}
|
{%- if on_sale -%}
|
||||||
<span class="product-grid-item__price__new">{{ money_product_price }}</span>
|
<span class="product-grid-item__price__new">{{ product_price }}</span>
|
||||||
|
|
||||||
<s>
|
<s>
|
||||||
{%- if currency_code_enable -%}
|
{%- if currency_code_enable -%}
|
||||||
@@ -219,9 +241,16 @@
|
|||||||
<div class="product-grid-item {% if carousel %}carousel__item{% else %}grid__item{% endif %} {{ size_desktop }} {{ size_mobile }}{% if tag %} has-tag{% endif %}{% if sold_out %} soldout{% endif %}{{ grid_item_class }}"
|
<div class="product-grid-item {% if carousel %}carousel__item{% else %}grid__item{% endif %} {{ size_desktop }} {{ size_mobile }}{% if tag %} has-tag{% endif %}{% if sold_out %} soldout{% endif %}{{ grid_item_class }}"
|
||||||
{% if carousel %} data-slide{% endif %}
|
{% if carousel %} data-slide{% endif %}
|
||||||
data-product-block
|
data-product-block
|
||||||
|
data-variant-options="{{ product.variants | where: 'available', true | map: 'options' | json | escape }}"
|
||||||
|
data-option-names="{{ product.options | json | escape }}"
|
||||||
id="{{ item_unique }}">
|
id="{{ item_unique }}">
|
||||||
{%- comment -%} Image {%- endcomment -%}
|
{%- comment -%} Image {%- endcomment -%}
|
||||||
<div class="product-grid-item__image" data-product-media-container>
|
<div class="product-grid-item__image" data-product-media-container>
|
||||||
|
|
||||||
|
<div style="display: block;" class="gw-add-to-wishlist-product-card-placeholder"
|
||||||
|
data-gw-variant-id="{{ product.variants[0].id }}"
|
||||||
|
data-gw-product-id="{{ product.id }}"></div>
|
||||||
|
|
||||||
{%- liquid
|
{%- liquid
|
||||||
assign grid_image_size = settings.image_size
|
assign grid_image_size = settings.image_size
|
||||||
assign image = featured_media.preview_image
|
assign image = featured_media.preview_image
|
||||||
@@ -260,9 +289,9 @@
|
|||||||
<div class="product__media__image{% if product_grid_hover %} product__media__image--hover-{{ product_grid_hover_animation }}{% endif %} lazy-image" style="background-image: url({{ image | img_url: '1x1' }});" data-product-media-featured>
|
<div class="product__media__image{% if product_grid_hover %} product__media__image--hover-{{ product_grid_hover_animation }}{% endif %} lazy-image" style="background-image: url({{ image | img_url: '1x1' }});" data-product-media-featured>
|
||||||
{%- capture image_attributes -%}
|
{%- capture image_attributes -%}
|
||||||
data-product-image
|
data-product-image
|
||||||
data-grid-image="{{ forloop.index0 }}"
|
data-grid-image="0"
|
||||||
data-grid-image-target="{{ media.id }}"
|
data-grid-image-target="{{ featured_media.id }}"
|
||||||
data-grid-image-target-default="{{ media.id }}"
|
data-grid-image-target-default="{{ featured_media.id }}"
|
||||||
{%- endcapture -%}
|
{%- endcapture -%}
|
||||||
|
|
||||||
{%- render 'image-fill',
|
{%- render 'image-fill',
|
||||||
@@ -365,28 +394,12 @@
|
|||||||
if settings.show_saving_badge
|
if settings.show_saving_badge
|
||||||
assign price = current_variant.price
|
assign price = current_variant.price
|
||||||
assign price_compare = current_variant.compare_at_price
|
assign price_compare = current_variant.compare_at_price
|
||||||
|
assign price_difference = price_compare | minus: price
|
||||||
assign current_variant_price = current_variant.metafields.app--168074346497.auto_discounted_price.value | default: current_variant.price
|
|
||||||
assign current_variant_compare_at_price = current_variant.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 current_variant_price = current_variant.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil
|
|
||||||
endif
|
|
||||||
|
|
||||||
if current_variant_price < current_variant.price and current_variant_compare_at_price == 0 or current_variant_compare_at_price == blank
|
|
||||||
assign current_variant_compare_at_price = current_variant.price
|
|
||||||
endif
|
|
||||||
|
|
||||||
comment
|
comment
|
||||||
assign price_difference = price_compare | minus: price
|
|
||||||
endcomment
|
|
||||||
|
|
||||||
assign price_difference = current_variant_compare_at_price | minus: current_variant_price
|
|
||||||
|
|
||||||
assign test_variants = product.variants | where: 'compare_at_price' | where: 'available', true
|
assign test_variants = product.variants | where: 'compare_at_price' | where: 'available', true
|
||||||
|
|
||||||
|
|
||||||
if test_variants.size > 0
|
if test_variants.size > 0
|
||||||
for variant in test_variants
|
for variant in test_variants
|
||||||
assign variant_price_difference = variant.compare_at_price | minus: variant.price
|
assign variant_price_difference = variant.compare_at_price | minus: variant.price
|
||||||
@@ -398,6 +411,7 @@
|
|||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
|
endcomment
|
||||||
|
|
||||||
if settings.currency_code_enable
|
if settings.currency_code_enable
|
||||||
assign discount = price_difference | money_with_currency | remove: '.00' | remove: ',00'
|
assign discount = price_difference | money_with_currency | remove: '.00' | remove: ',00'
|
||||||
@@ -406,7 +420,7 @@
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if settings.saving_badge_type == 'percentage'
|
if settings.saving_badge_type == 'percentage'
|
||||||
assign percent_off = price_difference | times: 1.00 | divided_by: current_variant_compare_at_price | times: 100
|
assign percent_off = price_difference | times: 1.00 | divided_by: price_compare | times: 100
|
||||||
assign discount = percent_off | floor | append: '%'
|
assign discount = percent_off | floor | append: '%'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -533,7 +547,8 @@
|
|||||||
<product-grid-item-swatch class="product-grid-item__swatch
|
<product-grid-item-swatch class="product-grid-item__swatch
|
||||||
{%- if settings.color_swatches_product_style == 'rectangle' %} product-grid__swatch--rectangle{% endif %}"
|
{%- if settings.color_swatches_product_style == 'rectangle' %} product-grid__swatch--rectangle{% endif %}"
|
||||||
data-swatch-handle="{{ product.handle }}"
|
data-swatch-handle="{{ product.handle }}"
|
||||||
data-swatch-label="{{ color_label }}">
|
data-swatch-label="{{ color_label }}"
|
||||||
|
role="listbox">
|
||||||
{%- for option in color_option -%}
|
{%- for option in color_option -%}
|
||||||
{%- liquid
|
{%- liquid
|
||||||
for variant in product.variants
|
for variant in product.variants
|
||||||
@@ -562,7 +577,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{%- assign color_variant_text = 'general.swatches.color_variant' | t -%}
|
{%- assign color_variant_text = 'general.swatches.color_variant' | t -%}
|
||||||
{%- assign swatch_product_title = product.title | strip_html | escape -%}
|
{%- assign swatch_product_title = product.title | strip_html | escape -%}
|
||||||
<a href="{{ product.url }}?variant={{ swatch_variant.id }}" data-swatch-variant="{{ swatch_variant.id }}" class="swatch__link">{{ swatch_product_title | append: ' - ' | append: color_variant_text | append: ': ' | append: option }}</a>
|
<a href="{{ product.url }}?variant={{ swatch_variant.id }}" data-swatch-variant="{{ swatch_variant.id }}" class="swatch__link" role="option">{{ swatch_product_title | append: ' - ' | append: color_variant_text | append: ': ' | append: option }}</a>
|
||||||
</div>
|
</div>
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
|
|
||||||
@@ -605,8 +620,6 @@
|
|||||||
{{ product_info_price }}
|
{{ product_info_price }}
|
||||||
{%- endunless -%}
|
{%- endunless -%}
|
||||||
|
|
||||||
{% render 'aframe_sswatch', product:product %}
|
|
||||||
|
|
||||||
{%- if settings.show_rating and product.metafields.reviews != empty -%}
|
{%- if settings.show_rating and product.metafields.reviews != empty -%}
|
||||||
<a href="{{ product.url | within: collection }}" class="product-grid-item__rating"{% if index > 1 %} tabindex="-1"{% endif %} data-grid-link>
|
<a href="{{ product.url | within: collection }}" class="product-grid-item__rating"{% if index > 1 %} tabindex="-1"{% endif %} data-grid-link>
|
||||||
{%- render 'rating', reviews: product.metafields.reviews, show_rating_count: settings.show_rating_count, tabindex_hidden: tabindex_hidden -%}
|
{%- render 'rating', reviews: product.metafields.reviews, show_rating_count: settings.show_rating_count, tabindex_hidden: tabindex_hidden -%}
|
||||||
@@ -614,3 +627,12 @@
|
|||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script class="camouflage-custom-metafields">
|
||||||
|
window.camouflage_product_metafields = window.camouflage_product_metafields || {};
|
||||||
|
window.camouflage_product_metafields[{{product.id}}] = {
|
||||||
|
{% for variant in product.variants %}
|
||||||
|
{{ variant.id }}: {{ variant.metafields.custom.disable_variante.value | json }}{% unless forloop.last %},{% endunless %}
|
||||||
|
{% endfor %}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
Reference in new issue
Block a user