Skip to content
This repository has been archived by the owner on Aug 30, 2018. It is now read-only.

Commit

Permalink
Added product price fix to search results
Browse files Browse the repository at this point in the history
  • Loading branch information
cshold committed Feb 23, 2015
1 parent 64bcaf2 commit e493012
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 34 deletions.
2 changes: 1 addition & 1 deletion snippets/product-grid-item.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}

Expand Down
2 changes: 1 addition & 1 deletion snippets/product-list-item.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}

Expand Down
57 changes: 42 additions & 15 deletions snippets/search-result-grid.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}

<div class="grid__item search-result {{ grid_item_width }}">

{% if item.featured_image %}
Expand All @@ -30,20 +46,31 @@

<h5>{{ item.title | link_to: item.url }}</h5>

<h6>
{% if item.compare_at_price > item.price %}
<span class="on-sale" itemprop="price">
{{ item.price | money }}
</span>
<small>
{{ 'products.product.compare_at' | t }}
{{ item.compare_at_price_max | money }}
</small>
{% else %}
<span itemprop="price">
{{ item.price | money }}
</span>
{% endif %}
</h6>
{% if item.price %}
<p>
{% 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 %}
<strong>{{ 'products.product.on_sale' | t }}</strong>
<span itemprop="price">{{ item.price | money }}</span>
{% endif %}
{% else %}
{% if item.price_varies %}{{ 'products.general.from' | t }}{% endif %}
<span itemprop="price">{{ item.price | money }}</span>
{% endif %}
{% if sold_out %}
<br><strong>{{ 'products.product.sold_out' | t }}</strong>
{% endif %}
{% if on_sale %}
<br><s>{{ item.compare_at_price | money }}</s>
{% endif %}
</p>
{% endif %}

</div>
57 changes: 41 additions & 16 deletions snippets/search-result.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}

<div class="grid">

{% if item.featured_image %}
Expand All @@ -33,22 +49,31 @@
<div class="grid__item two-thirds {% unless item.featured_image %}push--one-third{% endunless %}">
<h3>{{ item.title | link_to: item.url }}</h3>

{% 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 %}
<span class="on-sale" itemprop="price">
{{ item.price | money }}
</span>
<small>
{{ 'products.product.compare_at' | t }}
{{ item.compare_at_price_max | money }}
</small>
{% else %}
<span itemprop="price">
{{ item.price | money }}
</span>
{% if item.price %}
<p>
{% 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 %}
<strong>{{ 'products.product.on_sale' | t }}</strong>
<span itemprop="price">{{ item.price | money }}</span>
{% endif %}
{% else %}
{% if item.price_varies %}{{ 'products.general.from' | t }}{% endif %}
<span itemprop="price">{{ item.price | money }}</span>
{% endif %}
{% if sold_out %}
<br><strong>{{ 'products.product.sold_out' | t }}</strong>
{% endif %}
{% if on_sale %}
<br><s>{{ item.compare_at_price | money }}</s>
{% endif %}
</p>
{% endif %}

{% comment %}
Expand Down
2 changes: 1 addition & 1 deletion templates/search.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e493012

Please sign in to comment.