Skip to content

Commit

Permalink
Add Volume Pricing and Qty Rules Popover to Quick Add Bulk Input (#3393)
Browse files Browse the repository at this point in the history
  • Loading branch information
sofiamatulis committed Apr 5, 2024
1 parent 5ad5d44 commit 34ec5b9
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 3 deletions.
33 changes: 33 additions & 0 deletions assets/component-card.css
Expand Up @@ -148,6 +148,34 @@
color: rgba(var(--color-foreground), 0.75);
}

.card__information-volume-pricing-note--button {
position: relative;
z-index: 1;
cursor: pointer;
padding: 0;
margin: 0;
}

.card__information-volume-pricing-note--button:hover {
text-decoration: underline;
}

.card__information-volume-pricing-note--button + .global-settings-popup.quantity-popover__info {
transform: initial;
top: auto;
bottom: 3.5rem;
}

.card-information quantity-popover volume-pricing {
margin-top: 4.2rem;
}

@media screen and (min-width: 990px) {
.card-information quantity-popover volume-pricing {
margin-top: 0;
}
}

@media screen and (min-width: 750px) {
.card__information {
padding-bottom: 1.7rem;
Expand Down Expand Up @@ -370,6 +398,11 @@
margin-top: 0.4rem;
}

/* Specificity needed due to the changes below */
.card-information > *:not(.visually-hidden:first-child) + quantity-popover:not(.rating):not(.card__information-volume-pricing-note), .card-information .card__information-volume-pricing-note.card__information-volume-pricing-note--button {
margin-top: 0;
}

.card-information>*:not(.visually-hidden:first-child)+*:not(.rating):not(.card__information-volume-pricing-note) {
margin-top: 0.7rem;
}
Expand Down
90 changes: 87 additions & 3 deletions snippets/card-product.liquid
Expand Up @@ -205,9 +205,93 @@

{% render 'price', product: card_product, price_class: '', show_compare_at_price: true %}
{%- if card_product.quantity_price_breaks_configured? -%}
<div class="card__information-volume-pricing-note">
<span class="caption">{{ 'products.product.volume_pricing.note' | t }}</span>
</div>
{% if card_product.variants.size == 1 and quick_add == 'bulk' %}
{% liquid
assign has_qty_rules = false
if variant.quantity_rule.increment > 1 or variant.quantity_rule.min > 1 or variant.quantity_rule.max != null
assign has_qty_rules = true
endif
%}
<quantity-popover>
<button class="card__information-volume-pricing-note card__information-volume-pricing-note--button quantity-popover__info-button--icon-only button button button--tertiary medium-hide small-hide">
<span class="caption">{{ 'products.product.volume_pricing.note' | t }}</span>
</button>
<button class="card__information-volume-pricing-note card__information-volume-pricing-note--button quantity-popover__info-button--icon-with-label button button--tertiary large-up-hide">
<span class="caption">{{ 'products.product.volume_pricing.note' | t }}</span>
</button>
{% else %}
<div class="card__information-volume-pricing-note">
<span class="caption">{{ 'products.product.volume_pricing.note' | t }}</span>
</div>
{% endif %}
{% if card_product.variants.size == 1 and quick_add == 'bulk' %}
<div
class="global-settings-popup quantity-popover__info"
tabindex="-1"
hidden
id="quantity-popover-info-{{ card_product.selected_or_first_available_variant.id }}"
>
{%- if has_qty_rules -%}
<div class="quantity__rules caption no-js-hidden">
{%- if card_product.selected_or_first_available_variant.quantity_rule.increment > 1 -%}
<span class="divider">
{{-
'products.product.quantity.multiples_of'
| t: quantity: card_product.selected_or_first_available_variant.quantity_rule.increment
-}}
</span>
{%- endif -%}
{%- if variant.quantity_rule.min > 1 -%}
<span class="divider">
{{-
'products.product.quantity.min_of'
| t: quantity: card_product.selected_or_first_available_variant.quantity_rule.min
-}}
</span>
{%- endif -%}
{%- if variant.quantity_rule.max != null -%}
<span class="divider">
{{-
'products.product.quantity.max_of'
| t: quantity: card_product.selected_or_first_available_variant.quantity_rule.max
-}}
</span>
{%- endif -%}
</div>
{%- endif -%}
<button
class="button-close button button--tertiary large-up-hide"
type="button"
aria-label="{{ 'accessibility.close' | t }}"
>
{%- render 'icon-close' -%}
</button>
{%- if card_product.selected_or_first_available_variant.quantity_price_breaks.size > 0 -%}
<volume-pricing class="parent-display">
<ul class="list-unstyled">
<li>
<span>{{ card_product.selected_or_first_available_variant.quantity_rule.min }}+</span>
{%- assign price = card_product.selected_or_first_available_variant.price
| money_with_currency
-%}
<span>{{ 'sections.quick_order_list.each' | t: money: price }}</span>
</li>
{%- for price_break in card_product.selected_or_first_available_variant.quantity_price_breaks -%}
<li>
<span>
{{- price_break.minimum_quantity -}}
<span aria-hidden="true">+</span></span
>
{%- assign price = price_break.price | money_with_currency -%}
<span> {{ 'sections.quick_order_list.each' | t: money: price }}</span>
</li>
{%- endfor -%}
</ul>
</volume-pricing>
{%- endif -%}
</div>
</quantity-popover>
{% endif %}
{%- endif -%}
</div>
</div>
Expand Down

0 comments on commit 34ec5b9

Please sign in to comment.