Skip to content

Commit

Permalink
Merge pull request #132 from Voog/131-sale-price-support
Browse files Browse the repository at this point in the history
Add sale price support (#132)
  • Loading branch information
tanelj authored Nov 23, 2023
2 parents c1d3ed5 + c7eb01d commit 3144056
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 51 deletions.
16 changes: 8 additions & 8 deletions components/buy-button.tpl
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
{%- if product.price_min_with_tax != product.price_max_with_tax -%}
{%- assign with_price = true -%}
{%- else -%}
{%- if product.price_min_with_tax == product.price_max_with_tax and
product.effective_price_min_with_tax == product.effective_price_max_with_tax
-%}
{%- assign with_price = false -%}
{%- else -%}
{%- assign with_price = true -%}
{%- endif -%}

{%- capture _button_attributes %}
data-product-id="{{ product.id }}"
data-product="{{ product | json | escape }}"
data-settings="{"title":"{{ "add_to_cart" | lc | escape_once }}"
{%- if with_price -%}
{%- if with_price and product.uses_variants -%}
,"button_style":"with_price"
{%- endif -%}
}"
Expand Down Expand Up @@ -44,11 +46,9 @@
{% else %}
<span class="edy-buy-button-title">{{ 'add_to_cart' | lc | escape_once }}</span>
{% endif -%}

{%- if with_price and product.price_min_with_tax == product.price_max_with_tax -%}
<span class="edy-buy-button-price">{{ product.price_with_tax | money_with_currency: product.currency }}</span>
{%- endif -%}
</div>

<div class="edy-buy-button-price-container"></div>
</div>
</div>
{% else %}
Expand Down
43 changes: 36 additions & 7 deletions components/product-item.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,33 @@
{{ look_closer_btn }}
<div class="product_item-price">
<div class="flex_box">
{%- if _buyButton.product.price_max_with_tax != _buyButton.product.price_min_with_tax -%}
{{ _buyButton.product.price_min_with_tax | money_with_currency: _buyButton.product.currency }}
<span class="pad_0-4">-</span>
{%- endif -%}
{{ _buyButton.product.price_max_with_tax | money_with_currency: _buyButton.product.currency }}
{%- capture original_price -%}
{%- if _buyButton.product.price_max_with_tax != _buyButton.product.price_min_with_tax -%}
{{ _buyButton.product.price_min_with_tax | money_with_currency: _buyButton.product.currency }}
<span> – </span>
{%- endif -%}
{{ _buyButton.product.price_max_with_tax | money_with_currency: _buyButton.product.currency }}
{%- endcapture -%}

<div class="product-price">
{% if _buyButton.product.on_sale? %}
<s class="product-price-original">
{{- original_price -}}
</s>
{% endif %}

<span class="product-price-final">
{%- if _buyButton.product.on_sale? -%}
{% if _buyButton.product.effective_price_min_with_tax != _buyButton.product.effective_price_max_with_tax %}
{{- _buyButton.product.effective_price_min_with_tax | money_with_currency: _buyButton.product.currency -}}
<span> – </span>
{%- endif -%}
{{- _buyButton.product.effective_price_max_with_tax | money_with_currency: _buyButton.product.currency -}}
{%- else -%}
{{- original_price -}}
{%- endif -%}
</span>
</div>
</div>
</div>
{%- else -%}
Expand All @@ -68,8 +90,15 @@
<div class="product_item-btn js-cart-btn p-rel" data-product-id="{{ _buyButton.product.id }}">{{ "add_to_cart" | lc | escape_once }}</div>
{%- endif -%}
<div class="product_item-price">
<span>
{{ _buyButton.product.price_with_tax | money_with_currency: _buyButton.product.currency }}
<span class="product-price">
{%- if _buyButton.product.on_sale? -%}
<s class="product-price-original">
{{ _buyButton.product.price_min_with_tax | money_with_currency: _buyButton.product.currency }}
</s>
{%- endif -%}
<span class="product-price-final">
{{- _buyButton.product.effective_price_min_with_tax | money_with_currency: _buyButton.product.currency -}}
</span>
</span>
</div>

