From 863bab8e821340dbf16c8bceccd52a7f57e98f08 Mon Sep 17 00:00:00 2001 From: Nathan Ferguson Date: Thu, 30 Mar 2017 15:48:05 -0400 Subject: [PATCH 1/3] use valid object properties to render HTML --- src/sections/product.liquid | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/sections/product.liquid b/src/sections/product.liquid index f94d9c53b..0c45e0a24 100644 --- a/src/sections/product.liquid +++ b/src/sections/product.liquid @@ -76,10 +76,12 @@ {{ current_variant.price | money }} - {% if current_variant.compare_at_price_max > current_variant.price %} + {% if product.compare_at_price_max > product.price %} {{ 'products.product.regular_price' | t }} - {{ current_variant.compare_at_price | money }} + {% if current_variant.compare_at_price > current_variant.price %} + {{ current_variant.compare_at_price | money }} + {% endif %} {% endif %} From 57c753269da1d64531b660ef30d393bf17daf40c Mon Sep 17 00:00:00 2001 From: Nathan Ferguson Date: Thu, 30 Mar 2017 16:13:50 -0400 Subject: [PATCH 2/3] update and hide elements when not on sale --- src/scripts/sections/product.js | 11 +++++++---- src/sections/product.liquid | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/scripts/sections/product.js b/src/scripts/sections/product.js index 2c3d6bfb1..c987c66fc 100644 --- a/src/scripts/sections/product.js +++ b/src/scripts/sections/product.js @@ -12,6 +12,7 @@ theme.Product = (function() { addToCart: '[data-add-to-cart]', addToCartText: '[data-add-to-cart-text]', comparePrice: '[data-compare-price]', + comparePriceText: '[data-compare-text]', originalSelectorId: '[data-product-select]', priceWrapper: '[data-price-wrapper]', productFeaturedImage: '[data-product-featured-image]', @@ -103,16 +104,18 @@ theme.Product = (function() { */ updateProductPrices: function(evt) { var variant = evt.variant; + var $comparePrice = $(selectors.comparePrice, this.$container); + var $compareEls = $comparePrice.add(selectors.comparePriceText, this.$container); $(selectors.productPrice, this.$container) .html(slate.Currency.formatMoney(variant.price, theme.moneyFormat)); if (variant.compare_at_price > variant.price) { - $(selectors.comparePrice, this.$container) - .html(slate.Currency.formatMoney(variant.compare_at_price, theme.moneyFormat)) - .removeClass('hide'); + $comparePrice.html(slate.Currency.formatMoney(variant.compare_at_price, theme.moneyFormat)); + $compareEls.removeClass('hide'); } else { - $(selectors.comparePrice, this.$container).addClass('hide'); + $comparePrice.html(''); + $compareEls.addClass('hide'); } }, diff --git a/src/sections/product.liquid b/src/sections/product.liquid index 0c45e0a24..62ceeba02 100644 --- a/src/sections/product.liquid +++ b/src/sections/product.liquid @@ -77,7 +77,7 @@ {% if product.compare_at_price_max > product.price %} - {{ 'products.product.regular_price' | t }} + {{ 'products.product.regular_price' | t }} {% if current_variant.compare_at_price > current_variant.price %} {{ current_variant.compare_at_price | money }} From bc0258572950dba974d4dd4fce099c9766ae82a4 Mon Sep 17 00:00:00 2001 From: Nathan Ferguson Date: Thu, 30 Mar 2017 16:20:38 -0400 Subject: [PATCH 3/3] use variant price info on featured product --- src/sections/featured-product.liquid | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/sections/featured-product.liquid b/src/sections/featured-product.liquid index 54a58c0d6..4188235ca 100644 --- a/src/sections/featured-product.liquid +++ b/src/sections/featured-product.liquid @@ -1,4 +1,5 @@ {%- assign product = all_products[section.settings.product] -%} +{%- assign current_variant = product.selected_or_first_available_variant -%} {% if product.empty? %} {%- assign section_onboarding = true -%} @@ -81,13 +82,15 @@
- {{ product.price | default: '1999' | money }} + {{ current_variant.price | default: '1999' | money }} {% if product.compare_at_price_max > product.price %} - {{ 'products.product.regular_price' | t }} + {{ 'products.product.regular_price' | t }} - {{ product.compare_at_price | money }} + {% if current_variant.compare_at_price > current_variant.price %} + {{ current_variant.compare_at_price | money }} + {% endif %} {% endif %}