Skip to content

Commit

Permalink
Fix empty badge prices
Browse files Browse the repository at this point in the history
When a span has an HTML comment inside a liquid tag... it will generate 
an empty badge, this PR fix that
  • Loading branch information
cetinajero committed Sep 30, 2019
1 parent 89cc416 commit bf18d2b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
23 changes: 12 additions & 11 deletions _includes/components/product-cards/product-generals.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,26 @@ <h3 id="{{ i18n-id }}" class="product-description">{% if i18n-description %}{{ i

{% assign collections = site.collections | where: "label", page.collection %}
{% for collection in collections %}
{% unless collection.prices == false %} <!-- disable prices per collection thru config file -->
{% unless collection.prices == false %}

{% unless site.product.price.disabled %} <!-- disable prices to all products -->
<span class="badge badge-primary text-white {% if page.promotion-price and site.original == false %}{{ 'disabled-price' }}{% endif %}">
{% capture price %}
{% unless site.product.price.disabled %}
{% assign price-size = page.price | downcase | split: '.' | last | size %}
{% if page.price %}{{ page.price | prepend: '$ ' }}{% endif %}{% if price-size == 1 %}{{ "0" }}{% endif %} <!-- add decimals and currency sing ($) to prices -->
{% if page.price %}{{ page.price | prepend: '$ ' }}{% endif %}{% if price-size == 1 %}{{ "0" }}{% endif %}
{% if page.currency %}
{{ page.currency | prepend: ' ' }} <!-- prepand currency (USD) -->
{{ page.currency | prepend: ' ' }}
{% endif %}
</span>
{% endunless %}
{% endunless %}
{% endcapture %}
<span class="badge badge-primary text-white {% if page.promotion-price and site.original == false %}{{ 'disabled-price' }}{% endif %}">{{ price | strip }}</span>

{% capture promotion-price %}
{% unless site.original %} <!-- only to customers -->
{% if site.special-offers.customers %} <!-- if the product has an special offer -->
{% unless site.original %}
{% if site.special-offers.customers %}
{% assign promotion-price-size = page.promotion-price | downcase | split: '.' | last | size %}
{% if page.promotion-price %}{{ page.promotion-price | prepend: '$ ' }}{% endif %}{% if promotion-price-size == 1 %}{{ "0" }}{% endif %} <!-- add decimals and currency sing ($) to prices -->
{% if page.promotion-price %}{{ page.promotion-price | prepend: '$ ' }}{% endif %}{% if promotion-price-size == 1 %}{{ "0" }}{% endif %}
{% if page.promotion-currency %}
{{ page.promotion-currency | prepend: ' ' }} <!-- prepand currency (USD) -->
{{ page.promotion-currency | prepend: ' ' }}
{% endif %}
{% else %}
<a href="/our-offices/" title="Our offices" class="white">
Expand Down
21 changes: 11 additions & 10 deletions _includes/components/product-cards/progressive.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,27 @@

{% assign collections = site.collections | where: "label", page.collection %}
{% for collection in collections %}
{% unless collection.prices == false %} <!-- disable prices per collection thru config file -->
{% unless collection.prices == false %}

{% unless site.product.price.disabled %} <!-- disable prices to all products -->
{% unless site.product.price.disabled %}
<div class="text-right mb-1 mt-2">

<span class="product-price badge badge-primary text-white text-sm {% if doc.promotion-price and site.original == false %}{{ 'disabled-price' }}{% endif %}">
{% capture price %}
{% assign doc-price-size = doc.price | downcase | split: '.' | last | size %}
{% if doc.price %}{{ doc.price | prepend: '$ ' }}{% endif %}{% if doc-price-size == 1 %}{{ "0" }}{% endif %} <!-- add decimals and currency sing ($) to prices -->
{% if doc.price %}{{ doc.price | prepend: '$ ' }}{% endif %}{% if doc-price-size == 1 %}{{ "0" }}{% endif %}
{% if doc.currency %}
{{ doc.currency | prepend: ' ' }} <!-- prepand currency (USD) -->
{{ doc.currency | prepend: ' ' }}
{% endif %}
</span>
{% endcapture %}
<span class="product-price badge badge-primary text-white text-sm {% if doc.promotion-price and site.original == false %}{{ 'disabled-price' }}{% endif %}">{{ price | strip }}</span>

{% capture promotion-price %}
{% unless site.original %} <!-- only to customers -->
{% if site.special-offers.customers %} <!-- if the product has an special offer -->
{% unless site.original %}
{% if site.special-offers.customers %}
{% assign promotion-price-size = doc.promotion-price | downcase | split: '.' | last | size %}
{% if doc.promotion-price %}{{ doc.promotion-price | prepend: '$ ' }}{% endif %}{% if promotion-price-size == 1 %}{{ "0" }}{% endif %} <!-- add decimals and currency sing ($) to prices -->
{% if doc.promotion-price %}{{ doc.promotion-price | prepend: '$ ' }}{% endif %}{% if promotion-price-size == 1 %}{{ "0" }}{% endif %}
{% if doc.promotion-currency %}
{{ doc.promotion-currency | prepend: ' ' }} <!-- prepand currency (USD) -->
{{ doc.promotion-currency | prepend: ' ' }}
{% endif %}
{% endif %}
{% endunless %}
Expand Down

0 comments on commit bf18d2b

Please sign in to comment.