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

feat: initial changes #3660

Closed
wants to merge 1 commit into from
Closed
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
13 changes: 11 additions & 2 deletions assets/product-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,9 @@ if (!customElements.get('product-info')) {
if (modalContent && newModalContent) modalContent.innerHTML = newModalContent.innerHTML;
}

setQuantityBoundries() {
setQuantityBoundries(html) {
const selection = html ? this.getSelectedVariant(html) : null;

const data = {
cartQuantity: this.quantityInput.dataset.cartQuantity ? parseInt(this.quantityInput.dataset.cartQuantity) : 0,
min: this.quantityInput.dataset.min ? parseInt(this.quantityInput.dataset.min) : 1,
Expand All @@ -319,6 +321,13 @@ if (!customElements.get('product-info')) {
};

let min = data.min;
let step = data.step;

if (['110 cm', '150 cm'].includes(selection?.option2) || !selection) {
min = 10;
step = 10;
}

const max = data.max === null ? data.max : data.max - data.cartQuantity;
if (max !== null) min = Math.min(min, max);
if (data.cartQuantity >= data.min) min = Math.min(min, data.step);
Expand Down Expand Up @@ -352,7 +361,7 @@ if (!customElements.get('product-info')) {

updateQuantityRules(sectionId, html) {
if (!this.quantityInput) return;
this.setQuantityBoundries();
this.setQuantityBoundries(html);

const quantityFormUpdated = html.getElementById(`Quantity-Form-${sectionId}`);
const selectors = ['.quantity__input', '.quantity__rules', '.quantity__label'];
Expand Down
4 changes: 2 additions & 2 deletions sections/header.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@
{
"type": "checkbox",
"id": "enable_country_selector",
"default": true,
"default": false,
"label": "t:sections.header.settings.enable_country_selector.label"
},
{
Expand All @@ -561,7 +561,7 @@
{
"type": "checkbox",
"id": "enable_language_selector",
"default": true,
"default": false,
"label": "t:sections.header.settings.enable_language_selector.label"
},
{
Expand Down
97 changes: 60 additions & 37 deletions sections/main-cart-items.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -240,43 +240,66 @@
{{- 'icon-info.svg' | inline_asset_content -}}
</button>
{%- endif -%}
<quantity-input class="quantity cart-quantity">
<button class="quantity__button" name="minus" type="button">
<span class="visually-hidden">
{{- 'products.product.quantity.decrease' | t: product: item.product.title | escape -}}
</span>
<span class="svg-wrapper">
{{- 'icon-minus.svg' | inline_asset_content -}}
</span>
</button>
<input
class="quantity__input"
data-quantity-variant-id="{{ item.variant.id }}"
type="number"
name="updates[]"
value="{{ item.quantity }}"
{% # theme-check-disable %}
data-cart-quantity="{{ cart | item_count_for_variant: item.variant.id }}"
min="0"
data-min="{{ item.variant.quantity_rule.min }}"
{% if item.variant.quantity_rule.max != null %}
max="{{ item.variant.quantity_rule.max }}"
{% endif %}
step="{{ item.variant.quantity_rule.increment }}"
{% # theme-check-enable %}
aria-label="{{ 'products.product.quantity.input_label' | t: product: item.product.title | escape }}"
id="Quantity-{{ item.index | plus: 1 }}"
data-index="{{ item.index | plus: 1 }}"
>
<button class="quantity__button" name="plus" type="button">
<span class="visually-hidden">
{{- 'products.product.quantity.increase' | t: product: item.product.title | escape -}}
</span>
<span class="svg-wrapper">
{{- 'icon-plus.svg' | inline_asset_content -}}
</span>
</button>
</quantity-input>
{% assign meterOptions = '110 cm,150 cm' | split: ',' %}
{% assign option2 = item.options_with_values[1].value | string %}
{% assign is_option_in_meterOptions = false %}

{% for meter in meterOptions %}
{% if meter == option2 %}
{% assign is_option_in_meterOptions = true %}
{% endif %}
{% endfor %}
<div>
{% if is_option_in_meterOptions %}
Länge in cm
{% endif %}
<quantity-input class="quantity cart-quantity">
<button class="quantity__button" name="minus" type="button">
<span class="visually-hidden">
{{-
'products.product.quantity.decrease'
| t: product: item.product.title
| escape
-}}
</span>
<span class="svg-wrapper">
{{- 'icon-minus.svg' | inline_asset_content -}}
</span>
</button>

<input
class="quantity__input"
data-quantity-variant-id="{{ item.variant.id }}"
type="number"
name="updates[]"
value="{{ item.quantity }}"
{% # theme-check-disable %}
data-cart-quantity="{{ cart | item_count_for_variant: item.variant.id }}"
min="0"
data-min="{{ item.variant.quantity_rule.min }}"
{% if item.variant.quantity_rule.max != null %}
max="{{ item.variant.quantity_rule.max }}"
{% endif %}
step="{{ item.variant.quantity_rule.increment }}"
{% # theme-check-enable %}
aria-label="{{ 'products.product.quantity.input_label' | t: product: item.product.title | escape }}"
id="Quantity-{{ item.index | plus: 1 }}"
data-index="{{ item.index | plus: 1 }}"
>
<button class="quantity__button" name="plus" type="button">
<span class="visually-hidden">
{{-
'products.product.quantity.increase'
| t: product: item.product.title
| escape
-}}
</span>
<span class="svg-wrapper">
{{- 'icon-plus.svg' | inline_asset_content -}}
</span>
</button>
</quantity-input>
</div>
</div>
<cart-remove-button
id="Remove-{{ item.index | plus: 1 }}"
Expand Down
39 changes: 35 additions & 4 deletions sections/main-product.liquid
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
{% assign meterOptions = '110 cm,150 cm' | split: ',' %}
{% assign option2 = product.selected_or_first_available_variant.option2 | string %}
{% assign is_option_in_meterOptions = false %}

{% for meter in meterOptions %}
{% if meter == option2 %}
{% assign is_option_in_meterOptions = true %}
{% endif %}
{% endfor %}
<product-info
id="MainProduct-{{ section.id }}"
class="section-{{ section.id }}-padding gradient color-{{ section.settings.color_scheme }}"
Expand Down Expand Up @@ -240,7 +249,11 @@
-%}
{% # theme-check-enable %}
<label class="quantity__label form__label" for="Quantity-{{ section.id }}">
{{ 'products.product.quantity.label' | t }}
{% if is_option_in_meterOptions %}
Länge in cm
{% else %}
{{ 'products.product.quantity.label' | t }}
{% endif %}
<span class="quantity__rules-cart{% if cart_qty == 0 %} hidden{% endif %}">
{%- render 'loading-spinner' -%}
<span
Expand All @@ -267,13 +280,31 @@
id="Quantity-{{ section.id }}"
data-cart-quantity="{{ cart_qty }}"
data-min="{{ product.selected_or_first_available_variant.quantity_rule.min }}"
min="{{ product.selected_or_first_available_variant.quantity_rule.min }}"
min="
{%- if is_option_in_meterOptions -%}
10
{%- else -%}
1
{%- endif -%}
"
{% if product.selected_or_first_available_variant.quantity_rule.max != null %}
data-max="{{ product.selected_or_first_available_variant.quantity_rule.max }}"
max="{{ product.selected_or_first_available_variant.quantity_rule.max }}"
{% endif %}
step="{{ product.selected_or_first_available_variant.quantity_rule.increment }}"
value="{{ product.selected_or_first_available_variant.quantity_rule.min }}"
step="
{%- if is_option_in_meterOptions -%}
10
{%- else -%}
1
{%- endif -%}
"
value="
{%- if is_option_in_meterOptions -%}
10
{%- else -%}
1
{%- endif -%}
"
form="{{ product_form_id }}"
>
<button class="quantity__button" name="plus" type="button">
Expand Down
18 changes: 16 additions & 2 deletions snippets/price.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,22 @@
endif

assign compare_at_price = target.compare_at_price
assign price = target.price | default: 1999
-%}
{% comment %}
THE NEXT 3 LINES CHANGED FROM
"assign price = target.price | default: 1999
assign price_min = product.price_min
assign price_max = product.price_max
assign price_max = product.price_max"
TO
"assign price = target.price | times: 100
assign price_min = product.price_min | times: 100
assign price_max = product.price_max | times: 100"
to recalculate the price from cm to m price
{% endcomment %}
{%- liquid
assign price = target.price | times: 100
assign price_min = product.price_min | times: 100
assign price_max = product.price_max | times: 100
assign available = target.available | default: false
assign money_price = price | money
assign money_price_min = price_min | money
Expand All @@ -38,6 +51,7 @@
if target == product and product.price_varies
assign money_price = 'products.product.price.from_price_html' | t: price: money_price
endif

-%}

{%- unless target == null and placeholder == null -%}
Expand Down
29 changes: 7 additions & 22 deletions templates/cart.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
"cart-items": {
"type": "main-cart-items",
"settings": {
"color_scheme": "scheme-1",
"padding_top": 36,
"padding_bottom": 36
}
},
"cart-footer": {
"type": "main-cart-footer",
"settings": {
"color_scheme": "scheme-1",
"padding_top": 20,
"padding_bottom": 40
},
"blocks": {
"subtotal": {
"type": "subtotal",
Expand All @@ -25,31 +31,10 @@
"subtotal",
"buttons"
]
},
"featured-collection": {
"type": "featured-collection",
"settings": {
"title": "Featured collection",
"heading_size": "h2",
"collection": "all",
"products_to_show": 4,
"columns_desktop": 4,
"color_scheme": "scheme-1",
"show_view_all": true,
"swipe_on_mobile": false,
"image_ratio": "square",
"show_secondary_image": false,
"show_vendor": false,
"show_rating": false,
"columns_mobile": "2",
"padding_top": 36,
"padding_bottom": 36
}
}
},
"order": [
"cart-items",
"cart-footer",
"featured-collection"
"cart-footer"
]
}
4 changes: 4 additions & 0 deletions templates/collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@
"settings": {
"products_per_page": 16,
"columns_desktop": 4,
"color_scheme": "scheme-1",
"image_ratio": "adapt",
"image_shape": "default",
"show_secondary_image": false,
"show_vendor": false,
"show_rating": false,
"quick_add": "none",
"enable_filtering": true,
"filter_type": "horizontal",
"enable_sorting": true,
"columns_mobile": "2",
"padding_top": 36,
Expand Down
6 changes: 5 additions & 1 deletion templates/customers/account.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"sections": {
"main": {
"type": "main-account"
"type": "main-account",
"settings": {
"padding_top": 36,
"padding_bottom": 36
}
}
},
"order": [
Expand Down
6 changes: 5 additions & 1 deletion templates/customers/activate_account.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"sections": {
"main": {
"type": "main-activate-account"
"type": "main-activate-account",
"settings": {
"padding_top": 36,
"padding_bottom": 36
}
}
},
"order": [
Expand Down
6 changes: 5 additions & 1 deletion templates/customers/addresses.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"sections": {
"main": {
"type": "main-addresses"
"type": "main-addresses",
"settings": {
"padding_top": 36,
"padding_bottom": 36
}
}
},
"order": [
Expand Down
7 changes: 6 additions & 1 deletion templates/customers/login.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{
"sections": {
"main": {
"type": "main-login"
"type": "main-login",
"settings": {
"enable_shop_login_button": "true",
"padding_top": 36,
"padding_bottom": 36
}
}
},
"order": [
Expand Down
6 changes: 5 additions & 1 deletion templates/customers/order.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"sections": {
"main": {
"type": "main-order"
"type": "main-order",
"settings": {
"padding_top": 36,
"padding_bottom": 36
}
}
},
"order": [
Expand Down
6 changes: 5 additions & 1 deletion templates/customers/register.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"sections": {
"main": {
"type": "main-register"
"type": "main-register",
"settings": {
"padding_top": 36,
"padding_bottom": 36
}
}
},
"order": [
Expand Down
Loading
Loading