Expand Down
22 changes: 16 additions & 6 deletions components/template-cs-style-rules.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,14 @@ body {
-webkit-box-shadow: var(--content-button-border-width) var(--content-button-border-width) 0 rgba(0, 0, 0, 0.2);
box-shadow: var(--content-button-border-width) var(--content-button-border-width) 0 rgba(0, 0, 0, 0.2);
}
.content-formatted .edy-buy-button-price-container .edy-buy-button-price-original,
.content-formatted .edy-buy-button-price-container .edy-buy-button-effective-price {
color: var(--content-body-text-color);
}
.dark-background .content-formatted .edy-buy-button-price-container .edy-buy-button-price-original,
.dark-background .content-formatted .edy-buy-button-price-container .edy-buy-button-effective-price {
color: var(--third-color);
}

.content-formatted .form_field_textfield, .content-formatted .form_field_textarea, .content-formatted .form_field_select {
font-size: var(--form-field-font-size);
Expand Down Expand Up @@ -327,6 +335,8 @@ body {
font-size: var(--content-area-product-price__font-size);
font-weight: var(--content-area-product-price__font-weight);
font-style: var(--content-area-product-price__font-style);
}
.product-content .product-price .product-price-final {
-webkit-text-decoration: var(--content-area-product-price__text-decoration);
text-decoration: var(--content-area-product-price__text-decoration);
}
Expand All @@ -352,7 +362,6 @@ body {
.dark-background .edy-product-widget-grid .edy-product-widget-item .edy-product-widget-item-details-wrap .edy-product-widget-item-link {
color: var(--third-color);
}
.dark-background .edy-product-widget-grid .edy-product-widget-item .edy-product-widget-item-details-wrap .edy-product-widget-item-price,
.dark-background .edy-product-widget-grid .edy-product-widget-item .edy-product-widget-item-details-wrap .edy-product-widget-item-description {
color: var(--third-color);
opacity: 0.7;
Expand All @@ -372,10 +381,6 @@ body {
.dark-background .edy-product-widget-list .edy-product-widget-item-wrap .edy-product-widget-item .edy-product-widget-item-details-wrap .edy-product-widget-item-header .edy-product-widget-item-title .edy-product-widget-item-link {
color: var(--third-color);
}
.dark-background .edy-product-widget-list .edy-product-widget-item-wrap .edy-product-widget-item .edy-product-widget-item-details-wrap .edy-product-widget-item-header .edy-product-widget-item-price {
color: var(--third-color);
opacity: 0.7;
}
.dark-background .edy-product-widget-list .edy-product-widget-item-wrap .edy-product-widget-item .edy-product-widget-item-details-wrap .edy-product-widget-item-header .edy-product-widget-item-out-of-stock {
color: var(--third-color);
}
Expand All @@ -391,9 +396,14 @@ body {
color: var(--secondary-color-content);
}

.dark-background .edy-product-widget-item-price-original,
.dark-background .edy-product-widget-item-price-final,
.dark-background .edy-product-widget-filter-name,
.dark-background .edy-product-widget-filter-sort,
.dark-background .edy-product-widget-filter-label,
.dark-background .edy-product-widget-filter-search-input {
color: var(--fourth-color);
color: var(--third-color);
}
.dark-background .edy-product-widget-item-price-original {
opacity: 0.4;
}
30 changes: 25 additions & 5 deletions layouts/auto_generated_product.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,32 @@
<h1>{%- editable product.name -%}</h1>
</div>

<div class="product-price">
{%- if product.price_max_with_tax != product.price_min_with_tax -%}
{{ product.price_min_with_tax | money_with_currency: product.currency -}}
<span class="product-price-divider">–</span>
{%- capture original_price -%}
{% if product.price_min_with_tax != product.price_max_with_tax -%}
{{- product.price_min_with_tax | money_with_currency: product.currency -}}
<span> – </span>
{%- endif -%}
{{ product.price_max_with_tax | money_with_currency: product.currency -}}
{{- product.price_max_with_tax | money_with_currency: product.currency -}}
{%- endcapture -%}

<div class="product-price">
{% if product.on_sale? -%}
<s class="product-price-original">
{{- original_price -}}
</s>
{% endif -%}

<span class="product-price-final">
{%- if product.on_sale? -%}
{% if product.effective_price_min_with_tax != product.effective_price_max_with_tax %}
{{- product.effective_price_min_with_tax | money_with_currency: product.currency -}}
<span> – </span>
{%- endif -%}
{{- product.effective_price_max_with_tax | money_with_currency: product.currency -}}
{% else %}
{{ original_price }}
{% endif -%}
</span>
</div>

<section class="content-formatted" data-search-indexing-allowed="true">
Expand Down
32 changes: 24 additions & 8 deletions sources/components/custom-styles/template-cs-style-rules.scss
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,17 @@ body {
box-shadow: var(--content-button-border-width) var(--content-button-border-width) 0 rgba($black, .2);
}
}

.edy-buy-button-price-container {
.edy-buy-button-price-original,
.edy-buy-button-effective-price {
color: var(--content-body-text-color);

.dark-background & {
color: var(--third-color);
}
}
}
}

//==============================================================================
Expand Down Expand Up @@ -406,15 +417,20 @@ body {
font-size: var(--content-area-product-price__font-size);
font-weight: var(--content-area-product-price__font-weight);
font-style: var(--content-area-product-price__font-style);
text-decoration: var(--content-area-product-price__text-decoration);

.product-price-final {
text-decoration: var(--content-area-product-price__text-decoration);
}
}

.product-description {
color: var(--content-area-product-description__color);
font-size: var(--content-area-product-description__font-size);
font-weight: var(--content-area-product-description__font-weight);
font-style: var(--content-area-product-description__font-style);
text-decoration: var(--content-area-product-description__text-decoration);
}

.content-item-title h1 {
color: var(--content-area-product-title__color);
font-size: var(--content-area-product-title__font-size);
Expand All @@ -433,7 +449,6 @@ body {
color: var(--third-color);
}

.edy-product-widget-item-price,
.edy-product-widget-item-description {
color: var(--third-color);
opacity: .7;
Expand Down Expand Up @@ -469,11 +484,6 @@ body {
}
}

.edy-product-widget-item-price {
color: var(--third-color);
opacity: .7;
}

.edy-product-widget-item-out-of-stock {
color: var(--third-color);
}
Expand All @@ -495,10 +505,16 @@ body {
}

.dark-background {
.edy-product-widget-item-price-original,
.edy-product-widget-item-price-final,
.edy-product-widget-filter-name,
.edy-product-widget-filter-sort,
.edy-product-widget-filter-label,
.edy-product-widget-filter-search-input {
color: var(--fourth-color);
color: var(--third-color);
}

.edy-product-widget-item-price-original {
opacity: .4;
}
}
4 changes: 4 additions & 0 deletions sources/stylesheets/content/_buy-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
word-break: normal;
}
// sass-lint:enable class-name-format

.edy-buy-button-price-container .edy-buy-button-price-original {
opacity: .4;
}
}

.edy-buy-button-variants {
Expand Down
10 changes: 8 additions & 2 deletions sources/stylesheets/layouts/_auto-generated-product.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@
.product-price {
padding: 12px 0 24px 0;

&-divider {
margin: 0 4px;
.product-price-original {
display: inline-block;
padding-right: 4px;
opacity: .4;
}

.product-price-final {
display: inline-block;
}
}

Expand Down
15 changes: 9 additions & 6 deletions sources/stylesheets/layouts/_product-list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
.product_item-title,
.product_item-btn,
.product_item-price {
color: var(--color-main);
color: var(--main-color-content);
font-family: var(--font-primary);
font-size: 16px;
line-height: 1.3;
word-break: break-word;

.dark-background & {
color: $white;
color: var(--third-color);
}

a {
color: var(--color-main);
color: var(--main-color-content);
}
}

Expand All @@ -37,7 +37,10 @@
transition: all 300ms;
display: flex;
flex-wrap: wrap;
color: var(--secondary-color);

.product-price-original {
opacity: .4;
}
}

&:hover {
Expand Down Expand Up @@ -66,7 +69,7 @@

&-list {
a {
color: var(--color-main);
color: var(--main-color-content);
}
}

Expand All @@ -75,7 +78,7 @@
overflow: hidden;

a {
color: var(--color-main);
color: var(--main-color-content);
}
&--wrap {
display: flex;
Expand Down
Loading

0 comments on commit 3144056

Please sign in to comment.