From e493012b1b9130b27b30330d641d51acf645d277 Mon Sep 17 00:00:00 2001 From: Carson Shold Date: Mon, 23 Feb 2015 12:05:35 -0500 Subject: [PATCH] Added product price fix to search results --- snippets/product-grid-item.liquid | 2 +- snippets/product-list-item.liquid | 2 +- snippets/search-result-grid.liquid | 57 ++++++++++++++++++++++-------- snippets/search-result.liquid | 57 +++++++++++++++++++++--------- templates/search.liquid | 2 +- 5 files changed, 86 insertions(+), 34 deletions(-) diff --git a/snippets/product-grid-item.liquid b/snippets/product-grid-item.liquid index 8e5f9f0f3..f890a8946 100755 --- a/snippets/product-grid-item.liquid +++ b/snippets/product-grid-item.liquid @@ -33,7 +33,7 @@ Check if the product is sold out and set a variable to be used below. {% endcomment %} {% assign sold_out = true %} -{% if product.available %} +{% if product.available %} {% assign sold_out = false %} {% endif %} diff --git a/snippets/product-list-item.liquid b/snippets/product-list-item.liquid index 0b55e355f..0e6492b0c 100755 --- a/snippets/product-list-item.liquid +++ b/snippets/product-list-item.liquid @@ -18,7 +18,7 @@ Check if the product is sold out and set a variable to be used below. {% endcomment %} {% assign sold_out = true %} -{% if product.available %} +{% if product.available %} {% assign sold_out = false %} {% endif %} diff --git a/snippets/search-result-grid.liquid b/snippets/search-result-grid.liquid index ac57537fe..33b210a3c 100755 --- a/snippets/search-result-grid.liquid +++ b/snippets/search-result-grid.liquid @@ -18,6 +18,22 @@ {% assign grid_item_width = 'large--one-third medium--one-half' %} {% endunless %} +{% comment %} + Check if the product is on sale and set a variable to be used below. +{% endcomment %} +{% assign on_sale = false %} +{% if item.compare_at_price > item.price %} + {% assign on_sale = true %} +{% endif %} + +{% comment %} + Check if the product is sold out and set a variable to be used below. +{% endcomment %} +{% assign sold_out = true %} +{% if item.available %} + {% assign sold_out = false %} +{% endif %} +
{% if item.featured_image %} @@ -30,20 +46,31 @@
{{ item.title | link_to: item.url }}
-
- {% if item.compare_at_price > item.price %} - - {{ item.price | money }} - - - {{ 'products.product.compare_at' | t }} - {{ item.compare_at_price_max | money }} - - {% else %} - - {{ item.price | money }} - - {% endif %} -
+ {% if item.price %} +

+ {% comment %} + You can show a leading 'from' or 'up to' by checking 'product.price_varies' + if your variants have different prices. + {% endcomment %} + {% if on_sale %} + {% if item.price_varies %} + {% assign sale_price = item.price | money %} + {{ 'products.product.on_sale_from_html' | t: price: sale_price }} + {% else %} + {{ 'products.product.on_sale' | t }} + {{ item.price | money }} + {% endif %} + {% else %} + {% if item.price_varies %}{{ 'products.general.from' | t }}{% endif %} + {{ item.price | money }} + {% endif %} + {% if sold_out %} +
{{ 'products.product.sold_out' | t }} + {% endif %} + {% if on_sale %} +
{{ item.compare_at_price | money }} + {% endif %} +

+ {% endif %}
diff --git a/snippets/search-result.liquid b/snippets/search-result.liquid index 555e648af..0c1c9841f 100755 --- a/snippets/search-result.liquid +++ b/snippets/search-result.liquid @@ -14,6 +14,22 @@ {% endcomment %} +{% comment %} + Check if the product is on sale and set a variable to be used below. +{% endcomment %} +{% assign on_sale = false %} +{% if item.compare_at_price > item.price %} + {% assign on_sale = true %} +{% endif %} + +{% comment %} + Check if the product is sold out and set a variable to be used below. +{% endcomment %} +{% assign sold_out = true %} +{% if item.available %} + {% assign sold_out = false %} +{% endif %} +
{% if item.featured_image %} @@ -33,22 +49,31 @@

{{ item.title | link_to: item.url }}

- {% comment %} - To show the price, let's pull what was already done on the product page, - but change product to item. - {% endcomment %} - {% if item.compare_at_price > item.price %} - - {{ item.price | money }} - - - {{ 'products.product.compare_at' | t }} - {{ item.compare_at_price_max | money }} - - {% else %} - - {{ item.price | money }} - + {% if item.price %} +

+ {% comment %} + You can show a leading 'from' or 'up to' by checking 'product.price_varies' + if your variants have different prices. + {% endcomment %} + {% if on_sale %} + {% if item.price_varies %} + {% assign sale_price = item.price | money %} + {{ 'products.product.on_sale_from_html' | t: price: sale_price }} + {% else %} + {{ 'products.product.on_sale' | t }} + {{ item.price | money }} + {% endif %} + {% else %} + {% if item.price_varies %}{{ 'products.general.from' | t }}{% endif %} + {{ item.price | money }} + {% endif %} + {% if sold_out %} +
{{ 'products.product.sold_out' | t }} + {% endif %} + {% if on_sale %} +
{{ item.compare_at_price | money }} + {% endif %} +

{% endif %} {% comment %} diff --git a/templates/search.liquid b/templates/search.liquid index 8e4246d88..3c24733ee 100755 --- a/templates/search.liquid +++ b/templates/search.liquid @@ -17,7 +17,7 @@ If you're only showing products with the method above, why not show them off in a grid instead? Set grid_results to true and see your updated results page for the new layout. {% endcomment %} -{% assign grid_results = false %} +{% assign grid_results = true %} {% comment %} Check to enforce respond.js