Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide vol pricing and qty rules when variant is unavailable #2889

Merged
merged 4 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions assets/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down Expand Up @@ -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) {
Expand All @@ -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(
Expand Down Expand Up @@ -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() {
Expand Down
6 changes: 4 additions & 2 deletions assets/quick-order-list.css
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ quick-order-list .quantity__button {
.variant-item__sold-out {
opacity: 0.7;
font-size: 1.6rem;
color: rgb(var(--color-foreground));
}

quick-order-list-remove-button {
Expand Down Expand Up @@ -598,10 +599,11 @@ quick-order-list-remove-button {
align-items: center;
}

.quick-order-list__total-items h3,
.quick-order-list__total-items span,
.totals__subtotal-value {
margin-top: 0;
margin-bottom: 0;
color: rgb(var(--color-foreground));
}

.quick-order-list__total-items p,
Expand Down Expand Up @@ -658,7 +660,7 @@ quick-order-list-remove-button {
}

.totals__subtotal-value,
.quick-order-list__total-items h3 {
.quick-order-list__total-items span {
margin-right: 1.2rem;
}

Expand Down
4 changes: 2 additions & 2 deletions sections/featured-product.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
-%}
</div>
{%- if product.quantity_price_breaks_configured? -%}
<div class="volume-pricing-note">
<div class="volume-pricing-note" id="Volume-Note-{{ section.id }}">
<span>{{ 'products.product.volume_pricing.note' | t }}</span>
</div>
{%- endif -%}
Expand Down Expand Up @@ -361,7 +361,7 @@
</price-per-item>
{%- endif -%}
</div>
<div class="quantity__rules caption no-js-hidden">
<div class="quantity__rules caption no-js-hidden" id="Quantity-Rules-{{ section.id }}">
{%- if product.selected_or_first_available_variant.quantity_rule.increment > 1 -%}
<span class="divider">
{{-
Expand Down
4 changes: 2 additions & 2 deletions sections/main-product.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
-%}
</div>
{%- if product.quantity_price_breaks_configured? -%}
<div class="volume-pricing-note">
<div class="volume-pricing-note" id="Volume-Note-{{ section.id }}">
<span>{{ 'products.product.volume_pricing.note' | t }}</span>
</div>
{%- endif -%}
Expand Down Expand Up @@ -334,7 +334,7 @@
</price-per-item>
{%- endif -%}
</div>
<div class="quantity__rules caption no-js-hidden">
<div class="quantity__rules caption no-js-hidden" id="Quantity-Rules-{{ section.id }}">
{%- if product.selected_or_first_available_variant.quantity_rule.increment > 1 -%}
<span class="divider">
{{-
Expand Down
8 changes: 4 additions & 4 deletions sections/quick-order-list.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@
</span>
</div>
<div class="quick-order-list__total-items">
<h3>
<span>
{{ items_in_cart }}
</h3>
</span>
<p class="h5">{{ 'sections.quick_order_list.total_items' | t }}</p>
</div>
<div class="quick-order-list-total__price">
Expand All @@ -172,12 +172,12 @@
</button>
</noscript>
<div class="totals__product-total">
<h3 class="totals__subtotal-value">
<span class="totals__subtotal-value">
{% comment %} TODO: enable theme-check once `line_items_for` is accepted as valid filter {% endcomment %}
{% # theme-check-disable %}
{{ cart | line_items_for: product | sum: 'original_line_price' | money }}
{% # theme-check-enable %}
</h3>
</span>
<p class="totals__subtotal h5">{{ 'sections.quick_order_list.product_total' | t }}</p>
</div>
<small class="tax-note caption-large rte">
Expand Down
2 changes: 1 addition & 1 deletion snippets/quick-order-list-row.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
</button>
{%- endif -%}
{%- if variant.available == false or quantity_rule_soldout -%}
<span class="variant-item__sold-out h4"> {{ 'products.product.sold_out' | t }} </span>
<span class="variant-item__sold-out"> {{ 'products.product.sold_out' | t }} </span>
{%- else -%}
{% comment %} TODO: Remove theme check {% endcomment %}
{% # theme-check-disable %}
Expand Down