From a625737193668719c4458e939325fd9927307420 Mon Sep 17 00:00:00 2001 From: Sofia Matulis Date: Tue, 18 Jul 2023 14:34:20 -0300 Subject: [PATCH 01/13] Price per item, Popover and global style bugs (#2851) --- assets/component-volume-pricing.css | 4 ++ assets/price-per-item.js | 2 - assets/quantity-popover.css | 17 ++++- sections/featured-product.liquid | 94 +++++++++++++++++++--------- sections/main-cart-items.liquid | 4 +- sections/main-product.liquid | 61 +++++++++++++----- sections/quick-order-list.liquid | 39 +++++++++--- snippets/cart-drawer.liquid | 32 +++++++--- snippets/quick-order-list-row.liquid | 55 +++++++++------- 9 files changed, 215 insertions(+), 93 deletions(-) diff --git a/assets/component-volume-pricing.css b/assets/component-volume-pricing.css index dc4ed2ae388..3d07c0ee380 100644 --- a/assets/component-volume-pricing.css +++ b/assets/component-volume-pricing.css @@ -52,3 +52,7 @@ volume-pricing show-more-button { font-size: 1.4rem; letter-spacing: 0.06rem; } + +.price-per-item dd { + margin-left: 0; +} diff --git a/assets/price-per-item.js b/assets/price-per-item.js index 7bf83f3ab65..fdf37eb9700 100644 --- a/assets/price-per-item.js +++ b/assets/price-per-item.js @@ -72,7 +72,6 @@ if (!customElements.get('price-per-item')) { if (this.classList.contains('variant-item__price-per-item')) { this.currentQtyForVolumePricing = this.getCartQuantity(updatedCartQuantity); } - for (let pair of this.qtyPricePairs) { if (this.currentQtyForVolumePricing >= pair[0]) { const pricePerItemCurrent = document.querySelector(`price-per-item[id^="Price-Per-Item-${this.dataset.sectionId || this.dataset.variantId}"] .price-per-item span`); @@ -97,7 +96,6 @@ if (!customElements.get('price-per-item')) { this.qtyPricePairs.push([qty, price]); }); } - this.qtyPricePairs.reverse(); } } diff --git a/assets/quantity-popover.css b/assets/quantity-popover.css index eae0a897fbd..c39f7284a01 100644 --- a/assets/quantity-popover.css +++ b/assets/quantity-popover.css @@ -1,5 +1,6 @@ quantity-popover { position: relative; + display: block; } quantity-popover volume-pricing li:nth-child(odd) { @@ -22,12 +23,22 @@ quantity-popover volume-pricing li { max-width: 36rem; } +.quantity-popover__info .button-close, +.variant-remove-total quick-order-list-remove-all-button .button, +.quick-order-list-total__confirmation quick-order-list-remove-all-button .button, +quantity-popover quick-order-list-remove-button .button { + --shadow-opacity: 0; + --border-opacity: 0; +} + .quantity-popover__info-button { display: flex; align-items: center; margin: 0 0.4rem 0 0; min-width: 1.5rem; min-height: 1.5rem; + --shadow-opacity: 0; + --border-opacity: 0; } .quantity-popover__info-button--icon-with-label { @@ -79,6 +90,10 @@ quantity-popover volume-pricing li { justify-content: flex-end; } +.quantity-popover__info .volume-pricing-label~.button { + top: -0.2rem; +} + .quantity-popover__info .button .icon { width: 1.5rem; height: 1.5rem; @@ -145,4 +160,4 @@ quantity-popover .quantity__rules .divider:nth-child(2)::before { quantity-popover .quantity__button:not(:focus-visible):not(.focused), quantity-popover .quantity__input:not(:focus-visible):not(.focused) { background-color: initial; -} +} \ No newline at end of file diff --git a/sections/featured-product.liquid b/sections/featured-product.liquid index 22d5f814f18..7190579effb 100644 --- a/sections/featured-product.liquid +++ b/sections/featured-product.liquid @@ -282,35 +282,71 @@ assign current_qty_for_volume_pricing = cart_qty | plus: product.selected_or_first_available_variant.quantity_rule.increment endif -%} - - {%- if product.quantity_price_breaks_configured? -%} -
- {%- if current_qty_for_volume_pricing < volume_pricing_array.last.minimum_quantity -%} - {%- assign variant_price = product.selected_or_first_available_variant.price - | money_with_currency - -%} - - {{- 'products.product.volume_pricing.price_at_each' | t: price: variant_price -}} - - {%- else -%} - {%- for price_break in volume_pricing_array -%} - {%- if current_qty_for_volume_pricing >= price_break.minimum_quantity -%} - {%- assign price_break_price = price_break.price | money_with_currency -%} - - {{- 'products.product.volume_pricing.price_at_each' | t: price: price_break_price -}} - - {%- break -%} - {%- endif -%} - {%- endfor -%} - {%- endif -%} -
- {%- endif -%} -
+ {%- if product.quantity_price_breaks_configured? -%} + + {%- if product.selected_or_first_available_variant.quantity_price_breaks.size > 0 -%} +
+ {%- if current_qty_for_volume_pricing < volume_pricing_array.last.minimum_quantity -%} + {%- assign variant_price = product.selected_or_first_available_variant.price + | money_with_currency + -%} + + {{- 'products.product.volume_pricing.price_at_each' | t: price: variant_price -}} + + {%- else -%} + {%- for price_break in volume_pricing_array -%} + {%- if current_qty_for_volume_pricing >= price_break.minimum_quantity -%} + {%- assign price_break_price = price_break.price | money_with_currency -%} + + {{- + 'products.product.volume_pricing.price_at_each' + | t: price: price_break_price + -}} + + {%- break -%} + {%- endif -%} + {%- endfor -%} + {%- endif -%} +
+ {%- else -%} + {%- assign variant_price = product.selected_or_first_available_variant.price + | money_with_currency + -%} + {%- assign variant_price_compare = product.selected_or_first_available_variant.compare_at_price -%} +
+ {%- if variant_price_compare -%} +
+
+ {{ 'products.product.price.regular_price' | t }} +
+
+ + {{ variant_price_compare | money }} + +
+
+ {{ 'products.product.price.sale_price' | t }} +
+
+ + {{- 'products.product.volume_pricing.price_at_each' | t: price: variant_price -}} + +
+
+ {%- else -%} + + {{- 'products.product.volume_pricing.price_at_each' | t: price: variant_price -}} + + {%- endif -%} +
+ {%- endif -%} +
+ {%- endif -%}
{%- if product.selected_or_first_available_variant.quantity_rule.increment > 1 -%} diff --git a/sections/main-cart-items.liquid b/sections/main-cart-items.liquid index c93eb7f6018..068f6840eed 100644 --- a/sections/main-cart-items.liquid +++ b/sections/main-cart-items.liquid @@ -319,7 +319,9 @@ hidden > {%- if has_qty_rules == false -%} - Volume pricing + + {{- 'products.product.volume_pricing.title' | t -}} + {%- endif -%}
{%- if item.variant.quantity_rule.increment > 1 -%} diff --git a/sections/main-product.liquid b/sections/main-product.liquid index 609aaf9bf84..017e6a67137 100644 --- a/sections/main-product.liquid +++ b/sections/main-product.liquid @@ -275,24 +275,51 @@ endif -%} - - {%- if product.quantity_price_breaks_configured? -%} -
- {%- if current_qty_for_volume_pricing < volume_pricing_array.last.minimum_quantity -%} - {%- assign variant_price = product.selected_or_first_available_variant.price | money_with_currency -%} - {{ 'products.product.volume_pricing.price_at_each' | t: price: variant_price }} + {%- if product.quantity_price_breaks_configured? -%} + + {%- if product.selected_or_first_available_variant.quantity_price_breaks.size > 0 -%} +
+ {%- if current_qty_for_volume_pricing < volume_pricing_array.last.minimum_quantity -%} + {%- assign variant_price = product.selected_or_first_available_variant.price | money_with_currency -%} + {{ 'products.product.volume_pricing.price_at_each' | t: price: variant_price }} + {%- else -%} + {%- for price_break in volume_pricing_array -%} + {%- if current_qty_for_volume_pricing >= price_break.minimum_quantity -%} + {%- assign price_break_price = price_break.price | money_with_currency -%} + {{ 'products.product.volume_pricing.price_at_each' | t: price: price_break_price }} + {%- break -%} + {%- endif -%} + {%- endfor -%} + {%- endif -%} +
{%- else -%} - {%- for price_break in volume_pricing_array -%} - {%- if current_qty_for_volume_pricing >= price_break.minimum_quantity -%} - {%- assign price_break_price = price_break.price | money_with_currency -%} - {{ 'products.product.volume_pricing.price_at_each' | t: price: price_break_price }} - {%- break -%} - {%- endif -%} - {%- endfor -%} - {%- endif -%} -
- {%- endif -%} -
+ {%- assign variant_price = product.selected_or_first_available_variant.price | money_with_currency -%} + {%- assign variant_price_compare = product.selected_or_first_available_variant.compare_at_price -%} +
+ {%- if variant_price_compare -%} +
+
+ {{ 'products.product.price.regular_price' | t }} +
+
+ + {{ variant_price_compare | money }} + +
+
+ {{ 'products.product.price.sale_price' | t }} +
+
+ {{ 'products.product.volume_pricing.price_at_each' | t: price: variant_price }} +
+
+ {%- else -%} + {{ 'products.product.volume_pricing.price_at_each' | t: price: variant_price }} + {%- endif -%} +
+ {%- endif -%} + + {%- endif -%}
{%- if product.selected_or_first_available_variant.quantity_rule.increment > 1 -%} diff --git a/sections/quick-order-list.liquid b/sections/quick-order-list.liquid index ab2c4081aff..b2eb96dbfe6 100644 --- a/sections/quick-order-list.liquid +++ b/sections/quick-order-list.liquid @@ -140,9 +140,14 @@
{%- render 'loading-overlay' -%} - - {% render 'icon-remove' %} - {{ 'sections.quick_order_list.remove_all' | t }} + +
@@ -197,9 +202,15 @@
{%- render 'loading-overlay' -%} - - {% render 'icon-remove' %} - {{ 'sections.quick_order_list.remove_all' | t }} + +
@@ -217,16 +228,24 @@ {{ 'sections.quick_order_list.remove_all_items_confirmation' | t: quantity: items_in_cart }} - {{- 'sections.quick_order_list.remove_all' | t -}} + - {{- 'sections.quick_order_list.cancel' | t -}} + diff --git a/snippets/cart-drawer.liquid b/snippets/cart-drawer.liquid index e403cf59b8b..c5a9d5300d7 100644 --- a/snippets/cart-drawer.liquid +++ b/snippets/cart-drawer.liquid @@ -275,20 +275,28 @@ if item.variant.quantity_rule.increment > 1 or item.variant.quantity_rule.min > 1 or item.variant.quantity_rule.max != null assign has_qty_rules = true endif - + assign has_vol_pricing = false if item.variant.quantity_price_breaks.size > 0 assign has_vol_pricing = true endif -%} - +
-
+
@@ -312,7 +320,11 @@ > @@ -341,13 +353,13 @@ {% render 'icon-info' %} {%- if has_vol_pricing -%} - Volume pricing available + {{ 'products.product.volume_pricing.note' | t }} {%- elsif has_qty_rules -%} - View quantity rules + {{ 'products.product.quantity.note' | t }} {%- endif -%} - {%- endif -%} + {%- endif -%} {%- if has_vol_pricing or has_qty_rules -%}