From 07c1828d978d8a655545596c2a95f90468a42323 Mon Sep 17 00:00:00 2001 From: Sofia Matulis Date: Thu, 3 Aug 2023 13:43:15 -0400 Subject: [PATCH] Hide vol pricing and qty rules when variant is unavailable (#2889) --- assets/global.js | 30 +++++++++++++++++++++--------- sections/featured-product.liquid | 4 ++-- sections/main-product.liquid | 4 ++-- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/assets/global.js b/assets/global.js index c128d2dedc4..c04d3d37ad3 100644 --- a/assets/global.js +++ b/assets/global.js @@ -798,7 +798,7 @@ class SlideshowComponent extends SliderComponent { setSlidePosition(position) { if (this.setPositionTimeout) clearTimeout(this.setPositionTimeout); - this.setPositionTimeout = setTimeout (() => { + this.setPositionTimeout = setTimeout(() => { this.slider.scrollTo({ left: position, }); @@ -1110,12 +1110,18 @@ class VariantSelects extends HTMLElement { const pricePerItemSource = html.getElementById(`Price-Per-Item-${this.dataset.originalSection ? this.dataset.originalSection : this.dataset.section}`); const volumePricingDestination = document.getElementById(`Volume-${this.dataset.section}`); + const qtyRules = document.getElementById(`Quantity-Rules-${this.dataset.section}`); + const volumeNote = document.getElementById(`Volume-Note-${this.dataset.section}`); + + if (volumeNote) volumeNote.classList.remove('hidden'); + if (volumePricingDestination) volumePricingDestination.classList.remove('hidden'); + if (qtyRules) qtyRules.classList.remove('hidden'); if (source && destination) destination.innerHTML = source.innerHTML; if (inventorySource && inventoryDestination) inventoryDestination.innerHTML = inventorySource.innerHTML; if (skuSource && skuDestination) { skuDestination.innerHTML = skuSource.innerHTML; - skuDestination.classList.toggle('visibility-hidden', skuSource.classList.contains('visibility-hidden')); + skuDestination.classList.toggle('hidden', skuSource.classList.contains('hidden')); } if (volumePricingSource && volumePricingDestination) { @@ -1124,15 +1130,15 @@ class VariantSelects extends HTMLElement { if (pricePerItemSource && pricePerItemDestination) { pricePerItemDestination.innerHTML = pricePerItemSource.innerHTML; - pricePerItemDestination.classList.toggle('visibility-hidden', pricePerItemSource.classList.contains('visibility-hidden')); + pricePerItemDestination.classList.toggle('hidden', pricePerItemSource.classList.contains('hidden')); } const price = document.getElementById(`price-${this.dataset.section}`); - if (price) price.classList.remove('visibility-hidden'); + if (price) price.classList.remove('hidden'); if (inventoryDestination) - inventoryDestination.classList.toggle('visibility-hidden', inventorySource.innerText === ''); + inventoryDestination.classList.toggle('hidden', inventorySource.innerText === ''); const addButtonUpdated = html.getElementById(`ProductSubmitButton-${sectionId}`); this.toggleAddButton( @@ -1176,13 +1182,19 @@ class VariantSelects extends HTMLElement { const inventory = document.getElementById(`Inventory-${this.dataset.section}`); const sku = document.getElementById(`Sku-${this.dataset.section}`); const pricePerItem = document.getElementById(`Price-Per-Item-${this.dataset.section}`); + const volumeNote = document.getElementById(`Volume-Note-${this.dataset.section}`); + const volumeTable = document.getElementById(`Volume-${this.dataset.section}`); + const qtyRules = document.getElementById(`Quantity-Rules-${this.dataset.section}`); if (!addButton) return; addButtonText.textContent = window.variantStrings.unavailable; - if (price) price.classList.add('visibility-hidden'); - if (inventory) inventory.classList.add('visibility-hidden'); - if (sku) sku.classList.add('visibility-hidden'); - if (pricePerItem) pricePerItem.classList.add('visibility-hidden'); + if (price) price.classList.add('hidden'); + if (inventory) inventory.classList.add('hidden'); + if (sku) sku.classList.add('hidden'); + if (pricePerItem) pricePerItem.classList.add('hidden'); + if (volumeNote) volumeNote.classList.add('hidden'); + if (volumeTable) volumeTable.classList.add('hidden'); + if (qtyRules) qtyRules.classList.add('hidden'); } getVariantData() { diff --git a/sections/featured-product.liquid b/sections/featured-product.liquid index cd9291ae323..fe7897ac72a 100644 --- a/sections/featured-product.liquid +++ b/sections/featured-product.liquid @@ -177,7 +177,7 @@ -%} {%- if product.quantity_price_breaks_configured? -%} -
+
{{ 'products.product.volume_pricing.note' | t }}
{%- endif -%} @@ -361,7 +361,7 @@ {%- endif -%}
-
+
{%- if product.selected_or_first_available_variant.quantity_rule.increment > 1 -%} {{- diff --git a/sections/main-product.liquid b/sections/main-product.liquid index 8b9e9fc9b4c..b026b6042d1 100644 --- a/sections/main-product.liquid +++ b/sections/main-product.liquid @@ -106,7 +106,7 @@ -%}
{%- if product.quantity_price_breaks_configured? -%} -
+
{{ 'products.product.volume_pricing.note' | t }}
{%- endif -%} @@ -334,7 +334,7 @@ {%- endif -%}
-
+
{%- if product.selected_or_first_available_variant.quantity_rule.increment > 1 -%} {{-