Ajustes antes de produccion
This commit is contained in:
@@ -21,7 +21,11 @@
|
||||
endif
|
||||
endif
|
||||
|
||||
if section.settings.promo_link != blank
|
||||
assign promo_href = section.settings.promo_link
|
||||
if promo_href == blank
|
||||
assign promo_href = more_url
|
||||
endif
|
||||
if promo_href != blank
|
||||
assign promo_tag = 'a'
|
||||
else
|
||||
assign promo_tag = 'div'
|
||||
@@ -71,7 +75,7 @@
|
||||
<{{ promo_tag }}
|
||||
class="bestsellers__promo"
|
||||
{% if promo_tag == 'a' %}
|
||||
href="{{ section.settings.promo_link }}"
|
||||
href="{{ promo_href }}"
|
||||
{% endif %}
|
||||
>
|
||||
{% if section.settings.promo_image != blank %}
|
||||
@@ -103,11 +107,19 @@
|
||||
<div class="bestsellers__slider">
|
||||
<div class="bestsellers__viewport" data-viewport tabindex="0">
|
||||
<div class="bestsellers__track" data-track>
|
||||
{% assign shown = 0 %}
|
||||
{% if product_collection != blank and product_collection.products_count > 0 %}
|
||||
{% for product in product_collection.products limit: products_to_show %}
|
||||
{% render 'bestsellers-card', product: product, form_suffix: section.id %}
|
||||
{% for product in product_collection.products %}
|
||||
{% if product.available %}
|
||||
{% render 'bestsellers-card', product: product, form_suffix: section.id %}
|
||||
{% assign shown = shown | plus: 1 %}
|
||||
{% endif %}
|
||||
{% if shown >= products_to_show %}
|
||||
{% break %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% elsif request.design_mode %}
|
||||
{% endif %}
|
||||
{% if shown == 0 and request.design_mode %}
|
||||
<p class="bestsellers__empty">{{ 'bestsellers.empty' | t }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
@@ -164,7 +176,8 @@
|
||||
}
|
||||
|
||||
badge.textContent = String(count);
|
||||
link.setAttribute('aria-label', link.getAttribute('aria-label').replace(/\d+/, String(count)));
|
||||
const label = link.getAttribute('aria-label');
|
||||
if (label) link.setAttribute('aria-label', label.replace(/\d+/, String(count)));
|
||||
};
|
||||
|
||||
const updateArrows = (root) => {
|
||||
@@ -201,6 +214,28 @@
|
||||
root._bestsellersTimer = null;
|
||||
};
|
||||
|
||||
const mobileSlider = () => window.matchMedia('(max-width: 767px)').matches;
|
||||
|
||||
const slideStride = (viewport) => {
|
||||
const card = viewport.querySelector('.bestsellers__card');
|
||||
if (!card) return 0;
|
||||
const track = viewport.querySelector('[data-track]');
|
||||
const gap = track ? parseFloat(window.getComputedStyle(track).columnGap) || 0 : 0;
|
||||
return card.getBoundingClientRect().width + gap;
|
||||
};
|
||||
|
||||
const centerSlide = (viewport, index, behavior) => {
|
||||
const stride = slideStride(viewport);
|
||||
const count = viewport.querySelectorAll('.bestsellers__card').length;
|
||||
if (!stride || !count) return;
|
||||
const wrapped = ((index % count) + count) % count;
|
||||
const max = viewport.scrollWidth - viewport.clientWidth;
|
||||
viewport.scrollTo({
|
||||
left: Math.min(Math.max(wrapped * stride, 0), max),
|
||||
behavior,
|
||||
});
|
||||
};
|
||||
|
||||
const startAutoplay = (root) => {
|
||||
pauseAutoplay(root);
|
||||
if (reduceMotion.matches || root.dataset.paused === 'true') return;
|
||||
@@ -211,6 +246,16 @@
|
||||
const max = viewport.scrollWidth - viewport.clientWidth;
|
||||
if (max <= 2) return;
|
||||
|
||||
if (mobileSlider()) {
|
||||
const stride = slideStride(viewport);
|
||||
const count = viewport.querySelectorAll('.bestsellers__card').length;
|
||||
if (!stride || count < 2) return;
|
||||
const index = Math.round(viewport.scrollLeft / stride);
|
||||
const reduce = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||
centerSlide(viewport, index + 1 >= count ? 0 : index + 1, reduce ? 'auto' : 'smooth');
|
||||
return;
|
||||
}
|
||||
|
||||
if (viewport.scrollLeft >= max - 2) {
|
||||
viewport.scrollTo({ left: 0, behavior: 'smooth' });
|
||||
return;
|
||||
@@ -248,7 +293,10 @@
|
||||
const html = await response.text();
|
||||
const parsed = new DOMParser().parseFromString(html, 'text/html');
|
||||
const limit = Number(root.dataset.limit) || 8;
|
||||
const cards = Array.from(parsed.querySelectorAll('.bestsellers__card')).slice(0, limit);
|
||||
const cards = Array.from(parsed.querySelectorAll('.bestsellers__card')).filter((card) => {
|
||||
const button = card.querySelector('button[type="submit"]');
|
||||
return !button || !button.disabled;
|
||||
}).slice(0, limit);
|
||||
const track = root.querySelector('[data-track]');
|
||||
if (!track || !cards.length) {
|
||||
root.dataset.sorted = 'true';
|
||||
@@ -257,6 +305,8 @@
|
||||
|
||||
track.replaceChildren(...cards.map((card) => document.importNode(card, true)));
|
||||
applyWishlist(root);
|
||||
const loadedViewport = root.querySelector('[data-viewport]');
|
||||
if (loadedViewport && mobileSlider()) centerSlide(loadedViewport, 0, 'auto');
|
||||
updateArrows(root);
|
||||
root.dataset.sorted = 'true';
|
||||
startAutoplay(root);
|
||||
@@ -273,9 +323,17 @@
|
||||
if (!viewport) return;
|
||||
|
||||
applyWishlist(root);
|
||||
if (mobileSlider()) centerSlide(viewport, 0, 'auto');
|
||||
updateArrows(root);
|
||||
viewport.addEventListener('scroll', () => updateArrows(root), { passive: true });
|
||||
window.addEventListener('resize', () => updateArrows(root));
|
||||
window.addEventListener('resize', () => {
|
||||
if (mobileSlider()) {
|
||||
const stride = slideStride(viewport);
|
||||
const index = stride ? Math.round(viewport.scrollLeft / stride) : 0;
|
||||
centerSlide(viewport, index, 'auto');
|
||||
}
|
||||
updateArrows(root);
|
||||
});
|
||||
|
||||
root.addEventListener('mouseenter', () => {
|
||||
root.dataset.paused = 'true';
|
||||
@@ -369,6 +427,7 @@
|
||||
});
|
||||
|
||||
document.addEventListener('submit', async (event) => {
|
||||
if (event.defaultPrevented) return;
|
||||
const form = event.target;
|
||||
if (!(form instanceof HTMLFormElement) || !form.classList.contains('bestsellers__form')) return;
|
||||
|
||||
@@ -409,10 +468,10 @@
|
||||
return;
|
||||
}
|
||||
|
||||
document.dispatchEvent(new CustomEvent('season:cart:open'));
|
||||
const cartResponse = await fetch(root.dataset.cartUrl, { headers: { Accept: 'application/json' } });
|
||||
const cart = await cartResponse.json();
|
||||
if (typeof cart.item_count === 'number') setCartCount(cart.item_count);
|
||||
document.dispatchEvent(new CustomEvent('season:cart:open'));
|
||||
} catch (error) {
|
||||
form.submit();
|
||||
} finally {
|
||||
|
||||
+31
-28
@@ -100,31 +100,7 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{% if threshold > 0 %}
|
||||
<div class="cart-drawer__shipping">
|
||||
<p>
|
||||
{% if unlocked %}
|
||||
{{ 'cart_drawer.unlocked' | t }}
|
||||
{% else %}
|
||||
{{ 'cart_drawer.remaining_before' | t }}
|
||||
{{ remaining | money_without_trailing_zeros }}
|
||||
{{ 'cart_drawer.remaining_after' | t }}
|
||||
<span>{{ 'cart_drawer.free' | t }}</span>
|
||||
{% endif %}
|
||||
</p>
|
||||
<div
|
||||
class="cart-drawer__bar"
|
||||
style="--progress: {{ progress }}%;"
|
||||
role="progressbar"
|
||||
aria-valuemin="0"
|
||||
aria-valuemax="100"
|
||||
aria-valuenow="{{ progress }}"
|
||||
aria-label="{{ 'cart_drawer.shipping_progress' | t }}"
|
||||
>
|
||||
<span class="cart-drawer__bar-fill"></span>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
<div class="cart-drawer__items">
|
||||
{% if cart.item_count == 0 %}
|
||||
@@ -142,7 +118,7 @@
|
||||
{% unless item.variant.title == 'Default Title' %}
|
||||
<p class="cart-drawer__variant">{{ item.variant.title }}</p>
|
||||
{% endunless %}
|
||||
<p class="cart-drawer__price">{{ item.final_line_price | money_without_trailing_zeros }}</p>
|
||||
<p class="cart-drawer__price">{{ item.final_line_price | money_without_trailing_zeros }}{% render 'line-purchase-type', item: item %}</p>
|
||||
<div class="cart-drawer__qty">
|
||||
<button
|
||||
type="button"
|
||||
@@ -329,6 +305,8 @@
|
||||
const refresh = async (shouldOpen) => {
|
||||
const drawer = getDrawer();
|
||||
if (!drawer) return;
|
||||
// Combine duplicate lines of the same product/purchase type before rendering.
|
||||
if (window.seasonsMergeCartLines) await window.seasonsMergeCartLines();
|
||||
const currentId = ++requestId;
|
||||
|
||||
try {
|
||||
@@ -414,10 +392,33 @@
|
||||
const key = qtyButton.dataset.lineKey;
|
||||
const quantity = Number(qtyButton.dataset.quantity);
|
||||
if (!key || Number.isNaN(quantity)) return;
|
||||
// Optimistic UI: collapse the line right away instead of waiting for Shopify.
|
||||
const line = qtyButton.closest('.cart-drawer__line');
|
||||
if (quantity === 0 && line) line.classList.add('is-removing');
|
||||
drawer.classList.add('is-busy');
|
||||
try {
|
||||
const ok = await postJson(drawer.dataset.changeUrl, { id: key, quantity });
|
||||
if (ok) await refresh(false);
|
||||
// One round trip: change the line and get the re-rendered drawer (bundled section rendering).
|
||||
const sectionId = drawer.dataset.sectionId;
|
||||
const response = await fetch(drawer.dataset.changeUrl, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
||||
body: JSON.stringify({ id: key, quantity, sections: sectionId, sections_url: window.location.pathname }),
|
||||
});
|
||||
if (!response.ok) throw new Error('change failed');
|
||||
const data = await response.json();
|
||||
const html = data.sections && data.sections[sectionId];
|
||||
const fresh = html ? new DOMParser().parseFromString(html, 'text/html').querySelector('[data-cart-drawer-content]') : null;
|
||||
const current = getDrawer()?.querySelector('[data-cart-drawer-content]');
|
||||
if (fresh && current) {
|
||||
++requestId;
|
||||
current.replaceWith(fresh);
|
||||
setCount(Number(fresh.dataset.itemCount || '0'));
|
||||
} else {
|
||||
await refresh(false);
|
||||
}
|
||||
} catch (error) {
|
||||
line?.classList.remove('is-removing');
|
||||
await refresh(false);
|
||||
} finally {
|
||||
getDrawer()?.classList.remove('is-busy');
|
||||
}
|
||||
@@ -430,6 +431,8 @@
|
||||
if (!(form instanceof HTMLFormElement)) return;
|
||||
const action = form.getAttribute('action') || '';
|
||||
if (!action.includes('/cart/add')) return;
|
||||
// Forms with their own add-to-cart handler open the drawer themselves (season:cart:open).
|
||||
if (form.matches('.hero__form, .learn__form, .testimonials__form, .bestsellers__form, [data-collection-card]')) return;
|
||||
if (event.submitter && event.submitter.closest('.shopify-payment-button')) return;
|
||||
if (event.submitter && event.submitter.hasAttribute('data-buy')) return;
|
||||
|
||||
|
||||
+2
-27
@@ -55,7 +55,7 @@
|
||||
{% if item.original_line_price > item.final_line_price %}
|
||||
<s>{{ item.original_line_price | money_without_trailing_zeros }}</s>
|
||||
{% endif %}
|
||||
</p>
|
||||
{% render 'line-purchase-type', item: item %}</p>
|
||||
<div class="cart-page__qty">
|
||||
{% if item.quantity > 1 %}
|
||||
<a
|
||||
@@ -83,32 +83,7 @@
|
||||
</div>
|
||||
|
||||
<aside class="cart-page__summary">
|
||||
{% if threshold > 0 %}
|
||||
<div class="cart-page__shipping">
|
||||
<p>
|
||||
{% if unlocked %}
|
||||
{{ 'cart_drawer.unlocked' | t }}
|
||||
{% else %}
|
||||
{{ 'cart_drawer.remaining_before' | t }}
|
||||
{{ remaining | money_without_trailing_zeros }}
|
||||
{{ 'cart_drawer.remaining_after' | t }}
|
||||
<span>{{ 'cart_drawer.free' | t }}</span>
|
||||
{% endif %}
|
||||
</p>
|
||||
<div
|
||||
class="cart-page__bar"
|
||||
style="--progress: {{ progress }}%;"
|
||||
role="progressbar"
|
||||
aria-valuemin="0"
|
||||
aria-valuemax="100"
|
||||
aria-valuenow="{{ progress }}"
|
||||
aria-label="{{ 'cart_drawer.shipping_progress' | t }}"
|
||||
>
|
||||
<span class="cart-page__bar-fill"></span>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
<p class="cart-page__subtotal">
|
||||
<span>{{ 'cart_drawer.subtotal' | t }}</span>
|
||||
<strong>{{ cart.total_price | money_without_trailing_zeros }}</strong>
|
||||
|
||||
+72
-140
@@ -10,51 +10,102 @@
|
||||
endif
|
||||
|
||||
assign banner_title = collection.metafields.custom.banner_titulo.value | default: collection.metafields.custom.banner_title.value
|
||||
if banner_title == blank
|
||||
assign banner_title = collection.title
|
||||
endif
|
||||
|
||||
assign banner_asset = blank
|
||||
assign directory_title = blank
|
||||
assign directory_text = blank
|
||||
case collection.handle
|
||||
when 'all-products'
|
||||
assign banner_asset = 'banner-todos-productos.avif'
|
||||
when 'proteccion-solar-1'
|
||||
assign banner_asset = 'banner-proteccion-solar.avif'
|
||||
assign directory_title = 'category_directory.sun_title' | t
|
||||
assign directory_text = 'category_directory.sun_text' | t
|
||||
when '4-protege-bloqueadores-solares'
|
||||
assign banner_asset = 'banner-protectores.avif'
|
||||
assign directory_title = 'category_directory.protect_title' | t
|
||||
assign directory_text = 'category_directory.protect_text' | t
|
||||
when 'hidratantes'
|
||||
assign banner_asset = 'banner-hidratantes.avif'
|
||||
assign directory_title = 'category_directory.moisturizers_title' | t
|
||||
assign directory_text = 'category_directory.moisturizers_text' | t
|
||||
when 'limpiadores'
|
||||
assign banner_asset = 'banner-limpiadores.avif'
|
||||
assign directory_title = 'category_directory.cleansers_title' | t
|
||||
assign directory_text = 'category_directory.cleansers_text' | t
|
||||
when 'mascarillas'
|
||||
assign banner_asset = 'banner-mascarillas.avif'
|
||||
assign directory_title = 'category_directory.masks_title' | t
|
||||
assign directory_text = 'category_directory.masks_text' | t
|
||||
when 'serum'
|
||||
assign banner_asset = 'banner-serums.avif'
|
||||
assign directory_title = 'category_directory.serum_title' | t
|
||||
assign directory_text = 'category_directory.serum_text' | t
|
||||
when '1-limpia'
|
||||
assign banner_asset = 'banner-limpia.avif'
|
||||
assign directory_title = 'category_directory.clean_title' | t
|
||||
assign directory_text = 'category_directory.clean_text' | t
|
||||
when '2-trata'
|
||||
assign banner_asset = 'banner-trata.avif'
|
||||
assign directory_title = 'category_directory.treat_title' | t
|
||||
assign directory_text = 'category_directory.treat_text' | t
|
||||
when '3-hidrata'
|
||||
assign banner_asset = 'banner-hidrata.avif'
|
||||
assign directory_title = 'category_directory.hydrate_step_title' | t
|
||||
assign directory_text = 'category_directory.hydrate_step_text' | t
|
||||
when 'kits-skincare-facial'
|
||||
assign banner_asset = 'banner-kits.avif'
|
||||
when 'piel-mixta-grasa'
|
||||
assign banner_asset = 'banner-piel-mixta-grasa.avif'
|
||||
assign directory_title = 'category_directory.combination_title' | t
|
||||
assign directory_text = 'category_directory.combination_text' | t
|
||||
when 'piel-grasa'
|
||||
assign banner_asset = 'banner-piel-grasa.avif'
|
||||
assign directory_title = 'category_directory.oily_title' | t
|
||||
assign directory_text = 'category_directory.oily_text' | t
|
||||
when 'piel-seca-1'
|
||||
assign banner_asset = 'banner-piel-seca.avif'
|
||||
assign directory_title = 'category_directory.dry_title' | t
|
||||
assign directory_text = 'category_directory.dry_text' | t
|
||||
when 'control-grasa'
|
||||
assign banner_asset = 'banner-control-grasa.avif'
|
||||
assign directory_title = 'category_directory.oil_title' | t
|
||||
assign directory_text = 'category_directory.oil_text' | t
|
||||
when 'acne-1'
|
||||
assign banner_asset = 'banner-preocupacion-acne.avif'
|
||||
assign directory_title = 'category_directory.acne_title' | t
|
||||
assign directory_text = 'category_directory.acne_text' | t
|
||||
when 'hidratacion'
|
||||
assign banner_asset = 'banner-preocupacion-hidratacion.avif'
|
||||
assign directory_title = 'category_directory.hydration_title' | t
|
||||
assign directory_text = 'category_directory.hydration_text' | t
|
||||
when 'antiedad-1'
|
||||
assign banner_asset = 'banner-antiedad.avif'
|
||||
assign directory_title = 'category_directory.aging_title' | t
|
||||
assign directory_text = 'category_directory.aging_text' | t
|
||||
when 'aclarar'
|
||||
assign banner_asset = 'banner-manchas.avif'
|
||||
assign directory_title = 'category_directory.spots_title' | t
|
||||
assign directory_text = 'category_directory.spots_text' | t
|
||||
endcase
|
||||
|
||||
if banner_title == blank
|
||||
if directory_title != blank
|
||||
assign banner_title = directory_title
|
||||
else
|
||||
assign banner_title = collection.title
|
||||
endif
|
||||
endif
|
||||
|
||||
assign banner_text = collection.metafields.custom.banner_texto.value | default: collection.metafields.custom.banner_text.value
|
||||
assign banner_text_is_html = false
|
||||
if banner_text == blank
|
||||
assign banner_text = collection.description
|
||||
assign banner_text_is_html = true
|
||||
if directory_text != blank
|
||||
assign banner_text = directory_text
|
||||
else
|
||||
assign banner_text = collection.description
|
||||
assign banner_text_is_html = true
|
||||
endif
|
||||
endif
|
||||
|
||||
assign grid_image = collection.metafields.custom.banner_listado.value | default: collection.metafields.custom.banner_grid.value
|
||||
@@ -91,16 +142,10 @@
|
||||
endif
|
||||
|
||||
assign current_sort = collection.sort_by | default: collection.default_sort_by
|
||||
assign sort_label = blank
|
||||
for option in collection.sort_options
|
||||
if option.value == current_sort
|
||||
assign sort_label = option.name
|
||||
endif
|
||||
endfor
|
||||
%}
|
||||
|
||||
<section
|
||||
class="collection full-width"
|
||||
class="collection full-width{% if collection.handle == 'all' %} collection--all{% endif %}"
|
||||
data-collection
|
||||
data-cart-add-url="{{ routes.cart_add_url }}.js"
|
||||
>
|
||||
@@ -111,6 +156,8 @@
|
||||
<img
|
||||
class="collection__banner-image"
|
||||
src="{{ banner_asset | asset_url }}"
|
||||
srcset="{{ banner_asset | replace: '.avif', '-sm.avif' | asset_url }} 800w, {{ banner_asset | asset_url }} 1920w"
|
||||
sizes="(max-width: 767px) 100vw, 50vw"
|
||||
alt="{{ banner_title | escape }}"
|
||||
width="1600"
|
||||
height="667"
|
||||
@@ -161,133 +208,18 @@
|
||||
{% endif %}
|
||||
|
||||
<div class="collection__body">
|
||||
<div class="collection__bar">
|
||||
<div class="collection__tools">
|
||||
<button class="collection__tool" type="button" data-filter-toggle aria-expanded="false" aria-controls="collection-filters">
|
||||
<svg width="25" height="25" viewBox="0 0 25 25" aria-hidden="true" focusable="false">
|
||||
<path d="M4 7.5h17M4 12.5h17M4 17.5h17" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/>
|
||||
<circle cx="9" cy="7.5" r="2.1" fill="#f9f9fa" stroke="currentColor" stroke-width="1.4"/>
|
||||
<circle cx="16" cy="12.5" r="2.1" fill="#f9f9fa" stroke="currentColor" stroke-width="1.4"/>
|
||||
<circle cx="11" cy="17.5" r="2.1" fill="#f9f9fa" stroke="currentColor" stroke-width="1.4"/>
|
||||
</svg>
|
||||
{{ 'collection_page.filters' | t }}
|
||||
</button>
|
||||
<button class="collection__tool" type="button" data-sort-toggle aria-expanded="false" aria-controls="collection-sort">
|
||||
{{ 'collection_page.sort' | t: sort: sort_label }}
|
||||
</button>
|
||||
</div>
|
||||
<p class="collection__count">{{ 'collection_page.products' | t: count: collection.products_count }}</p>
|
||||
</div>
|
||||
|
||||
<div class="collection__drawer" id="collection-filters" data-filter-panel aria-hidden="true">
|
||||
<button class="collection__drawer-backdrop" type="button" data-filter-close tabindex="-1" aria-label="{{ 'collection_page.close_filters' | t }}"></button>
|
||||
<div class="collection__drawer-panel" role="dialog" aria-modal="true" aria-labelledby="collection-filters-title">
|
||||
<div class="collection__drawer-head">
|
||||
<h2 id="collection-filters-title" class="collection__drawer-title">{{ 'collection_page.filters' | t }}</h2>
|
||||
<button class="collection__drawer-close" type="button" data-filter-close aria-label="{{ 'collection_page.close_filters' | t }}">
|
||||
<svg width="14" height="14" viewBox="0 0 14 14" aria-hidden="true" focusable="false">
|
||||
<path d="M2 2l10 10M12 2L2 12" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
{% if collection.filters.size > 0 %}
|
||||
<form class="collection__filter-form" action="{{ collection.url }}" method="get">
|
||||
{% if current_sort != blank %}
|
||||
<input type="hidden" name="sort_by" value="{{ current_sort }}">
|
||||
{% endif %}
|
||||
<div class="collection__filter-groups">
|
||||
{% for filter in collection.filters %}
|
||||
<fieldset class="collection__filter">
|
||||
<legend>{{ filter.label | escape }}</legend>
|
||||
{% case filter.type %}
|
||||
{% when 'price_range' %}
|
||||
<div class="collection__price">
|
||||
<input
|
||||
type="number"
|
||||
name="{{ filter.min_value.param_name }}"
|
||||
{% if filter.min_value.value %}value="{{ filter.min_value.value | divided_by: 100.0 }}"{% endif %}
|
||||
min="0"
|
||||
placeholder="0"
|
||||
>
|
||||
<input
|
||||
type="number"
|
||||
name="{{ filter.max_value.param_name }}"
|
||||
{% if filter.max_value.value %}value="{{ filter.max_value.value | divided_by: 100.0 }}"{% endif %}
|
||||
min="0"
|
||||
placeholder="{{ filter.range_max | divided_by: 100.0 }}"
|
||||
>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="collection__options">
|
||||
{% for value in filter.values %}
|
||||
<label class="collection__option">
|
||||
<input
|
||||
type="checkbox"
|
||||
name="{{ value.param_name }}"
|
||||
value="{{ value.value }}"
|
||||
{% if value.active %}checked{% endif %}
|
||||
{% if value.count == 0 and value.active == false %}disabled{% endif %}
|
||||
>
|
||||
<span>{{ value.label | escape }} ({{ value.count }})</span>
|
||||
</label>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endcase %}
|
||||
</fieldset>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="collection__filter-actions">
|
||||
<button class="collection__apply" type="submit">{{ 'collection_page.apply' | t }}</button>
|
||||
<a class="collection__clear" href="{{ collection.url }}">{{ 'collection_page.clear' | t }}</a>
|
||||
</div>
|
||||
</form>
|
||||
{% else %}
|
||||
<p class="collection__none">{{ 'collection_page.no_filters' | t }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="collection__drawer" id="collection-sort" data-sort-panel aria-hidden="true">
|
||||
<button class="collection__drawer-backdrop" type="button" data-sort-close tabindex="-1" aria-label="{{ 'collection_page.close_sort' | t }}"></button>
|
||||
<div class="collection__drawer-panel" role="dialog" aria-modal="true" aria-labelledby="collection-sort-title">
|
||||
<div class="collection__drawer-head">
|
||||
<h2 id="collection-sort-title" class="collection__drawer-title">{{ 'collection_page.sort_title' | t }}</h2>
|
||||
<button class="collection__drawer-close" type="button" data-sort-close aria-label="{{ 'collection_page.close_sort' | t }}">
|
||||
<svg width="14" height="14" viewBox="0 0 14 14" aria-hidden="true" focusable="false">
|
||||
<path d="M2 2l10 10M12 2L2 12" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<form class="collection__sort-form" action="{{ collection.url }}" method="get">
|
||||
{% for filter in collection.filters %}
|
||||
{% if filter.type == 'price_range' %}
|
||||
{% if filter.min_value.value %}
|
||||
<input type="hidden" name="{{ filter.min_value.param_name }}" value="{{ filter.min_value.value }}">
|
||||
{% endif %}
|
||||
{% if filter.max_value.value %}
|
||||
<input type="hidden" name="{{ filter.max_value.param_name }}" value="{{ filter.max_value.value }}">
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% for value in filter.active_values %}
|
||||
<input type="hidden" name="{{ value.param_name }}" value="{{ value.value }}">
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<div class="collection__sort-list">
|
||||
{% for option in collection.sort_options %}
|
||||
<button
|
||||
class="collection__sort-option{% if option.value == current_sort %} is-current{% endif %}"
|
||||
type="submit"
|
||||
name="sort_by"
|
||||
value="{{ option.value }}"
|
||||
>
|
||||
{{ option.name | escape }}
|
||||
</button>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{%- capture collection_count -%}{{ 'collection_page.products' | t: count: collection.products_count }}{%- endcapture -%}
|
||||
{% render 'facets-toolbar',
|
||||
filters: collection.filters,
|
||||
sort_options: collection.sort_options,
|
||||
current_sort: current_sort,
|
||||
action_url: collection.url,
|
||||
sort_action_url: request.path,
|
||||
clear_url: collection.url,
|
||||
tag_list: collection.all_tags,
|
||||
tag_base_url: collection.url,
|
||||
count_label: collection_count
|
||||
%}
|
||||
|
||||
{% paginate collection.products by per_page %}
|
||||
{% if collection.products_count == 0 %}
|
||||
@@ -318,7 +250,7 @@
|
||||
|
||||
{% for product in collection.products %}
|
||||
{% assign card_suffix = section.id | append: '-' | append: forloop.index %}
|
||||
{% render 'collection-card', product: product, form_suffix: card_suffix %}
|
||||
{% render 'collection-card', product: product, form_suffix: card_suffix, badge_mode: 'none' %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
+35
-31
@@ -1,40 +1,44 @@
|
||||
{% comment %}
|
||||
This section is used in the list-collections template to render a list of
|
||||
collections.
|
||||
|
||||
https://shopify.dev/docs/storefronts/themes/architecture/templates/collection
|
||||
Category directory used by the list-collections template.
|
||||
{% endcomment %}
|
||||
|
||||
<h1>{{ 'collections.title' | t }}</h1>
|
||||
<section class="category-directory full-width">
|
||||
<h1 class="category-directory__title">{{ 'category_directory.heading' | t }}</h1>
|
||||
|
||||
<div
|
||||
class="collections {{ section.settings.grid_item_width }}"
|
||||
style="--grid-gap: {{ section.settings.grid_gap }}px"
|
||||
>
|
||||
{% for collection in collections %}
|
||||
<a class="collection-card" href="{{ collection.url }}">
|
||||
{% if collection.featured_image %}
|
||||
{% render 'image',
|
||||
class: 'collection-card__image',
|
||||
image: collection.featured_image,
|
||||
width: 600,
|
||||
height: 600,
|
||||
crop: 'center'
|
||||
%}
|
||||
{% endif %}
|
||||
{% capture category_cards %}
|
||||
banner-limpia.avif|/collections/1-limpia|{{ 'category_directory.clean_title' | t }}|{{ 'category_directory.clean_text' | t }}
|
||||
---banner-trata.avif|/collections/2-trata|{{ 'category_directory.treat_title' | t }}|{{ 'category_directory.treat_text' | t }}
|
||||
---banner-hidrata.avif|/collections/3-hidrata|{{ 'category_directory.hydrate_step_title' | t }}|{{ 'category_directory.hydrate_step_text' | t }}
|
||||
---banner-protectores.avif|/collections/4-protege-bloqueadores-solares|{{ 'category_directory.protect_title' | t }}|{{ 'category_directory.protect_text' | t }}
|
||||
---banner-hidratantes.avif|/collections/hidratantes|{{ 'category_directory.moisturizers_title' | t }}|{{ 'category_directory.moisturizers_text' | t }}
|
||||
---banner-mascarillas.avif|/collections/mascarillas|{{ 'category_directory.masks_title' | t }}|{{ 'category_directory.masks_text' | t }}
|
||||
---banner-proteccion-solar.avif|/collections/proteccion-solar-1|{{ 'category_directory.sun_title' | t }}|{{ 'category_directory.sun_text' | t }}
|
||||
---banner-limpiadores.avif|/collections/limpiadores|{{ 'category_directory.cleansers_title' | t }}|{{ 'category_directory.cleansers_text' | t }}
|
||||
---banner-serums.avif|/collections/serum|{{ 'category_directory.serum_title' | t }}|{{ 'category_directory.serum_text' | t }}
|
||||
---banner-preocupacion-acne.avif|/collections/acne-1|{{ 'category_directory.acne_title' | t }}|{{ 'category_directory.acne_text' | t }}
|
||||
---banner-antiedad.avif|/collections/antiedad-1|{{ 'category_directory.aging_title' | t }}|{{ 'category_directory.aging_text' | t }}
|
||||
---banner-control-grasa.avif|/collections/control-grasa|{{ 'category_directory.oil_title' | t }}|{{ 'category_directory.oil_text' | t }}
|
||||
---banner-preocupacion-hidratacion.avif|/collections/hidratacion|{{ 'category_directory.hydration_title' | t }}|{{ 'category_directory.hydration_text' | t }}
|
||||
---banner-preocupacion-solar.avif|/collections/proteccion-solar-1|{{ 'category_directory.sun_title' | t }}|{{ 'category_directory.sun_text' | t }}
|
||||
---banner-manchas.avif|/collections/aclarar|{{ 'category_directory.spots_title' | t }}|{{ 'category_directory.spots_text' | t }}
|
||||
---banner-piel-grasa.avif|/collections/piel-grasa|{{ 'category_directory.oily_title' | t }}|{{ 'category_directory.oily_text' | t }}
|
||||
---banner-piel-mixta-grasa.avif|/collections/piel-mixta-grasa|{{ 'category_directory.combination_title' | t }}|{{ 'category_directory.combination_text' | t }}
|
||||
---banner-piel-seca.avif|/collections/piel-seca-1|{{ 'category_directory.dry_title' | t }}|{{ 'category_directory.dry_text' | t }}
|
||||
{% endcapture %}
|
||||
|
||||
<div class="collection-card__content">
|
||||
<p>{{ collection.title }}</p>
|
||||
|
||||
{% if collection.description %}
|
||||
<p>{{ collection.description | strip_html | truncatewords: 15 }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</a>
|
||||
{% assign category_rows = category_cards | split: '---' %}
|
||||
{% for category_row in category_rows %}
|
||||
{% assign category_parts = category_row | strip | split: '|' %}
|
||||
{% if category_parts.size > 3 %}
|
||||
{% render 'category-card',
|
||||
image: category_parts[0],
|
||||
url: category_parts[1],
|
||||
title: category_parts[2],
|
||||
text: category_parts[3]
|
||||
%}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
{% schema %}
|
||||
{
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
/*
|
||||
* ------------------------------------------------------------
|
||||
* IMPORTANT: The contents of this file are auto-generated.
|
||||
*
|
||||
* This file may be updated by the Shopify admin theme editor
|
||||
* or related systems. Please exercise caution as any changes
|
||||
* made to this file may be overwritten.
|
||||
* ------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
"type": "footer",
|
||||
"name": "t:general.footer",
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
/*
|
||||
* ------------------------------------------------------------
|
||||
* IMPORTANT: The contents of this file are auto-generated.
|
||||
*
|
||||
* This file may be updated by the Shopify admin theme editor
|
||||
* or related systems. Please exercise caution as any changes
|
||||
* made to this file may be overwritten.
|
||||
* ------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
"type": "header",
|
||||
"name": "t:general.header",
|
||||
|
||||
+296
-22
@@ -239,7 +239,7 @@
|
||||
if pill_title == favorites_label
|
||||
assign open_wishlist = true
|
||||
endif
|
||||
if pill_handle == 'los-favoritos'
|
||||
if pill_handle == 'los-favoritos' or pill_handle == 'tus-favoritos' or pill_handle == 'favoritos'
|
||||
assign open_wishlist = true
|
||||
endif
|
||||
%}
|
||||
@@ -253,7 +253,7 @@
|
||||
aria-expanded="false"
|
||||
aria-haspopup="dialog"
|
||||
>
|
||||
{{ link.title }}
|
||||
{{ 'header.links.favorites' | t }}
|
||||
</button>
|
||||
{% else %}
|
||||
<a
|
||||
@@ -300,16 +300,20 @@
|
||||
</div>
|
||||
|
||||
{% if promo_text != blank %}
|
||||
{% liquid
|
||||
assign promo_url = section.settings.promo_link
|
||||
if promo_url == blank
|
||||
if routes.root_url == '/'
|
||||
assign promo_url = '/collections/all-products'
|
||||
else
|
||||
assign promo_url = routes.root_url | append: '/collections/all-products'
|
||||
endif
|
||||
endif
|
||||
%}
|
||||
<div class="header__promo flex h-[50px] items-center justify-center bg-brand-mint px-4 text-center">
|
||||
{% if section.settings.promo_link != blank %}
|
||||
<a class="text-[20px] font-bold uppercase leading-none text-black no-underline xl:text-[14px]" href="{{ section.settings.promo_link }}">
|
||||
{{ promo_text }}
|
||||
</a>
|
||||
{% else %}
|
||||
<p class="m-0 text-[20px] font-bold uppercase leading-none xl:text-[14px]">
|
||||
{{ promo_text }}
|
||||
</p>
|
||||
{% endif %}
|
||||
<a class="text-[20px] font-bold uppercase leading-none text-black no-underline xl:text-[14px]" href="{{ promo_url }}">
|
||||
{{ promo_text }}
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
@@ -322,7 +326,7 @@
|
||||
></button>
|
||||
</header>
|
||||
|
||||
<div id="wish-drawer" class="wish-drawer" data-wish-drawer data-empty="{{ 'header.wishlist_empty' | t | escape }}" data-remove="{{ 'header.wishlist_remove' | t | escape }}" aria-hidden="true">
|
||||
<div id="wish-drawer" class="wish-drawer" data-wish-drawer data-empty="{{ 'header.wishlist_empty' | t | escape }}" data-remove="{{ 'header.wishlist_remove' | t | escape }}" data-add="{{ 'header.wishlist_add' | t | escape }}" data-sold-out="{{ 'header.wishlist_sold_out' | t | escape }}" data-cart-add-url="{{ routes.cart_add_url }}.js" aria-hidden="true" inert>
|
||||
<button class="wish-drawer__backdrop" type="button" data-wish-close tabindex="-1" aria-label="{{ 'header.wishlist_close' | t }}"></button>
|
||||
<div class="wish-drawer__panel" role="dialog" aria-modal="true" aria-labelledby="wish-drawer-title">
|
||||
<div class="wish-drawer__head">
|
||||
@@ -333,7 +337,46 @@
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<div class="wish-drawer__list" data-wish-list></div>
|
||||
<div class="wish-drawer__scroll">
|
||||
<div class="wish-drawer__list" data-wish-list></div>
|
||||
{%- liquid
|
||||
assign wish_suggest = section.settings.wishlist_suggestions
|
||||
if wish_suggest == blank
|
||||
assign wish_suggest = collections['los-mas-vendidos']
|
||||
endif
|
||||
if wish_suggest == blank or wish_suggest.products_count == 0
|
||||
assign wish_suggest = collections.all
|
||||
endif
|
||||
-%}
|
||||
<div class="wish-drawer__suggest" data-wish-suggest hidden>
|
||||
<p class="wish-drawer__suggest-title">{{ 'header.wishlist_suggest' | t }}</p>
|
||||
<div class="wish-drawer__suggest-list">
|
||||
{%- assign wish_shown = 0 -%}
|
||||
{%- for sp in wish_suggest.products limit: 12 -%}
|
||||
{%- if wish_shown >= 4 -%}{%- break -%}{%- endif -%}
|
||||
{%- if sp.available -%}
|
||||
{%- assign wish_shown = wish_shown | plus: 1 -%}
|
||||
<article class="wish-drawer__item">
|
||||
<a class="wish-drawer__thumb" href="{{ sp.url }}">
|
||||
{%- if sp.featured_image -%}{{ sp.featured_image | image_url: width: 160 | image_tag: width: 72, height: 72, loading: 'lazy', alt: '' }}{%- endif -%}
|
||||
</a>
|
||||
<div>
|
||||
<a class="wish-drawer__name" href="{{ sp.url }}">{{ sp.title }}</a>
|
||||
<p class="wish-drawer__price">{{ sp.price | money_without_trailing_zeros }}</p>
|
||||
</div>
|
||||
<div class="wish-drawer__actions">
|
||||
<button class="wish-drawer__add" type="button" data-wish-add="{{ sp.selected_or_first_available_variant.id }}">{{ 'header.wishlist_add' | t }}</button>
|
||||
</div>
|
||||
</article>
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
</div>
|
||||
<a class="wish-drawer__browse" href="{{ wish_suggest.url | default: routes.all_products_collection_url }}">{{ 'header.wishlist_browse' | t }}</a>
|
||||
</div>
|
||||
<div class="wish-drawer__foot" data-wish-foot hidden>
|
||||
<button class="wish-drawer__add wish-drawer__add--all" type="button" data-wish-add-all>{{ 'header.wishlist_add_all' | t }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -346,15 +389,55 @@
|
||||
|
||||
const mobileQuery = window.matchMedia('(max-width: 1119px)');
|
||||
|
||||
const headerGroup = () => document.querySelector('.shopify-section-group-header-group');
|
||||
|
||||
const setHeaderOffset = () => {
|
||||
const group = document.querySelector('.shopify-section-group-header-group');
|
||||
const group = headerGroup();
|
||||
if (!group) return;
|
||||
document.documentElement.style.setProperty('--header-offset', group.offsetHeight + 'px');
|
||||
const hidden = !mobileQuery.matches && group.classList.contains('is-header-hidden');
|
||||
document.documentElement.style.setProperty('--header-offset', (hidden ? 0 : group.offsetHeight) + 'px');
|
||||
};
|
||||
|
||||
setHeaderOffset();
|
||||
window.addEventListener('resize', setHeaderOffset);
|
||||
|
||||
const header = document.querySelector('[data-header]');
|
||||
const group = headerGroup();
|
||||
if (header && group && !window.Shopify?.designMode) {
|
||||
let lastY = window.scrollY;
|
||||
let frame = 0;
|
||||
const onScroll = () => {
|
||||
frame = 0;
|
||||
if (mobileQuery.matches) {
|
||||
if (group.classList.contains('is-header-hidden')) {
|
||||
group.classList.remove('is-header-hidden');
|
||||
setHeaderOffset();
|
||||
}
|
||||
lastY = window.scrollY;
|
||||
return;
|
||||
}
|
||||
if (header.classList.contains('is-menu-open') || header.querySelector('.header__search.is-open') || document.documentElement.classList.contains('wish-drawer-open')) {
|
||||
group.classList.remove('is-header-hidden');
|
||||
setHeaderOffset();
|
||||
lastY = window.scrollY;
|
||||
return;
|
||||
}
|
||||
const y = Math.max(0, window.scrollY);
|
||||
const delta = y - lastY;
|
||||
if (Math.abs(delta) < 8) return;
|
||||
const hide = y > group.offsetHeight && delta > 0;
|
||||
if (hide !== group.classList.contains('is-header-hidden')) {
|
||||
group.classList.toggle('is-header-hidden', hide);
|
||||
setHeaderOffset();
|
||||
}
|
||||
lastY = y;
|
||||
};
|
||||
window.addEventListener('scroll', () => {
|
||||
if (frame) return;
|
||||
frame = window.requestAnimationFrame(onScroll);
|
||||
}, { passive: true });
|
||||
}
|
||||
|
||||
const closeMenu = (header) => {
|
||||
const menu = header.querySelector('[data-menu]');
|
||||
const toggle = header.querySelector('[data-menu-toggle]');
|
||||
@@ -508,6 +591,133 @@
|
||||
});
|
||||
}
|
||||
|
||||
const syncSubmenuArrows = (list) => {
|
||||
if (!(list instanceof HTMLElement)) return;
|
||||
const item = list.closest('[data-menu-item]');
|
||||
if (!item) return;
|
||||
const prev = item.querySelector('[data-submenu-scroll="-1"]');
|
||||
const next = item.querySelector('[data-submenu-scroll="1"]');
|
||||
const max = Math.max(0, list.scrollWidth - list.clientWidth);
|
||||
const overflow = mobileQuery.matches && item.classList.contains('is-open') && max > 8;
|
||||
if (prev) prev.hidden = !overflow || list.scrollLeft <= 4;
|
||||
if (next) next.hidden = !overflow || list.scrollLeft >= max - 4;
|
||||
const media = list.querySelector('.header__card-media');
|
||||
if (!overflow || !media) return;
|
||||
const top = media.getBoundingClientRect().top - item.getBoundingClientRect().top + (media.getBoundingClientRect().height - 36) / 2;
|
||||
item.querySelectorAll('[data-submenu-scroll]').forEach((control) => {
|
||||
control.style.top = top + 'px';
|
||||
});
|
||||
};
|
||||
|
||||
menu?.querySelectorAll('.header__submenu--cards').forEach((list) => {
|
||||
list.addEventListener('scroll', () => syncSubmenuArrows(list), { passive: true });
|
||||
});
|
||||
|
||||
let arrowFrame = 0;
|
||||
let arrowDelay = 0;
|
||||
let arrowList = null;
|
||||
let arrowDir = 0;
|
||||
let arrowHolding = false;
|
||||
let arrowTime = 0;
|
||||
|
||||
const stopSubmenuHold = () => {
|
||||
window.clearTimeout(arrowDelay);
|
||||
arrowDelay = 0;
|
||||
arrowHolding = false;
|
||||
arrowList = null;
|
||||
if (arrowFrame) window.cancelAnimationFrame(arrowFrame);
|
||||
arrowFrame = 0;
|
||||
};
|
||||
|
||||
const holdSubmenu = (now) => {
|
||||
if (!arrowHolding || !arrowList) return;
|
||||
const delta = Math.min(40, now - arrowTime);
|
||||
arrowTime = now;
|
||||
const max = Math.max(0, arrowList.scrollWidth - arrowList.clientWidth);
|
||||
arrowList.scrollLeft = Math.min(max, Math.max(0, arrowList.scrollLeft + arrowDir * (delta / 1000) * 420));
|
||||
syncSubmenuArrows(arrowList);
|
||||
const atEdge = arrowDir < 0 ? arrowList.scrollLeft <= 0 : arrowList.scrollLeft >= max - 1;
|
||||
if (atEdge) {
|
||||
stopSubmenuHold();
|
||||
return;
|
||||
}
|
||||
arrowFrame = window.requestAnimationFrame(holdSubmenu);
|
||||
};
|
||||
|
||||
const submenuCards = (list) => [...list.querySelectorAll('.header__card')];
|
||||
|
||||
const submenuIndex = (list) => {
|
||||
const cards = submenuCards(list);
|
||||
const mid = list.getBoundingClientRect().left + list.clientWidth / 2;
|
||||
let index = 0;
|
||||
let best = Infinity;
|
||||
cards.forEach((card, cardIndex) => {
|
||||
const rect = card.getBoundingClientRect();
|
||||
const distance = Math.abs(rect.left + rect.width / 2 - mid);
|
||||
if (distance < best) {
|
||||
best = distance;
|
||||
index = cardIndex;
|
||||
}
|
||||
});
|
||||
return index;
|
||||
};
|
||||
|
||||
const scrollToSubmenuCard = (list, index) => {
|
||||
const cards = submenuCards(list);
|
||||
const card = cards[Math.max(0, Math.min(cards.length - 1, index))];
|
||||
if (!card) return;
|
||||
const listRect = list.getBoundingClientRect();
|
||||
const cardRect = card.getBoundingClientRect();
|
||||
const delta = cardRect.left + cardRect.width / 2 - (listRect.left + listRect.width / 2);
|
||||
list.scrollTo({ left: list.scrollLeft + delta, behavior: 'smooth' });
|
||||
};
|
||||
|
||||
const stepSubmenu = (list, dir) => {
|
||||
scrollToSubmenuCard(list, submenuIndex(list) + dir);
|
||||
};
|
||||
|
||||
menu?.addEventListener('pointerdown', (event) => {
|
||||
const button = event.target.closest('[data-submenu-scroll]');
|
||||
if (!button || !mobileQuery.matches) return;
|
||||
const list = button.closest('[data-menu-item]')?.querySelector('.header__submenu--cards');
|
||||
if (!list) return;
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
stopSubmenuHold();
|
||||
arrowList = list;
|
||||
arrowDir = Number(button.dataset.submenuScroll);
|
||||
try {
|
||||
if (button.setPointerCapture) button.setPointerCapture(event.pointerId);
|
||||
} catch (error) {}
|
||||
arrowDelay = window.setTimeout(() => {
|
||||
arrowHolding = true;
|
||||
arrowTime = window.performance.now();
|
||||
arrowFrame = window.requestAnimationFrame(holdSubmenu);
|
||||
}, 200);
|
||||
});
|
||||
|
||||
const finishSubmenuPointer = () => {
|
||||
if (!arrowList) return;
|
||||
const list = arrowList;
|
||||
const dir = arrowDir;
|
||||
const wasHolding = arrowHolding;
|
||||
stopSubmenuHold();
|
||||
if (wasHolding) scrollToSubmenuCard(list, submenuIndex(list));
|
||||
else stepSubmenu(list, dir);
|
||||
};
|
||||
|
||||
menu?.addEventListener('pointerup', finishSubmenuPointer);
|
||||
menu?.addEventListener('pointercancel', stopSubmenuHold);
|
||||
menu?.addEventListener('click', (event) => {
|
||||
if (!event.target.closest('[data-submenu-scroll]')) return;
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
});
|
||||
|
||||
window.addEventListener('resize', () => {
|
||||
menu?.querySelectorAll('.header__submenu--cards').forEach(syncSubmenuArrows);
|
||||
});
|
||||
|
||||
menu?.addEventListener('click', (event) => {
|
||||
const submenuToggle = event.target.closest('[data-submenu-toggle]');
|
||||
const toggleSubmenu = (submenuToggle) => {
|
||||
@@ -520,6 +730,9 @@
|
||||
});
|
||||
item.classList.toggle('is-open', !expanded);
|
||||
submenuToggle.setAttribute('aria-expanded', expanded ? 'false' : 'true');
|
||||
window.requestAnimationFrame(() => {
|
||||
menu.querySelectorAll('.header__submenu--cards').forEach(syncSubmenuArrows);
|
||||
});
|
||||
};
|
||||
|
||||
if (submenuToggle) {
|
||||
@@ -634,12 +847,19 @@
|
||||
if (!wishList) return;
|
||||
const request = ++wishRequest;
|
||||
const items = readWishItems().filter((item) => item.handle);
|
||||
if (!items.length) {
|
||||
const suggest = wishDrawer?.querySelector('[data-wish-suggest]');
|
||||
const foot = wishDrawer?.querySelector('[data-wish-foot]');
|
||||
const showEmpty = () => {
|
||||
wishList.replaceChildren();
|
||||
const empty = document.createElement('p');
|
||||
empty.className = 'wish-drawer__empty';
|
||||
empty.textContent = wishDrawer?.dataset.empty || '';
|
||||
wishList.append(empty);
|
||||
if (suggest) suggest.hidden = false;
|
||||
if (foot) foot.hidden = true;
|
||||
};
|
||||
if (!items.length) {
|
||||
showEmpty();
|
||||
return;
|
||||
}
|
||||
const products = await Promise.all(items.map(async (item) => {
|
||||
@@ -657,12 +877,12 @@
|
||||
const found = products.filter(Boolean);
|
||||
wishList.replaceChildren();
|
||||
if (!found.length) {
|
||||
const empty = document.createElement('p');
|
||||
empty.className = 'wish-drawer__empty';
|
||||
empty.textContent = wishDrawer?.dataset.empty || '';
|
||||
wishList.append(empty);
|
||||
showEmpty();
|
||||
return;
|
||||
}
|
||||
if (suggest) suggest.hidden = true;
|
||||
const buyable = found.filter((product) => (product.variants || []).some((variant) => variant.available));
|
||||
if (foot) foot.hidden = buyable.length < 2;
|
||||
found.forEach((product) => {
|
||||
const row = document.createElement('article');
|
||||
row.className = 'wish-drawer__item';
|
||||
@@ -693,20 +913,59 @@
|
||||
remove.type = 'button';
|
||||
remove.dataset.wishRemove = product._wishId;
|
||||
remove.textContent = wishDrawer?.dataset.remove || '';
|
||||
row.append(link, copy, remove);
|
||||
const actions = document.createElement('div');
|
||||
actions.className = 'wish-drawer__actions';
|
||||
const variant = (product.variants || []).find((v) => v.available);
|
||||
const add = document.createElement('button');
|
||||
add.className = 'wish-drawer__add';
|
||||
add.type = 'button';
|
||||
if (variant) {
|
||||
add.dataset.wishAdd = String(variant.id);
|
||||
add.textContent = wishDrawer?.dataset.add || 'Agregar';
|
||||
} else {
|
||||
add.disabled = true;
|
||||
add.textContent = wishDrawer?.dataset.soldOut || 'Agotado';
|
||||
}
|
||||
actions.append(add, remove);
|
||||
row.append(link, copy, actions);
|
||||
wishList.append(row);
|
||||
});
|
||||
};
|
||||
|
||||
const addWishToCart = async (ids, button) => {
|
||||
if (!ids.length || !button || button.disabled) return;
|
||||
button.disabled = true;
|
||||
button.classList.add('is-busy');
|
||||
try {
|
||||
const response = await fetch(wishDrawer?.dataset.cartAddUrl || '/cart/add.js', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
||||
body: JSON.stringify({ items: ids.map((id) => ({ id: Number(id), quantity: 1 })) }),
|
||||
});
|
||||
if (!response.ok) throw new Error('add failed');
|
||||
setWishOpen(false);
|
||||
document.dispatchEvent(new CustomEvent('season:cart:open'));
|
||||
} catch (error) {
|
||||
button.classList.add('is-error');
|
||||
window.setTimeout(() => button.classList.remove('is-error'), 1500);
|
||||
} finally {
|
||||
button.disabled = false;
|
||||
button.classList.remove('is-busy');
|
||||
}
|
||||
};
|
||||
|
||||
const setWishOpen = (open) => {
|
||||
if (!wishDrawer || !wishButton) return;
|
||||
if (open && wishDrawer.parentElement !== document.body) document.body.appendChild(wishDrawer);
|
||||
wishDrawer.classList.toggle('is-open', open);
|
||||
wishDrawer.setAttribute('aria-hidden', open ? 'false' : 'true');
|
||||
wishDrawer.inert = !open;
|
||||
document.querySelectorAll('[data-wish-open]').forEach((control) => {
|
||||
control.setAttribute('aria-expanded', open ? 'true' : 'false');
|
||||
});
|
||||
document.documentElement.classList.toggle('overflow-hidden', open);
|
||||
document.documentElement.classList.toggle('wish-drawer-open', open);
|
||||
if (open) {
|
||||
document.querySelector('.shopify-section-group-header-group')?.classList.remove('is-header-hidden');
|
||||
document.querySelectorAll('[data-header]').forEach((header) => {
|
||||
closeMenu(header);
|
||||
closeSearch(header);
|
||||
@@ -735,6 +994,15 @@
|
||||
wishButton?.focus();
|
||||
return;
|
||||
}
|
||||
const addOne = event.target.closest('[data-wish-add]');
|
||||
const addAll = event.target.closest('[data-wish-add-all]');
|
||||
if (addOne || addAll) {
|
||||
const ids = addAll
|
||||
? [...(wishDrawer?.querySelectorAll('[data-wish-list] [data-wish-add]') || [])].map((b) => b.dataset.wishAdd)
|
||||
: [addOne.dataset.wishAdd];
|
||||
addWishToCart(ids.filter(Boolean), addOne || addAll);
|
||||
return;
|
||||
}
|
||||
const remove = event.target.closest('[data-wish-remove]');
|
||||
if (!remove) return;
|
||||
const id = remove.dataset.wishRemove;
|
||||
@@ -784,6 +1052,12 @@
|
||||
"type": "url",
|
||||
"id": "promo_link",
|
||||
"label": "t:header.promo_link"
|
||||
},
|
||||
{
|
||||
"type": "collection",
|
||||
"id": "wishlist_suggestions",
|
||||
"label": "Sugerencias en Favoritos vacío",
|
||||
"info": "Por defecto: Los más vendidos."
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
+207
-39
@@ -13,12 +13,56 @@
|
||||
assign cover_mobile = 'mascara-vido-mobile.avif' | asset_url
|
||||
endif
|
||||
|
||||
comment
|
||||
Video hero: use the video's own first frame as the cover (LCP image). It is tiny
|
||||
(AVIF ~20 KB desktop / ~8 KB mobile) and identical to frame 0, so the switch to video is seamless.
|
||||
endcomment
|
||||
assign cover_w = 1920
|
||||
assign cover_h = 650
|
||||
if media_type == 'video' and section.settings.poster_from_video
|
||||
comment
|
||||
Shopify's video preview image is frame 0 of the video, served as AVIF/WebP by the CDN.
|
||||
endcomment
|
||||
if section.settings.video.preview_image
|
||||
assign cover_desktop = section.settings.video.preview_image | image_url: width: 1280
|
||||
assign cover_w = section.settings.video.preview_image.width | at_most: 1280
|
||||
assign cover_h = section.settings.video.preview_image.height | times: cover_w | divided_by: section.settings.video.preview_image.width
|
||||
else
|
||||
assign cover_desktop = 'hero-frame-desktop.avif' | asset_url
|
||||
assign cover_w = 1280
|
||||
assign cover_h = 720
|
||||
endif
|
||||
if section.settings.video_mobile.preview_image
|
||||
assign cover_mobile = section.settings.video_mobile.preview_image | image_url: width: 720
|
||||
elsif section.settings.use_light_mobile_video
|
||||
assign cover_mobile = 'hero-frame-mobile.avif' | asset_url
|
||||
elsif section.settings.video.preview_image
|
||||
assign cover_mobile = section.settings.video.preview_image | image_url: width: 900
|
||||
else
|
||||
assign cover_mobile = cover_desktop
|
||||
endif
|
||||
endif
|
||||
|
||||
assign video_src = blank
|
||||
assign video_src_mobile = blank
|
||||
if media_type == 'video'
|
||||
if section.settings.video != blank
|
||||
comment
|
||||
Desktop: the largest MP4 up to 1080p. Mobile: the smallest MP4 that is at least 480p.
|
||||
endcomment
|
||||
assign best_h = 0
|
||||
assign mobile_h = 99999
|
||||
for source in section.settings.video.sources
|
||||
if source.mime_type == 'video/mp4' or source.format == 'mp4'
|
||||
assign video_src = source.url
|
||||
assign h = source.height | default: 0
|
||||
if h <= 1080 and h >= best_h
|
||||
assign best_h = h
|
||||
assign video_src = source.url
|
||||
endif
|
||||
if h >= 480 and h < mobile_h
|
||||
assign mobile_h = h
|
||||
assign video_src_mobile = source.url
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
@@ -26,6 +70,39 @@
|
||||
if video_src == blank
|
||||
assign video_src = 'home-video-op.mp4' | asset_url
|
||||
endif
|
||||
|
||||
comment
|
||||
Mobile: a dedicated vertical, light video (setting) or the theme's hero-mobile.mp4 (~450 KB, cropped 516x720).
|
||||
endcomment
|
||||
if section.settings.video_mobile != blank
|
||||
assign mobile_h = 99999
|
||||
for source in section.settings.video_mobile.sources
|
||||
if source.mime_type == 'video/mp4' or source.format == 'mp4'
|
||||
assign h = source.height | default: 0
|
||||
if h >= 480 and h < mobile_h
|
||||
assign mobile_h = h
|
||||
assign video_src_mobile = source.url
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
elsif section.settings.use_light_mobile_video
|
||||
assign video_src_mobile = 'hero-mobile.mp4' | asset_url
|
||||
endif
|
||||
|
||||
comment
|
||||
Theme-hosted optimized videos (no Shopify re-encoding: ~1 MB desktop / ~0.4 MB mobile)
|
||||
plus their first frames as the cover. These files must match the videos picked above.
|
||||
endcomment
|
||||
if section.settings.theme_hosted_videos
|
||||
assign video_src = 'seasons-hero-desktop.mp4' | asset_url
|
||||
assign video_src_mobile = 'seasons-hero-mobile.mp4' | asset_url
|
||||
if section.settings.poster_from_video
|
||||
assign cover_desktop = 'hero-frame-desktop.avif' | asset_url
|
||||
assign cover_mobile = 'hero-frame-mobile.avif' | asset_url
|
||||
assign cover_w = 1280
|
||||
assign cover_h = 720
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
if section.settings.social_label != blank
|
||||
@@ -70,8 +147,6 @@
|
||||
data-cart-add-url="{{ routes.cart_add_url }}.js"
|
||||
data-cart-url="{{ routes.cart_url }}.js"
|
||||
>
|
||||
<link rel="preload" as="image" href="{{ cover_desktop }}" media="(min-width: 1024px)" fetchpriority="high">
|
||||
<link rel="preload" as="image" href="{{ cover_mobile }}" media="(max-width: 1023px)" fetchpriority="high">
|
||||
|
||||
<div class="hero__media" aria-hidden="true">
|
||||
{% if media_type == 'image' %}
|
||||
@@ -90,22 +165,24 @@
|
||||
<video
|
||||
class="hero__video"
|
||||
data-hero-video
|
||||
data-src-desktop="{{ video_src }}"
|
||||
data-src-mobile="{{ video_src_mobile | default: video_src }}"
|
||||
muted
|
||||
loop
|
||||
playsinline
|
||||
preload="none"
|
||||
>
|
||||
<source src="{{ video_src }}" type="video/mp4">
|
||||
</video>
|
||||
<picture class="hero__poster">
|
||||
<source media="(max-width: 1023px)" srcset="{{ cover_mobile }}">
|
||||
<img
|
||||
class="hero__poster-image"
|
||||
src="{{ cover_desktop }}"
|
||||
alt=""
|
||||
width="1920"
|
||||
height="650"
|
||||
alt=""
|
||||
width="{{ cover_w }}"
|
||||
height="{{ cover_h }}"
|
||||
fetchpriority="high"
|
||||
decoding="sync"
|
||||
>
|
||||
</picture>
|
||||
{% endif %}
|
||||
@@ -134,6 +211,11 @@
|
||||
{% for block in section.blocks %}
|
||||
{% liquid
|
||||
assign featured_product = block.settings.product
|
||||
if featured_product != blank
|
||||
unless featured_product.available
|
||||
assign featured_product = blank
|
||||
endunless
|
||||
endif
|
||||
if featured_product == blank and forloop.first
|
||||
assign featured_product = fallback_product
|
||||
endif
|
||||
@@ -204,24 +286,61 @@
|
||||
window.__seasonHeroVideo = true;
|
||||
if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return;
|
||||
|
||||
const events = ['keydown', 'mousedown', 'mousemove', 'touchstart', 'wheel'];
|
||||
const start = () => {
|
||||
events.forEach((eventName) => window.removeEventListener(eventName, start));
|
||||
// The cover (first frame of the video) is the LCP image. Once the page has loaded we
|
||||
// start buffering the video, and it starts playing 3 s after the cover was shown.
|
||||
const HOLD_MS = 3000;
|
||||
const shownAt = performance.now();
|
||||
let buffering = false;
|
||||
|
||||
const buffer = () => {
|
||||
if (buffering) return;
|
||||
buffering = true;
|
||||
events.forEach((eventName) => window.removeEventListener(eventName, buffer));
|
||||
const mobile = window.matchMedia('(max-width: 1023px)').matches;
|
||||
document.querySelectorAll('[data-hero-video]').forEach((video) => {
|
||||
const src = (mobile ? video.dataset.srcMobile : video.dataset.srcDesktop) || video.dataset.srcDesktop;
|
||||
if (!src) return;
|
||||
const hero = video.closest('[data-hero]');
|
||||
video.addEventListener('playing', () => hero?.classList.add('is-playing'));
|
||||
if (!video.getAttribute('src')) video.src = src;
|
||||
video.preload = 'auto';
|
||||
video.load();
|
||||
const play = () => {
|
||||
const attempt = video.play();
|
||||
if (attempt && typeof attempt.catch === 'function') attempt.catch(() => {});
|
||||
};
|
||||
video.addEventListener('playing', () => hero?.classList.add('is-playing'));
|
||||
video.preload = 'auto';
|
||||
if (video.readyState >= 2) play();
|
||||
else video.addEventListener('canplay', play, { once: true });
|
||||
video.load();
|
||||
const wait = Math.max(0, HOLD_MS - (performance.now() - shownAt));
|
||||
window.setTimeout(() => {
|
||||
if (video.readyState >= 3) play();
|
||||
else video.addEventListener('canplay', play, { once: true });
|
||||
}, wait);
|
||||
});
|
||||
};
|
||||
|
||||
events.forEach((eventName) => window.addEventListener(eventName, start, { passive: true }));
|
||||
// Buffering begins after load (so it never competes with the cover image) or on the first interaction.
|
||||
const events = ['keydown', 'mousedown', 'touchstart', 'wheel', 'scroll'];
|
||||
events.forEach((eventName) => window.addEventListener(eventName, buffer, { passive: true }));
|
||||
const conn = navigator.connection;
|
||||
const slow = conn && (conn.saveData || /2g/.test(conn.effectiveType || ''));
|
||||
if (!slow) {
|
||||
// Wait for the page load AND for the cover (LCP image) to be painted, then an idle moment,
|
||||
// so the video download never competes with the cover.
|
||||
const cover = document.querySelector('.hero__poster-image');
|
||||
const coverReady = () => new Promise((resolve) => {
|
||||
if (!cover || cover.complete) return resolve();
|
||||
cover.addEventListener('load', resolve, { once: true });
|
||||
cover.addEventListener('error', resolve, { once: true });
|
||||
});
|
||||
const pageLoaded = () => new Promise((resolve) => {
|
||||
if (document.readyState === 'complete') resolve();
|
||||
else window.addEventListener('load', resolve, { once: true });
|
||||
});
|
||||
const idle = () => new Promise((resolve) => {
|
||||
if ('requestIdleCallback' in window) window.requestIdleCallback(() => resolve(), { timeout: 1500 });
|
||||
else window.setTimeout(resolve, 300);
|
||||
});
|
||||
Promise.all([pageLoaded(), coverReady()]).then(idle).then(buffer);
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
|
||||
@@ -253,22 +372,11 @@
|
||||
|
||||
const markPlaying = () => hero.classList.add('is-playing');
|
||||
video.addEventListener('playing', markPlaying);
|
||||
|
||||
const tryPlay = () => {
|
||||
const playAttempt = video.play();
|
||||
if (playAttempt && typeof playAttempt.catch === 'function') {
|
||||
playAttempt.catch(() => {});
|
||||
}
|
||||
};
|
||||
|
||||
if (video.readyState >= 2) {
|
||||
tryPlay();
|
||||
} else {
|
||||
video.addEventListener('canplay', tryPlay, { once: true });
|
||||
}
|
||||
// Playback timing (3 s hold on the first-frame cover) is handled by the inline hero script.
|
||||
});
|
||||
|
||||
document.addEventListener('submit', async (event) => {
|
||||
if (event.defaultPrevented) return;
|
||||
const form = event.target;
|
||||
if (!(form instanceof HTMLFormElement) || !form.classList.contains('hero__form')) return;
|
||||
|
||||
@@ -319,7 +427,10 @@
|
||||
"class": "hero-section",
|
||||
"max_blocks": 2,
|
||||
"disabled_on": {
|
||||
"groups": ["header", "footer"]
|
||||
"groups": [
|
||||
"header",
|
||||
"footer"
|
||||
]
|
||||
},
|
||||
"settings": [
|
||||
{
|
||||
@@ -338,8 +449,14 @@
|
||||
"label": "t:hero.line_1_weight",
|
||||
"default": "light",
|
||||
"options": [
|
||||
{ "value": "light", "label": "t:hero.weight_light" },
|
||||
{ "value": "medium", "label": "t:hero.weight_medium" }
|
||||
{
|
||||
"value": "light",
|
||||
"label": "t:hero.weight_light"
|
||||
},
|
||||
{
|
||||
"value": "medium",
|
||||
"label": "t:hero.weight_medium"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -354,8 +471,14 @@
|
||||
"label": "t:hero.line_2_weight",
|
||||
"default": "medium",
|
||||
"options": [
|
||||
{ "value": "light", "label": "t:hero.weight_light" },
|
||||
{ "value": "medium", "label": "t:hero.weight_medium" }
|
||||
{
|
||||
"value": "light",
|
||||
"label": "t:hero.weight_light"
|
||||
},
|
||||
{
|
||||
"value": "medium",
|
||||
"label": "t:hero.weight_medium"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -370,8 +493,14 @@
|
||||
"label": "t:hero.line_3_weight",
|
||||
"default": "light",
|
||||
"options": [
|
||||
{ "value": "light", "label": "t:hero.weight_light" },
|
||||
{ "value": "medium", "label": "t:hero.weight_medium" }
|
||||
{
|
||||
"value": "light",
|
||||
"label": "t:hero.weight_light"
|
||||
},
|
||||
{
|
||||
"value": "medium",
|
||||
"label": "t:hero.weight_medium"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -390,8 +519,14 @@
|
||||
"label": "t:hero.media_type",
|
||||
"default": "video",
|
||||
"options": [
|
||||
{ "value": "video", "label": "t:hero.media_video" },
|
||||
{ "value": "image", "label": "t:hero.media_image" }
|
||||
{
|
||||
"value": "video",
|
||||
"label": "t:hero.media_video"
|
||||
},
|
||||
{
|
||||
"value": "image",
|
||||
"label": "t:hero.media_image"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -401,6 +536,37 @@
|
||||
"info": "t:hero.video_info",
|
||||
"visible_if": "{{ section.settings.media_type == 'video' }}"
|
||||
},
|
||||
{
|
||||
"type": "video",
|
||||
"id": "video_mobile",
|
||||
"label": "Video móvil (vertical, ligero)",
|
||||
"info": "Opcional. Recomendado: vertical, sin audio, menos de 1 MB.",
|
||||
"visible_if": "{{ section.settings.media_type == 'video' }}"
|
||||
},
|
||||
{
|
||||
"type": "checkbox",
|
||||
"id": "use_light_mobile_video",
|
||||
"label": "Usar versión ligera incluida en el tema para móvil",
|
||||
"info": "Recorte vertical del video actual (~450 KB). Desactívalo si cambias el video principal y no subes uno móvil.",
|
||||
"default": true,
|
||||
"visible_if": "{{ section.settings.media_type == 'video' }}"
|
||||
},
|
||||
{
|
||||
"type": "checkbox",
|
||||
"id": "poster_from_video",
|
||||
"label": "Portada = primer cuadro del video",
|
||||
"info": "Muestra el primer cuadro del video (imagen ligera precargada) 3 s antes de reproducir. Desactívalo para usar las portadas de abajo.",
|
||||
"default": true,
|
||||
"visible_if": "{{ section.settings.media_type == 'video' }}"
|
||||
},
|
||||
{
|
||||
"type": "checkbox",
|
||||
"id": "theme_hosted_videos",
|
||||
"label": "Usar videos optimizados del tema",
|
||||
"info": "Sirve seasons-hero-desktop.mp4 (~1 MB) y seasons-hero-mobile.mp4 (~0.4 MB) desde el tema, sin la recompresión de Shopify (que los vuelve ~2 MB). Si cambias los videos, actualiza esos archivos o desactiva esta opción.",
|
||||
"default": true,
|
||||
"visible_if": "{{ section.settings.media_type == 'video' }}"
|
||||
},
|
||||
{
|
||||
"type": "image_picker",
|
||||
"id": "cover_desktop",
|
||||
@@ -456,7 +622,9 @@
|
||||
{
|
||||
"name": "t:hero.name",
|
||||
"blocks": [
|
||||
{ "type": "featured_product" }
|
||||
{
|
||||
"type": "featured_product"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
+130
-25
@@ -60,24 +60,21 @@
|
||||
assign fallback_image = blank
|
||||
case forloop.index
|
||||
when 1
|
||||
assign fallback_image = 'learn-cover-1.avif'
|
||||
assign fallback_image = 'video-11.png'
|
||||
when 2
|
||||
assign fallback_image = 'learn-cover-2.avif'
|
||||
assign fallback_image = 'video-22.png'
|
||||
when 3
|
||||
assign fallback_image = 'reel1.jpg'
|
||||
assign fallback_image = 'learn-reel-3.avif'
|
||||
when 4
|
||||
assign fallback_image = 'learn-cover-4.avif'
|
||||
assign fallback_image = 'video-44.png'
|
||||
when 5
|
||||
assign fallback_image = 'learn-cover-5.avif'
|
||||
assign fallback_image = 'video-55.png'
|
||||
endcase
|
||||
|
||||
assign poster_alt = heading
|
||||
assign slide_state = ''
|
||||
if forloop.index0 == active_index
|
||||
assign slide_state = ' is-active'
|
||||
if video_src != blank
|
||||
assign slide_state = slide_state | append: ' is-playing'
|
||||
endif
|
||||
endif
|
||||
%}
|
||||
<article
|
||||
@@ -103,10 +100,12 @@
|
||||
src="{{ fallback_image | asset_url }}"
|
||||
alt="{{ poster_alt | escape }}"
|
||||
width="384"
|
||||
height="680"
|
||||
height="{% if fallback_image contains '.png' %}518{% else %}680{% endif %}"
|
||||
loading="lazy"
|
||||
srcset="{{ fallback_image | replace: '.avif', '-sm.avif' | asset_url }} 400w, {{ fallback_image | asset_url }} 780w"
|
||||
sizes="(max-width: 1024px) 220px, 384px"
|
||||
{% unless fallback_image contains '.png' %}
|
||||
srcset="{{ fallback_image | replace: '.avif', '-sm.avif' | asset_url }} 360w, {{ fallback_image | asset_url }} 720w"
|
||||
sizes="(max-width: 1024px) 200px, 384px"
|
||||
{% endunless %}
|
||||
decoding="async"
|
||||
>
|
||||
{% endif %}
|
||||
@@ -114,23 +113,20 @@
|
||||
<video
|
||||
class="learn__video"
|
||||
data-learn-video
|
||||
src="{{ video_src }}"
|
||||
data-src="{{ video_src }}"
|
||||
{% if block.settings.poster != blank %}
|
||||
poster="{{ block.settings.poster | image_url: width: 800 }}"
|
||||
{% elsif fallback_image != blank %}
|
||||
poster="{{ fallback_image | asset_url }}"
|
||||
{% endif %}
|
||||
muted
|
||||
playsinline
|
||||
loop
|
||||
{% if forloop.index0 == active_index %}
|
||||
autoplay
|
||||
preload="auto"
|
||||
{% else %}
|
||||
preload="none"
|
||||
{% endif %}
|
||||
preload="none"
|
||||
></video>
|
||||
<button class="learn__play" type="button" data-learn-play aria-label="{{ 'learn.play_sound' | t }}">
|
||||
<svg width="22" height="22" viewBox="0 0 22 22" aria-hidden="true" focusable="false"><path d="M7 4.5v13l11-6.5z" fill="currentColor"/></svg>
|
||||
</button>
|
||||
<button class="learn__sound" type="button" data-learn-sound aria-pressed="false" aria-label="{{ 'learn.sound_on' | t }}" data-label-on="{{ 'learn.sound_on' | t }}" data-label-off="{{ 'learn.sound_off' | t }}">
|
||||
<svg class="learn__sound-off" width="18" height="18" viewBox="0 0 18 18" aria-hidden="true" focusable="false"><path d="M3 6.5h2.5L9 3.5v11L5.5 11.5H3z" fill="currentColor"/><path d="M12 6.5l4 5M16 6.5l-4 5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>
|
||||
<svg class="learn__sound-on" width="18" height="18" viewBox="0 0 18 18" aria-hidden="true" focusable="false"><path d="M3 6.5h2.5L9 3.5v11L5.5 11.5H3z" fill="currentColor"/><path d="M12 6.2a3.6 3.6 0 0 1 0 5.6M14 4.2a6.3 6.3 0 0 1 0 9.6" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>
|
||||
<span class="learn__sound-text">{{ 'learn.tap_sound' | t }}</span>
|
||||
</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</article>
|
||||
@@ -138,6 +134,102 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script nolazy>
|
||||
(function () {
|
||||
if (window.__learnReelClicks) return;
|
||||
window.__learnReelClicks = true;
|
||||
var setSoundUi = function (root) {
|
||||
var on = root.dataset.sound === 'on';
|
||||
root.querySelectorAll('[data-learn-sound]').forEach(function (b) {
|
||||
b.setAttribute('aria-pressed', on ? 'true' : 'false');
|
||||
b.setAttribute('aria-label', on ? b.dataset.labelOff : b.dataset.labelOn);
|
||||
});
|
||||
root.classList.toggle('has-sound', on);
|
||||
};
|
||||
var watch = function (slide, video) {
|
||||
if (video.dataset.watched) return;
|
||||
video.dataset.watched = '1';
|
||||
video.addEventListener('playing', function () { slide.classList.add('is-playing'); slide.classList.remove('is-paused'); });
|
||||
video.addEventListener('pause', function () { if (slide.classList.contains('is-active')) slide.classList.add('is-paused'); });
|
||||
};
|
||||
var start = function (root, slide, video) {
|
||||
root.dataset.sound = 'on';
|
||||
setSoundUi(root);
|
||||
if (video.dataset.src && video.getAttribute('src') !== video.dataset.src) { video.src = video.dataset.src; video.load(); }
|
||||
video.dataset.loaded = 'true';
|
||||
video.muted = false;
|
||||
watch(slide, video);
|
||||
slide.classList.add('is-playing');
|
||||
slide.classList.remove('is-paused');
|
||||
var p = video.play();
|
||||
if (p && p.catch) p.catch(function () {
|
||||
video.muted = true;
|
||||
root.dataset.sound = 'off';
|
||||
setSoundUi(root);
|
||||
video.play().catch(function () {});
|
||||
});
|
||||
};
|
||||
// Autoplay (muted) only while the reels are on screen.
|
||||
if ('IntersectionObserver' in window) {
|
||||
var io = new IntersectionObserver(function (entries) {
|
||||
entries.forEach(function (entry) {
|
||||
var root = entry.target;
|
||||
var active = root.querySelector('[data-slide].is-active');
|
||||
var video = active && active.querySelector('[data-learn-video]');
|
||||
if (entry.isIntersecting) {
|
||||
root.dataset.inview = '1';
|
||||
if (video && video.paused && !active.classList.contains('is-paused')) {
|
||||
if (video.dataset.src && video.getAttribute('src') !== video.dataset.src) { video.src = video.dataset.src; video.dataset.loaded = 'true'; }
|
||||
video.muted = root.dataset.sound !== 'on';
|
||||
watch(active, video);
|
||||
var p = video.play(); if (p && p.catch) p.catch(function () {});
|
||||
}
|
||||
} else {
|
||||
root.dataset.inview = '0';
|
||||
if (video && !video.paused) { video.pause(); active.classList.remove('is-paused'); }
|
||||
}
|
||||
});
|
||||
}, { rootMargin: '100px 0px' });
|
||||
var observe = function () { document.querySelectorAll('[data-learn]').forEach(function (r) { io.observe(r); }); };
|
||||
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', observe); else observe();
|
||||
}
|
||||
document.addEventListener('click', function (event) {
|
||||
// The carousel drag code uses pointer capture, which retargets the click to the viewport.
|
||||
var hit = event.target.closest('[data-learn] .learn__media') ? event.target : document.elementFromPoint(event.clientX, event.clientY);
|
||||
var media = hit && hit.closest('[data-learn] .learn__media');
|
||||
if (media && !event.target.closest('[data-learn]')) media = null;
|
||||
if (!media) return;
|
||||
var root = media.closest('[data-learn]');
|
||||
var slide = media.closest('[data-slide]');
|
||||
var video = slide && slide.querySelector('[data-learn-video]');
|
||||
if (!video) return;
|
||||
event.preventDefault();
|
||||
var slides = [].slice.call(root.querySelectorAll('[data-slide]'));
|
||||
var i = slides.indexOf(slide);
|
||||
if (hit.closest('[data-learn-sound]')) {
|
||||
var on = root.dataset.sound !== 'on';
|
||||
root.dataset.sound = on ? 'on' : 'off';
|
||||
setSoundUi(root);
|
||||
video.muted = !on;
|
||||
if (video.paused) start(root, slide, video);
|
||||
if (!on) video.muted = true;
|
||||
return;
|
||||
}
|
||||
if (!slide.classList.contains('is-active')) {
|
||||
slides.forEach(function (s) { if (s !== slide) { var v = s.querySelector('[data-learn-video]'); if (v) v.pause(); } });
|
||||
start(root, slide, video);
|
||||
if (root.__learnGo) root.__learnGo(i);
|
||||
else {
|
||||
root.dataset.pending = String(i);
|
||||
slides.forEach(function (s) { s.classList.toggle('is-active', s === slide); });
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (video.paused || video.muted) start(root, slide, video);
|
||||
else video.pause();
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
<button class="learn__arrow learn__arrow--prev" type="button" data-learn-prev aria-label="{{ 'learn.previous' | t }}">
|
||||
<span class="learn__arrow-icon" aria-hidden="true">
|
||||
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
@@ -165,7 +257,7 @@
|
||||
assign slide_product = block.settings.product_2
|
||||
endif
|
||||
%}
|
||||
{% if slide_product != blank %}
|
||||
{% if slide_product != blank and slide_product.available %}
|
||||
{% liquid
|
||||
assign variant = slide_product.selected_or_first_available_variant
|
||||
assign card_image = slide_product.featured_image
|
||||
@@ -258,7 +350,13 @@
|
||||
|
||||
const playSlide = (slide) => {
|
||||
const video = slide.querySelector('[data-learn-video]');
|
||||
if (!video || reduceMotion) return;
|
||||
if (!video) return;
|
||||
const root = slide.closest('[data-learn]');
|
||||
const soundOn = root && root.dataset.sound === 'on';
|
||||
if (reduceMotion && !soundOn) return;
|
||||
// Only download/play once the section is on screen (or the visitor asked for sound).
|
||||
if (!soundOn && root && root.dataset.inview !== '1') return;
|
||||
video.muted = !soundOn;
|
||||
if (video.dataset.loaded !== 'true' && video.dataset.src) {
|
||||
video.dataset.loaded = 'true';
|
||||
if (video.getAttribute('src') !== video.dataset.src) {
|
||||
@@ -276,6 +374,7 @@
|
||||
const stopSlide = (slide) => {
|
||||
const video = slide.querySelector('[data-learn-video]');
|
||||
slide.classList.remove('is-playing');
|
||||
slide.classList.remove('is-paused');
|
||||
if (video && video.dataset.loaded === 'true') video.pause();
|
||||
};
|
||||
|
||||
@@ -329,6 +428,7 @@
|
||||
index = target;
|
||||
paint(true);
|
||||
};
|
||||
root.__learnGo = go;
|
||||
|
||||
prev?.addEventListener('click', () => go(index - 1));
|
||||
next?.addEventListener('click', () => go(index + 1));
|
||||
@@ -416,6 +516,10 @@
|
||||
}
|
||||
|
||||
window.addEventListener('resize', () => paint(false));
|
||||
if (root.dataset.pending) {
|
||||
index = Math.min(Math.max(Number(root.dataset.pending) || 0, 0), slides.length - 1);
|
||||
delete root.dataset.pending;
|
||||
}
|
||||
paint(false);
|
||||
};
|
||||
|
||||
@@ -431,6 +535,7 @@
|
||||
if (!window.__seasonLearn) {
|
||||
window.__seasonLearn = true;
|
||||
document.addEventListener('submit', async (event) => {
|
||||
if (event.defaultPrevented) return;
|
||||
const form = event.target;
|
||||
if (!(form instanceof HTMLFormElement) || !form.classList.contains('learn__form')) return;
|
||||
const root = form.closest('[data-learn]');
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
endif
|
||||
|
||||
assign video_src = blank
|
||||
assign using_asset_video = false
|
||||
if section.settings.video != blank
|
||||
for source in section.settings.video.sources
|
||||
if source.mime_type == 'video/mp4' or source.format == 'mp4'
|
||||
@@ -30,16 +31,23 @@
|
||||
endfor
|
||||
endif
|
||||
if video_src == blank and section.settings.promo_link == blank
|
||||
assign video_src = 'nuevos-productos.mp4' | asset_url
|
||||
assign video_src = 'nuevos-productos-2.mp4' | asset_url
|
||||
assign using_asset_video = true
|
||||
endif
|
||||
|
||||
assign poster = section.settings.poster
|
||||
assign poster_url = blank
|
||||
if poster != blank
|
||||
if using_asset_video
|
||||
assign poster_url = 'nuevos-productos-poster.avif' | asset_url
|
||||
elsif poster != blank
|
||||
assign poster_url = poster | image_url: width: 1000
|
||||
endif
|
||||
|
||||
if video_src == blank and section.settings.promo_link != blank
|
||||
assign promo_href = section.settings.promo_link
|
||||
if promo_href == blank
|
||||
assign promo_href = more_url
|
||||
endif
|
||||
if promo_href != blank
|
||||
assign promo_tag = 'a'
|
||||
else
|
||||
assign promo_tag = 'div'
|
||||
@@ -47,7 +55,7 @@
|
||||
|
||||
assign products_to_show = section.settings.products_to_show | default: 8
|
||||
assign show_promo = false
|
||||
if poster != blank or video_src != blank
|
||||
if poster != blank or video_src != blank or using_asset_video
|
||||
assign show_promo = true
|
||||
endif
|
||||
%}
|
||||
@@ -95,10 +103,20 @@
|
||||
<{{ promo_tag }}
|
||||
class="bestsellers__promo"
|
||||
{% if promo_tag == 'a' %}
|
||||
href="{{ section.settings.promo_link }}"
|
||||
href="{{ promo_href }}"
|
||||
{% endif %}
|
||||
>
|
||||
{% if poster != blank %}
|
||||
{% if using_asset_video %}
|
||||
<img
|
||||
class="bestsellers__promo-image new-products__poster"
|
||||
src="{{ 'nuevos-productos-poster.avif' | asset_url }}"
|
||||
alt="{{ heading | escape }}"
|
||||
width="486"
|
||||
height="550"
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
>
|
||||
{% elsif poster != blank %}
|
||||
{{
|
||||
poster
|
||||
| image_url: width: 1400
|
||||
@@ -132,11 +150,19 @@
|
||||
<div class="bestsellers__slider">
|
||||
<div class="bestsellers__viewport" data-viewport tabindex="0">
|
||||
<div class="bestsellers__track" data-track>
|
||||
{% assign shown = 0 %}
|
||||
{% if product_collection != blank and product_collection.products_count > 0 %}
|
||||
{% for product in product_collection.products limit: products_to_show %}
|
||||
{% render 'bestsellers-card', product: product, form_suffix: section.id %}
|
||||
{% for product in product_collection.products %}
|
||||
{% if product.available %}
|
||||
{% render 'bestsellers-card', product: product, form_suffix: section.id %}
|
||||
{% assign shown = shown | plus: 1 %}
|
||||
{% endif %}
|
||||
{% if shown >= products_to_show %}
|
||||
{% break %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% elsif request.design_mode %}
|
||||
{% endif %}
|
||||
{% if shown == 0 and request.design_mode %}
|
||||
<p class="bestsellers__empty">{{ 'bestsellers.empty' | t }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
@@ -34,8 +34,27 @@
|
||||
{%- endif -%}
|
||||
</span>
|
||||
<span class="header__predictive-copy">
|
||||
{%- liquid
|
||||
assign ps_variant = product.selected_or_first_available_variant
|
||||
assign ps_on_sale = false
|
||||
if ps_variant.compare_at_price > ps_variant.price
|
||||
assign ps_on_sale = true
|
||||
assign ps_saving = ps_variant.compare_at_price | minus: ps_variant.price | times: 100.0 | divided_by: ps_variant.compare_at_price | round
|
||||
endif
|
||||
-%}
|
||||
{%- if ps_on_sale -%}
|
||||
<span class="inline-flex w-fit rounded-[3px] bg-[#f8d5ce] px-1.5 py-[3px] text-[10px] font-medium uppercase leading-none text-[#e35b4c]">{{ 'header.search_sale' | t }} -{{ ps_saving }}%</span>
|
||||
{%- endif -%}
|
||||
<span class="header__predictive-title">{{ product.title | escape }}</span>
|
||||
<span class="header__predictive-price">{{ product.price | money_without_trailing_zeros }}</span>
|
||||
<span class="header__predictive-price{% if ps_on_sale %} header__predictive-price--sale{% endif %}">
|
||||
{%- if ps_on_sale -%}
|
||||
<span class="sr-only">{{ 'header.search_sale_price' | t }}</span>
|
||||
{{ ps_variant.price | money_without_trailing_zeros }}
|
||||
<s class="ml-1 text-[13px] font-normal text-[#a3a3a3]"><span class="sr-only">{{ 'header.search_regular_price' | t }}</span>{{ ps_variant.compare_at_price | money_without_trailing_zeros }}</s>
|
||||
{%- else -%}
|
||||
{{ product.price | money_without_trailing_zeros }}
|
||||
{%- endif -%}
|
||||
</span>
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
+553
-35
@@ -30,8 +30,37 @@
|
||||
if excerpt == blank
|
||||
assign excerpt = product.metafields.custom.short_description.value | default: product.metafields.custom.excerpt.value
|
||||
endif
|
||||
if excerpt == blank
|
||||
assign excerpt = product.description | strip_html | truncate: 180
|
||||
assign excerpt_from_description = false
|
||||
if excerpt == blank and product.description != blank
|
||||
assign excerpt_from_description = true
|
||||
assign excerpt_parts = product.description | replace: '</p>', '[[br]]' | replace: '</h1>', '[[br]]' | replace: '</h2>', '[[br]]' | replace: '</h3>', '[[br]]' | replace: '</h4>', '[[br]]' | replace: '</h5>', '[[br]]' | replace: '</h6>', '[[br]]' | replace: '</li>', '[[br]]' | replace: '<br>', '[[br]]' | replace: '<br/>', '[[br]]' | replace: '<br />', '[[br]]' | strip_html | split: '[[br]]'
|
||||
comment
|
||||
First paragraph: the first <p> of the description (falls back to the first text block).
|
||||
endcomment
|
||||
assign excerpt = ''
|
||||
if product.description contains '</p>'
|
||||
assign excerpt = product.description | split: '</p>' | first | split: '<p' | last | split: '>' | slice: 1, 999 | join: '>' | strip_html | strip
|
||||
endif
|
||||
if excerpt == blank
|
||||
for part in excerpt_parts
|
||||
assign part_text = part | strip
|
||||
if part_text != blank
|
||||
assign excerpt = part_text
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
assign excerpt_count = 0
|
||||
for part in excerpt_parts
|
||||
assign part_text = part | strip
|
||||
if part_text != blank
|
||||
assign excerpt_count = excerpt_count | plus: 1
|
||||
endif
|
||||
endfor
|
||||
assign excerpt_has_more = false
|
||||
if excerpt_count > 1
|
||||
assign excerpt_has_more = true
|
||||
endif
|
||||
endif
|
||||
|
||||
assign how_field = product.metafields.custom.como_aplicarlo
|
||||
@@ -132,6 +161,17 @@
|
||||
assign show_reviews = true
|
||||
endif
|
||||
|
||||
comment
|
||||
Hide the reviews module (and the stars under the title) when the average rating is below 3.5.
|
||||
endcomment
|
||||
assign reviews_min_rating = section.settings.reviews_min_rating | default: 3.5 | times: 1.0
|
||||
assign rating_average = product.metafields.reviews.rating.value.rating | default: 0 | times: 1.0
|
||||
assign low_rating = false
|
||||
if rating_count > 0 and rating_average < reviews_min_rating
|
||||
assign low_rating = true
|
||||
assign show_reviews = false
|
||||
endif
|
||||
|
||||
assign review_pages = review_count | plus: 2 | divided_by: 3
|
||||
assign main_alt = main_image.alt | default: product.title
|
||||
%}
|
||||
@@ -146,8 +186,14 @@
|
||||
>
|
||||
<div class="product__hero">
|
||||
<div class="product__gallery">
|
||||
<div class="product__main">
|
||||
{% if main_image %}
|
||||
{% if main_image %}
|
||||
<button
|
||||
type="button"
|
||||
class="product__main"
|
||||
data-gallery-open
|
||||
data-full="{{ main_image | image_url: width: 2000 }}"
|
||||
aria-label="{{ 'product_page.gallery_open' | t }}"
|
||||
>
|
||||
{{
|
||||
main_image
|
||||
| image_url: width: 1400
|
||||
@@ -156,14 +202,16 @@
|
||||
alt: main_alt,
|
||||
loading: 'eager',
|
||||
fetchpriority: 'high',
|
||||
widths: '700, 1000, 1400',
|
||||
widths: '360, 540, 720, 1000, 1400',
|
||||
sizes: '(min-width: 1120px) 58vw, 100vw',
|
||||
data-main-image: 'true'
|
||||
}}
|
||||
{% else %}
|
||||
</button>
|
||||
{% else %}
|
||||
<div class="product__main">
|
||||
{{ 'product-1' | placeholder_svg_tag: 'product__main-image' }}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if product.images.size > 1 %}
|
||||
{% assign gallery_count = 0 %}
|
||||
{% if main_image != blank %}
|
||||
@@ -176,7 +224,13 @@
|
||||
{% endfor %}
|
||||
<div class="product__thumbs" data-product-thumbs>
|
||||
{% if main_image != blank %}
|
||||
<div class="product__thumb product__thumb--main">
|
||||
<button
|
||||
type="button"
|
||||
class="product__thumb product__thumb--main"
|
||||
data-gallery-open
|
||||
data-full="{{ main_image | image_url: width: 2000 }}"
|
||||
aria-label="{{ 'product_page.gallery_open' | t }}"
|
||||
>
|
||||
{{
|
||||
main_image
|
||||
| image_url: width: 1400
|
||||
@@ -184,27 +238,33 @@
|
||||
alt: main_alt,
|
||||
loading: 'eager',
|
||||
fetchpriority: 'high',
|
||||
widths: '700, 1000, 1400',
|
||||
sizes: '100vw',
|
||||
widths: '360, 540, 720, 1000, 1400',
|
||||
sizes: '92vw',
|
||||
draggable: false
|
||||
}}
|
||||
</div>
|
||||
</button>
|
||||
{% endif %}
|
||||
{% for image in product.images %}
|
||||
{% if image.id != main_image.id %}
|
||||
{% assign thumb_alt = image.alt | default: product.title %}
|
||||
<div class="product__thumb">
|
||||
<button
|
||||
type="button"
|
||||
class="product__thumb"
|
||||
data-gallery-open
|
||||
data-full="{{ image | image_url: width: 2000 }}"
|
||||
aria-label="{{ 'product_page.gallery_open' | t }}"
|
||||
>
|
||||
{{
|
||||
image
|
||||
| image_url: width: 900
|
||||
| image_tag:
|
||||
alt: thumb_alt,
|
||||
loading: 'lazy',
|
||||
widths: '400, 700, 900',
|
||||
sizes: '(max-width: 767px) 100vw, (min-width: 1120px) 28vw, 50vw',
|
||||
widths: '360, 540, 720, 900',
|
||||
sizes: '(max-width: 767px) 92vw, (min-width: 1120px) 28vw, 50vw',
|
||||
draggable: false
|
||||
}}
|
||||
</div>
|
||||
</button>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
@@ -223,6 +283,15 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if main_image %}
|
||||
<dialog class="product-lightbox" data-gallery-lightbox>
|
||||
<button type="button" class="product-lightbox__nav product-lightbox__nav--prev" data-gallery-prev aria-label="{{ 'product_page.gallery_prev' | t }}" hidden>‹</button>
|
||||
<img class="product-lightbox__image" alt="" data-gallery-image>
|
||||
<button type="button" class="product-lightbox__nav product-lightbox__nav--next" data-gallery-next aria-label="{{ 'product_page.gallery_next' | t }}" hidden>›</button>
|
||||
<button type="button" class="product-lightbox__close" data-gallery-close aria-label="{{ 'product_page.gallery_close' | t }}">×</button>
|
||||
<p class="product-lightbox__count" data-gallery-count data-template="{{ 'product_page.gallery_count' | t: current: '__C__', total: '__T__' }}" hidden></p>
|
||||
</dialog>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="product__details">
|
||||
@@ -242,7 +311,7 @@
|
||||
<p class="product__subtitle">{{ subtitle | escape }}</p>
|
||||
{% endif %}
|
||||
|
||||
{% if rating_count > 0 %}
|
||||
{% if rating_count > 0 and low_rating == false %}
|
||||
<div class="product__rating">
|
||||
<span class="product__stars" aria-hidden="true">
|
||||
{% for star in (1..5) %}
|
||||
@@ -263,7 +332,37 @@
|
||||
</p>
|
||||
|
||||
{% if excerpt != blank %}
|
||||
<p class="product__excerpt">{{ excerpt | escape }}</p>
|
||||
{% if excerpt_from_description %}
|
||||
<div class="product__excerpt" data-excerpt>
|
||||
<p class="product__excerpt-short">{{ excerpt | escape }}</p>
|
||||
{%- if excerpt_has_more -%}
|
||||
<div class="product__excerpt-full" id="ProductExcerptFull-{{ section.id }}" hidden>
|
||||
{%- for part in excerpt_parts -%}
|
||||
{%- assign part_text = part | strip -%}
|
||||
{%- if part_text != blank -%}<p>{{ part_text | escape }}</p>{%- endif -%}
|
||||
{%- endfor -%}
|
||||
</div>
|
||||
<button type="button" class="product__excerpt-toggle" aria-expanded="false" aria-controls="ProductExcerptFull-{{ section.id }}" data-more="Leer más" data-less="Leer menos">Leer más</button>
|
||||
<script nolazy>
|
||||
(function () {
|
||||
var root = document.currentScript.closest('[data-excerpt]');
|
||||
var btn = root.querySelector('.product__excerpt-toggle');
|
||||
var full = root.querySelector('.product__excerpt-full');
|
||||
var shortEl = root.querySelector('.product__excerpt-short');
|
||||
if (btn.dataset.bound) return; btn.dataset.bound = '1';
|
||||
btn.addEventListener('click', function () {
|
||||
var open = btn.getAttribute('aria-expanded') !== 'true';
|
||||
full.hidden = !open; shortEl.hidden = open;
|
||||
btn.setAttribute('aria-expanded', String(open));
|
||||
btn.textContent = open ? btn.dataset.less : btn.dataset.more;
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
{%- endif -%}
|
||||
</div>
|
||||
{% else %}
|
||||
<p class="product__excerpt">{{ excerpt | escape }}</p>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% form 'product', product, id: 'product-form', class: 'product__form' %}
|
||||
@@ -315,18 +414,35 @@
|
||||
</div>
|
||||
{% endunless %}
|
||||
|
||||
<ul class="product__trust">
|
||||
<ul class="product__trust overflow-hidden">
|
||||
<li class="product__trust-row">
|
||||
<span class="product__trust-icon">{{ 'icon-marquee-shipping.svg' | inline_asset_content }}</span>
|
||||
<span>{{ 'product_page.shipping' | t }}</span>
|
||||
</li>
|
||||
<li class="product__trust-row">
|
||||
<span class="product__trust-icon">{{ 'icon-marquee-card.svg' | inline_asset_content }}</span>
|
||||
<span>{{ 'product_page.payment' | t }}</span>
|
||||
<span class="inline-flex min-w-0 items-center gap-x-2 gap-y-1">
|
||||
<span>{{ 'product_page.payment' | t }}</span>
|
||||
<span class="inline-flex flex-nowrap items-center gap-1">
|
||||
<img class="h-6 w-auto max-w-none shrink-0" src="{{ 'pay-visa.svg' | asset_url }}" alt="Visa" width="38" height="24" loading="lazy" decoding="async">
|
||||
<img class="h-6 w-auto max-w-none shrink-0" src="{{ 'pay-mastercard.svg' | asset_url }}" alt="Mastercard" width="38" height="24" loading="lazy" decoding="async">
|
||||
<img class="h-6 w-auto max-w-none shrink-0" src="{{ 'pay-amex.svg' | asset_url }}" alt="American Express" width="38" height="24" loading="lazy" decoding="async">
|
||||
<img class="h-6 w-auto max-w-none shrink-0" src="{{ 'pay-paypal.svg' | asset_url }}" alt="PayPal" width="38" height="24" loading="lazy" decoding="async">
|
||||
{{ 'apple_pay' | payment_type_svg_tag: class: 'h-6 w-auto max-w-none shrink-0' }}
|
||||
{{ 'google_pay' | payment_type_svg_tag: class: 'h-6 w-auto max-w-none shrink-0' }}
|
||||
</span>
|
||||
</span>
|
||||
</li>
|
||||
<li class="product__trust-row">
|
||||
<span class="product__trust-icon">{{ 'icon-marquee-wallet.svg' | inline_asset_content }}</span>
|
||||
<span>{{ 'product_page.installments' | t }}</span>
|
||||
<span class="inline-flex min-w-0 items-center gap-x-2 gap-y-1">
|
||||
<span>{{ 'product_page.installments_with' | t }}</span>
|
||||
<span class="inline-flex flex-nowrap items-center gap-1">
|
||||
<img class="h-6 w-auto max-w-none shrink-0" src="{{ 'pay-mercadopago.svg' | asset_url }}" alt="Mercado Pago" width="38" height="24" loading="lazy" decoding="async">
|
||||
<img class="h-6 w-auto max-w-none shrink-0" src="{{ 'pay-kueski.svg' | asset_url }}" alt="Kueski Pay" width="48" height="30" loading="lazy" decoding="async">
|
||||
<img class="h-6 w-auto max-w-none shrink-0" src="{{ 'pay-aplazo.svg' | asset_url }}" alt="Aplazo" width="48" height="30" loading="lazy" decoding="async">
|
||||
</span>
|
||||
</span>
|
||||
</li>
|
||||
<li class="product__trust-row">
|
||||
<span class="product__trust-icon">{{ 'icon-marquee-guarantee.svg' | inline_asset_content }}</span>
|
||||
@@ -334,6 +450,7 @@
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="product__subscription" data-kv-subscription-target></div>
|
||||
<div class="product__purchase">
|
||||
<div class="product__qty">
|
||||
<button type="button" data-qty="down" aria-label="{{ 'product_page.decrease' | t }}">−</button>
|
||||
@@ -360,6 +477,113 @@
|
||||
</button>
|
||||
{% endform %}
|
||||
|
||||
{% if additional_checkout_buttons %}
|
||||
<div class="product__express" data-wallets {% unless current_variant.available %}hidden{% endunless %}>
|
||||
<p class="product__express-label">{{ 'product_page.express' | t }}</p>
|
||||
{{ content_for_additional_checkout_buttons }}
|
||||
</div>
|
||||
<script nolazy>
|
||||
(() => {
|
||||
const root = document.querySelector('[data-product-page]');
|
||||
const wallets = root?.querySelector('[data-wallets]');
|
||||
const form = root?.querySelector('.product__form');
|
||||
if (!wallets || !form || wallets.dataset.bound) return;
|
||||
wallets.dataset.bound = 'true';
|
||||
|
||||
const rootPath = window.Shopify?.routes?.root || '/';
|
||||
let checkoutStarted = false;
|
||||
|
||||
const request = (url, body) => {
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', url, false);
|
||||
xhr.setRequestHeader('Accept', 'application/json');
|
||||
if (body) xhr.setRequestHeader('Content-Type', 'application/json');
|
||||
xhr.send(body || null);
|
||||
return xhr.status >= 200 && xhr.status < 300 ? xhr.responseText : '';
|
||||
};
|
||||
|
||||
const variantId = () => Number(form.querySelector('[name="id"]')?.value);
|
||||
const variantQuantity = () => Math.max(1, Number(form.querySelector('[name="quantity"]')?.value) || 1);
|
||||
|
||||
const addCurrentVariant = () => {
|
||||
checkoutStarted = true;
|
||||
const id = variantId();
|
||||
const quantity = variantQuantity();
|
||||
if (!id) return;
|
||||
try {
|
||||
const cartRequest = new XMLHttpRequest();
|
||||
cartRequest.open('GET', `${rootPath}cart.js`, false);
|
||||
cartRequest.setRequestHeader('Accept', 'application/json');
|
||||
cartRequest.send();
|
||||
const cart = cartRequest.status === 200 ? JSON.parse(cartRequest.responseText) : { items: [] };
|
||||
const already = (cart.items || []).some((item) => item.variant_id === id);
|
||||
if (already) return;
|
||||
request(`${form.action}.js`, JSON.stringify({ id, quantity }));
|
||||
} catch (error) {}
|
||||
};
|
||||
|
||||
const walletNames = (element) => {
|
||||
try {
|
||||
return JSON.parse(element?.getAttribute('wallet-configs') || '[]').map((wallet) => wallet.name);
|
||||
} catch (error) {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
const ensureGooglePay = async () => {
|
||||
const current = wallets.querySelector('shopify-accelerated-checkout-cart');
|
||||
if (!current || wallets.hidden || walletNames(current).includes('google_pay')) return;
|
||||
const id = variantId();
|
||||
if (!id) return;
|
||||
|
||||
let lineKey = '';
|
||||
try {
|
||||
const addedResponse = await fetch(`${form.action}.js`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
||||
body: JSON.stringify({ id, quantity: variantQuantity() }),
|
||||
});
|
||||
if (!addedResponse.ok) return;
|
||||
const added = await addedResponse.json();
|
||||
lineKey = added.key || added.items?.find((item) => item.variant_id === id)?.key || '';
|
||||
const sectionId = root.closest('[id^="shopify-section"]')?.id?.replace('shopify-section-', '');
|
||||
const html = await fetch(`${window.location.pathname}?section_id=${encodeURIComponent(sectionId || '')}`, {
|
||||
cache: 'no-store',
|
||||
headers: { Accept: 'text/html' },
|
||||
}).then((response) => response.text());
|
||||
const next = new DOMParser().parseFromString(html, 'text/html').querySelector('shopify-accelerated-checkout-cart');
|
||||
if (!next || !walletNames(next).includes('google_pay')) return;
|
||||
current.replaceWith(next);
|
||||
await new Promise((resolve) => {
|
||||
const started = Date.now();
|
||||
const waitForButton = () => {
|
||||
if (wallets.querySelector('shopify-google-pay-button') || Date.now() - started > 8000) resolve();
|
||||
else window.setTimeout(waitForButton, 200);
|
||||
};
|
||||
waitForButton();
|
||||
});
|
||||
} catch (error) {
|
||||
} finally {
|
||||
if (lineKey && !checkoutStarted) {
|
||||
await fetch(`${rootPath}cart/change.js`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
||||
body: JSON.stringify({ id: lineKey, quantity: 0 }),
|
||||
}).catch(() => {});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
wallets.addEventListener('pointerdown', addCurrentVariant);
|
||||
window.addEventListener('blur', () => {
|
||||
const active = document.activeElement;
|
||||
if (active && wallets.contains(active)) addCurrentVariant();
|
||||
});
|
||||
ensureGooglePay();
|
||||
})();
|
||||
</script>
|
||||
{% endif %}
|
||||
|
||||
{% liquid
|
||||
assign sticky_image = current_variant.image
|
||||
if sticky_image == blank and current_variant.featured_media
|
||||
@@ -413,6 +637,51 @@
|
||||
document.body.appendChild(bar);
|
||||
})();
|
||||
</script>
|
||||
<script nolazy>
|
||||
// Subscription apps (Konvertti Addons) inject their purchase-options widget next to the
|
||||
// add-to-cart button. Keep the layout: widget on its own row above [qty | Añadir], "Comprar" below,
|
||||
// and mirror the chosen option's price in the sticky footer bar.
|
||||
(function () {
|
||||
if (window.__seasonPurchaseOptions) return;
|
||||
window.__seasonPurchaseOptions = true;
|
||||
var WIDGETS = '.kv-sub, [data-kv-subscription]';
|
||||
var tidy = function () {
|
||||
var row = document.querySelector('#product-form .product__purchase');
|
||||
if (!row) return;
|
||||
row.querySelectorAll(WIDGETS).forEach(function (w) {
|
||||
var node = w.closest('.shopify-block') && row.contains(w.closest('.shopify-block')) ? w.closest('.shopify-block') : w;
|
||||
if (node.parentElement === row) row.parentElement.insertBefore(node, row);
|
||||
});
|
||||
};
|
||||
var priceText = function (el) {
|
||||
if (!el) return '';
|
||||
var m = (el.textContent || '').match(/[$€£]\s?[\d.,]+|[\d.,]+\s?[$€£]/);
|
||||
return m ? m[0].trim() : '';
|
||||
};
|
||||
var syncSticky = function () {
|
||||
var sticky = document.querySelector('[data-sticky-price]');
|
||||
var checked = document.querySelector('.kv-sub input[type="radio"]:checked');
|
||||
if (!sticky || !checked) return;
|
||||
var label = checked.closest('.kv-sub__option');
|
||||
var price = priceText(label && label.querySelector('.kv-sub__price'));
|
||||
if (price) sticky.textContent = price;
|
||||
};
|
||||
var run = function () { tidy(); syncSticky(); };
|
||||
document.addEventListener('change', function (e) { if (e.target.closest && e.target.closest('.kv-sub')) window.setTimeout(run, 0); });
|
||||
document.addEventListener('kv:plan-change', function () { window.setTimeout(run, 0); });
|
||||
document.addEventListener('click', function (e) { if (e.target.closest && e.target.closest('.kv-sub, [data-variant-option], .product__variant')) window.setTimeout(run, 50); });
|
||||
var start = function () {
|
||||
run();
|
||||
var form = document.getElementById('product-form');
|
||||
if (form && 'MutationObserver' in window) {
|
||||
var t = 0;
|
||||
new MutationObserver(function () { window.clearTimeout(t); t = window.setTimeout(run, 30); })
|
||||
.observe(form.parentElement || form, { childList: true, subtree: true, characterData: true });
|
||||
}
|
||||
};
|
||||
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', start); else start();
|
||||
})();
|
||||
</script>
|
||||
|
||||
<button
|
||||
class="product__favorite"
|
||||
@@ -421,9 +690,6 @@
|
||||
data-product-id="{{ product.id }}"
|
||||
data-product-handle="{{ product.handle }}"
|
||||
aria-pressed="false"
|
||||
aria-label="{{ 'bestsellers.save' | t: product: product.title }}"
|
||||
data-label-save="{{ 'bestsellers.save' | t: product: product.title }}"
|
||||
data-label-saved="{{ 'bestsellers.saved' | t: product: product.title }}"
|
||||
>
|
||||
<svg width="22" height="22" viewBox="0 0 25 25" aria-hidden="true" focusable="false">
|
||||
<path d="M17.2324 3.90625C14.0625 3.90625 12.5 7.03125 12.5 7.03125C12.5 7.03125 10.9375 3.90625 7.76758 3.90625C5.19141 3.90625 3.15137 6.06152 3.125 8.6333C3.07129 13.9717 7.35986 17.7681 12.0605 20.9585C12.1901 21.0467 12.3433 21.0938 12.5 21.0938C12.6567 21.0938 12.8099 21.0467 12.9395 20.9585C17.6396 17.7681 21.9282 13.9717 21.875 8.6333C21.8486 6.06152 19.8086 3.90625 17.2324 3.90625Z" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
@@ -547,7 +813,7 @@
|
||||
{% if also_shown < 4 and item.id != blank and item.id != product.id %}
|
||||
{% unless routine_ids contains item_token %}
|
||||
{% assign also_key = 'also-' | append: item.id %}
|
||||
{% render 'collection-card', product: item, form_suffix: also_key %}
|
||||
{% render 'collection-card', product: item, form_suffix: also_key, badge_mode: 'collection' %}
|
||||
{% assign also_shown = also_shown | plus: 1 %}
|
||||
{% endunless %}
|
||||
{% endif %}
|
||||
@@ -575,6 +841,8 @@
|
||||
data-product-handle="{{ product.handle | escape }}"
|
||||
data-shop="{{ shop.permanent_domain | escape }}"
|
||||
data-reviews-shop="{{ section.settings.reviews_shop | escape }}"
|
||||
data-min-rating="{{ reviews_min_rating }}"
|
||||
data-product-image="{% if product.featured_image %}https:{{ product.featured_image | image_url: width: 96 }}{% endif %}"
|
||||
data-reviews-storefront="{{ section.settings.reviews_storefront | escape }}"
|
||||
>
|
||||
<div class="product__reviews-head">
|
||||
@@ -687,7 +955,7 @@
|
||||
|
||||
const applyWish = () => {
|
||||
const saved = readWishlist().map((item) => item.id);
|
||||
root.querySelectorAll('[data-product-wish]').forEach((button) => {
|
||||
root.querySelectorAll('[data-product-wish], [data-wishlist]').forEach((button) => {
|
||||
const active = saved.includes(String(button.dataset.productId));
|
||||
button.classList.toggle('is-active', active);
|
||||
button.setAttribute('aria-pressed', active ? 'true' : 'false');
|
||||
@@ -709,29 +977,85 @@
|
||||
});
|
||||
|
||||
const thumbs = root.querySelector('[data-product-thumbs]');
|
||||
const lightbox = root.querySelector('[data-gallery-lightbox]');
|
||||
const lightboxImage = lightbox ? lightbox.querySelector('[data-gallery-image]') : null;
|
||||
const gallerySlides = () => {
|
||||
const seen = new Set();
|
||||
const slides = [];
|
||||
root.querySelectorAll('[data-gallery-open]').forEach((button) => {
|
||||
const src = button.getAttribute('data-full');
|
||||
if (!src || seen.has(src)) return;
|
||||
seen.add(src);
|
||||
const image = button.querySelector('img');
|
||||
slides.push({ src, alt: image ? image.alt : '' });
|
||||
});
|
||||
return slides;
|
||||
};
|
||||
let slides = [];
|
||||
let slideIndex = 0;
|
||||
const showSlide = (next) => {
|
||||
if (!lightbox || !lightboxImage || !slides.length) return;
|
||||
slideIndex = (next + slides.length) % slides.length;
|
||||
const slide = slides[slideIndex];
|
||||
lightboxImage.src = slide.src;
|
||||
lightboxImage.alt = slide.alt;
|
||||
const count = lightbox.querySelector('[data-gallery-count]');
|
||||
const multiple = slides.length > 1;
|
||||
if (count) {
|
||||
count.hidden = !multiple;
|
||||
const template = count.getAttribute('data-template') || '';
|
||||
count.textContent = template.replace('__C__', String(slideIndex + 1)).replace('__T__', String(slides.length));
|
||||
}
|
||||
lightbox.querySelectorAll('[data-gallery-prev], [data-gallery-next]').forEach((button) => {
|
||||
button.hidden = !multiple;
|
||||
});
|
||||
};
|
||||
const openLightbox = (button) => {
|
||||
if (!button || !lightbox || !lightboxImage) return;
|
||||
const full = button.getAttribute('data-full');
|
||||
if (!full) return;
|
||||
slides = gallerySlides();
|
||||
const start = Math.max(0, slides.findIndex((slide) => slide.src === full));
|
||||
showSlide(start);
|
||||
if (!lightbox.open) lightbox.showModal();
|
||||
};
|
||||
if (thumbs) {
|
||||
let pointerId = null;
|
||||
let startX = 0;
|
||||
let startScroll = 0;
|
||||
let dragged = false;
|
||||
let pending = null;
|
||||
|
||||
thumbs.addEventListener('pointerdown', (event) => {
|
||||
if (event.pointerType !== 'mouse' || event.button !== 0) return;
|
||||
if (event.pointerType === 'mouse' && event.button !== 0) return;
|
||||
pointerId = event.pointerId;
|
||||
startX = event.clientX;
|
||||
startScroll = thumbs.scrollLeft;
|
||||
thumbs.classList.add('is-dragging');
|
||||
thumbs.setPointerCapture(pointerId);
|
||||
dragged = false;
|
||||
pending = event.target.closest('[data-gallery-open]');
|
||||
});
|
||||
|
||||
thumbs.addEventListener('pointermove', (event) => {
|
||||
if (event.pointerId !== pointerId) return;
|
||||
thumbs.scrollLeft = startScroll - (event.clientX - startX);
|
||||
const delta = event.clientX - startX;
|
||||
if (Math.abs(delta) > 8) {
|
||||
dragged = true;
|
||||
if (!thumbs.classList.contains('is-dragging')) {
|
||||
thumbs.classList.add('is-dragging');
|
||||
thumbs.setPointerCapture(pointerId);
|
||||
}
|
||||
thumbs.scrollLeft = startScroll - delta;
|
||||
}
|
||||
});
|
||||
|
||||
const endDrag = (event) => {
|
||||
if (event.pointerId !== pointerId) return;
|
||||
const button = pending;
|
||||
pointerId = null;
|
||||
pending = null;
|
||||
thumbs.classList.remove('is-dragging');
|
||||
if (event.type === 'pointercancel' || dragged) return;
|
||||
openLightbox(button);
|
||||
};
|
||||
|
||||
thumbs.addEventListener('pointerup', endDrag);
|
||||
@@ -750,12 +1074,88 @@
|
||||
thumbs.addEventListener('scroll', syncProgress, { passive: true });
|
||||
window.addEventListener('resize', syncProgress);
|
||||
syncProgress();
|
||||
|
||||
thumbs.addEventListener('click', (event) => {
|
||||
if (dragged) return;
|
||||
openLightbox(event.target.closest('[data-gallery-open]'));
|
||||
});
|
||||
}
|
||||
|
||||
const mainImage = root.querySelector('.product__main[data-gallery-open]');
|
||||
if (mainImage) {
|
||||
mainImage.addEventListener('click', () => openLightbox(mainImage));
|
||||
}
|
||||
|
||||
if (lightbox && lightboxImage) {
|
||||
let swipeX = null;
|
||||
let swiped = false;
|
||||
lightbox.addEventListener('click', (event) => {
|
||||
if (event.target.closest('[data-gallery-close]')) {
|
||||
lightbox.close();
|
||||
return;
|
||||
}
|
||||
if (event.target.closest('[data-gallery-prev]')) {
|
||||
showSlide(slideIndex - 1);
|
||||
return;
|
||||
}
|
||||
if (event.target.closest('[data-gallery-next]')) {
|
||||
showSlide(slideIndex + 1);
|
||||
return;
|
||||
}
|
||||
if (swiped) {
|
||||
swiped = false;
|
||||
return;
|
||||
}
|
||||
const rect = lightbox.getBoundingClientRect();
|
||||
const inside = event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
|
||||
if (!inside) lightbox.close();
|
||||
});
|
||||
lightbox.addEventListener('keydown', (event) => {
|
||||
if (event.key === 'ArrowLeft') {
|
||||
event.preventDefault();
|
||||
showSlide(slideIndex - 1);
|
||||
}
|
||||
if (event.key === 'ArrowRight') {
|
||||
event.preventDefault();
|
||||
showSlide(slideIndex + 1);
|
||||
}
|
||||
});
|
||||
lightbox.addEventListener('pointerdown', (event) => {
|
||||
if (event.target !== lightboxImage) return;
|
||||
swipeX = event.clientX;
|
||||
swiped = false;
|
||||
});
|
||||
lightbox.addEventListener('pointerup', (event) => {
|
||||
if (swipeX == null || event.target !== lightboxImage) return;
|
||||
const delta = event.clientX - swipeX;
|
||||
swipeX = null;
|
||||
if (Math.abs(delta) < 40) return;
|
||||
swiped = true;
|
||||
showSlide(slideIndex + (delta < 0 ? 1 : -1));
|
||||
});
|
||||
lightbox.addEventListener('close', () => {
|
||||
lightboxImage.removeAttribute('src');
|
||||
});
|
||||
}
|
||||
|
||||
const form = root.querySelector('.product__form');
|
||||
const qtyInput = root.querySelector('[data-qty-input]');
|
||||
|
||||
root.addEventListener('click', (event) => {
|
||||
const wishCard = event.target.closest('[data-wishlist]');
|
||||
if (wishCard && root.contains(wishCard)) {
|
||||
const id = String(wishCard.dataset.productId || '');
|
||||
const cardHandle = String(wishCard.dataset.productHandle || '');
|
||||
if (!id) return;
|
||||
const saved = readWishlist();
|
||||
const next = saved.some((item) => item.id === id)
|
||||
? saved.filter((item) => item.id !== id)
|
||||
: saved.concat({ id, handle: cardHandle });
|
||||
writeWishlist(next);
|
||||
applyWish();
|
||||
return;
|
||||
}
|
||||
|
||||
const wish = event.target.closest('[data-product-wish]');
|
||||
if (wish && root.contains(wish)) {
|
||||
const id = String(wish.dataset.productId || '');
|
||||
@@ -783,7 +1183,10 @@
|
||||
node.classList.toggle('is-selected', node === option);
|
||||
});
|
||||
const idInput = form?.querySelector('[name="id"]');
|
||||
if (idInput) idInput.value = option.dataset.id || idInput.value;
|
||||
if (idInput) {
|
||||
idInput.value = option.dataset.id || idInput.value;
|
||||
idInput.dispatchEvent(new Event('change', { bubbles: true }));
|
||||
}
|
||||
const price = root.querySelector('[data-price]');
|
||||
if (price) price.textContent = option.dataset.price || '';
|
||||
const compare = root.querySelector('[data-compare]');
|
||||
@@ -816,10 +1219,16 @@
|
||||
}
|
||||
if (stickyPrice) stickyPrice.textContent = option.dataset.price || '';
|
||||
if (buyButton) buyButton.disabled = !available;
|
||||
const wallets = root.querySelector('[data-wallets]');
|
||||
if (wallets) wallets.hidden = !available;
|
||||
const main = root.querySelector('[data-main-image]');
|
||||
if (main && option.dataset.image) {
|
||||
main.removeAttribute('srcset');
|
||||
main.src = option.dataset.image;
|
||||
const mainButton = main.closest('[data-gallery-open]');
|
||||
if (mainButton) mainButton.setAttribute('data-full', option.dataset.image);
|
||||
const twin = root.querySelector('.product__thumb--main[data-gallery-open]');
|
||||
if (twin) twin.setAttribute('data-full', option.dataset.image);
|
||||
}
|
||||
const stickyImage = root.querySelector('[data-sticky-image]');
|
||||
if (stickyImage && option.dataset.image) {
|
||||
@@ -828,6 +1237,48 @@
|
||||
}
|
||||
});
|
||||
|
||||
root.addEventListener('submit', async (event) => {
|
||||
const cardForm = event.target;
|
||||
if (!(cardForm instanceof HTMLFormElement) || !cardForm.hasAttribute('data-collection-card') || !root.contains(cardForm)) return;
|
||||
event.preventDefault();
|
||||
const button = event.submitter instanceof HTMLButtonElement ? event.submitter : cardForm.querySelector('[type="submit"]');
|
||||
const variantId = cardForm.querySelector('[name="id"]')?.value;
|
||||
if (!button || button.disabled || !variantId) return;
|
||||
const buttons = [...cardForm.querySelectorAll('button')];
|
||||
buttons.forEach((item) => {
|
||||
item.disabled = true;
|
||||
});
|
||||
const buyNow = button.hasAttribute('data-buy');
|
||||
try {
|
||||
const addResponse = await fetch(`${cardForm.action}.js`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Accept: 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ id: Number(variantId), quantity: 1 }),
|
||||
});
|
||||
if (!addResponse.ok) {
|
||||
cardForm.submit();
|
||||
return;
|
||||
}
|
||||
if (buyNow) {
|
||||
const base = (root.dataset.root || '/').replace(/\/?$/, '/');
|
||||
window.location.href = `${base}checkout`;
|
||||
return;
|
||||
}
|
||||
document.dispatchEvent(new CustomEvent('season:cart:open'));
|
||||
} catch (error) {
|
||||
cardForm.submit();
|
||||
} finally {
|
||||
if (!buyNow) {
|
||||
buttons.forEach((item) => {
|
||||
item.disabled = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
form?.addEventListener('submit', async (event) => {
|
||||
const submitter = event.submitter;
|
||||
if (!(submitter instanceof HTMLButtonElement) || !submitter.hasAttribute('data-buy')) return;
|
||||
@@ -906,6 +1357,7 @@
|
||||
list.replaceChildren(...nodes);
|
||||
block.hidden = false;
|
||||
block.dataset.filled = 'true';
|
||||
applyWish();
|
||||
} catch (error) {
|
||||
block.hidden = true;
|
||||
}
|
||||
@@ -936,7 +1388,15 @@
|
||||
return (parsed.body.textContent || '').trim();
|
||||
};
|
||||
|
||||
const renderReviews = (reviews, append) => {
|
||||
const avatarIcon = '<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="8" r="3.25" stroke="currentColor" stroke-width="1.4"/><path d="M5.2 19.4c1.15-3.15 3.35-4.7 6.8-4.7s5.65 1.55 6.8 4.7" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/></svg>';
|
||||
const pictureUrl = (pic) => {
|
||||
if (!pic) return '';
|
||||
if (typeof pic === 'string') return pic;
|
||||
return (pic.urls && (pic.urls.compact || pic.urls.small || pic.urls.original)) || pic.compact || pic.small || pic.original || '';
|
||||
};
|
||||
const fallbackProductImage = reviewsRoot.dataset.productImage || '';
|
||||
|
||||
const renderReviews = (reviews, append, data) => {
|
||||
if (!append) list.replaceChildren();
|
||||
reviews.forEach((review) => {
|
||||
const rating = Math.max(1, Math.min(5, Math.round(Number(review.rating) || 0)));
|
||||
@@ -966,7 +1426,21 @@
|
||||
const avatar = document.createElement('span');
|
||||
avatar.className = 'product__avatar';
|
||||
avatar.setAttribute('aria-hidden', 'true');
|
||||
avatar.innerHTML = '<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="8" r="3.25" stroke="currentColor" stroke-width="1.4"/><path d="M5.2 19.4c1.15-3.15 3.35-4.7 6.8-4.7s5.65 1.55 6.8 4.7" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/></svg>';
|
||||
const avatarUrl = review.avatar_image_url || (review.gravatar_hash ? 'https://www.gravatar.com/avatar/' + review.gravatar_hash + '?s=96&d=404' : '');
|
||||
if (avatarUrl) {
|
||||
const avatarImg = document.createElement('img');
|
||||
avatarImg.className = 'product__avatar-img';
|
||||
avatarImg.src = avatarUrl;
|
||||
avatarImg.alt = '';
|
||||
avatarImg.width = 48;
|
||||
avatarImg.height = 48;
|
||||
avatarImg.loading = 'lazy';
|
||||
avatarImg.decoding = 'async';
|
||||
avatarImg.addEventListener('error', () => { avatar.innerHTML = avatarIcon; }, { once: true });
|
||||
avatar.append(avatarImg);
|
||||
} else {
|
||||
avatar.innerHTML = avatarIcon;
|
||||
}
|
||||
const name = document.createElement('p');
|
||||
name.className = 'product__review-name';
|
||||
name.textContent = review.reviewer_name || 'Cliente';
|
||||
@@ -978,6 +1452,33 @@
|
||||
text.textContent = body || review.title || '';
|
||||
|
||||
article.append(stars, person, text);
|
||||
|
||||
const photos = (review.pictures_urls || []).map(pictureUrl).filter(Boolean);
|
||||
if (photos.length) {
|
||||
const gallery = document.createElement('div');
|
||||
gallery.className = 'product__review-photos';
|
||||
photos.slice(0, 4).forEach((src) => {
|
||||
const img = document.createElement('img');
|
||||
img.src = src; img.alt = 'Foto de ' + (review.reviewer_name || 'cliente');
|
||||
img.width = 64; img.height = 64; img.loading = 'lazy'; img.decoding = 'async';
|
||||
gallery.append(img);
|
||||
});
|
||||
article.append(gallery);
|
||||
}
|
||||
|
||||
const productImage = review.product_variant_image_url || (data && data.image_url) || fallbackProductImage;
|
||||
if (productImage) {
|
||||
const productRow = document.createElement('div');
|
||||
productRow.className = 'product__review-product';
|
||||
const thumb = document.createElement('img');
|
||||
thumb.src = productImage + (productImage.includes('?') ? '&' : '?') + 'width=96';
|
||||
thumb.alt = '';
|
||||
thumb.width = 40; thumb.height = 40; thumb.loading = 'lazy'; thumb.decoding = 'async';
|
||||
const label = document.createElement('span');
|
||||
label.textContent = review.product_title || (data && data.product_name) || '';
|
||||
productRow.append(thumb, label);
|
||||
article.append(productRow);
|
||||
}
|
||||
list.append(article);
|
||||
});
|
||||
};
|
||||
@@ -1006,7 +1507,11 @@
|
||||
cache.set(page, await response.json());
|
||||
}
|
||||
const data = cache.get(page);
|
||||
renderReviews(data.reviews || [], append);
|
||||
if (page === 1 && Number(data.number_of_reviews) > 0 && Number(data.average_rating) < (Number(reviewsRoot.dataset.minRating) || 0)) {
|
||||
reviewsRoot.hidden = true;
|
||||
return;
|
||||
}
|
||||
renderReviews(data.reviews || [], append, data);
|
||||
updateMore(page, data.pagination ? data.pagination.total_pages : 1);
|
||||
} finally {
|
||||
loading = false;
|
||||
@@ -1087,6 +1592,16 @@
|
||||
"type": "paragraph",
|
||||
"content": "t:product_page.metafields"
|
||||
},
|
||||
{
|
||||
"type": "range",
|
||||
"id": "reviews_min_rating",
|
||||
"label": "Calificación mínima para mostrar reseñas",
|
||||
"info": "Si el promedio del producto es menor, se ocultan las reseñas y las estrellas. 0 = mostrar siempre.",
|
||||
"min": 0,
|
||||
"max": 5,
|
||||
"step": 0.1,
|
||||
"default": 3.5
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"id": "reviews_shop",
|
||||
@@ -1103,7 +1618,10 @@
|
||||
}
|
||||
],
|
||||
"disabled_on": {
|
||||
"groups": ["header", "footer"]
|
||||
"groups": [
|
||||
"header",
|
||||
"footer"
|
||||
]
|
||||
}
|
||||
}
|
||||
{% endschema %}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
{% if collection != blank %}
|
||||
{% for product in collection.products limit: 4 %}
|
||||
{% assign card_suffix = section.id | append: '-recent-' | append: forloop.index %}
|
||||
{% render 'collection-card', product: product, form_suffix: card_suffix %}
|
||||
{% render 'collection-card', product: product, form_suffix: card_suffix, badge_mode: 'collection' %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
+115
-4
@@ -6,10 +6,11 @@
|
||||
endif
|
||||
|
||||
if section.settings.cover_link != blank
|
||||
assign cover_tag = 'a'
|
||||
assign cover_href = section.settings.cover_link
|
||||
else
|
||||
assign cover_tag = 'div'
|
||||
assign cover_href = '/collections/kits-skincare-facial'
|
||||
endif
|
||||
assign cover_tag = 'a'
|
||||
%}
|
||||
|
||||
<section class="routine full-width">
|
||||
@@ -17,7 +18,7 @@
|
||||
<{{ cover_tag }}
|
||||
class="routine__cover"
|
||||
{% if cover_tag == 'a' %}
|
||||
href="{{ section.settings.cover_link }}"
|
||||
href="{{ cover_href }}"
|
||||
{% endif %}
|
||||
>
|
||||
{% if section.settings.cover_image != blank %}
|
||||
@@ -47,7 +48,8 @@
|
||||
<h2 class="routine__heading">{{ heading | escape | newline_to_br }}</h2>
|
||||
</{{ cover_tag }}>
|
||||
|
||||
<div class="routine__steps">
|
||||
<div class="routine__steps" data-routine-viewport>
|
||||
<div class="routine__track" data-routine-track>
|
||||
{% for block in section.blocks %}
|
||||
{% liquid
|
||||
if block.settings.title != blank
|
||||
@@ -140,10 +142,119 @@
|
||||
<p class="routine__empty">{{ 'routine.empty' | t }}</p>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="routine__progress" aria-hidden="true">
|
||||
<span class="routine__progress-bar" data-routine-bar></span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<script nolazy>
|
||||
(() => {
|
||||
const sliderQuery = window.matchMedia('(max-width: 1024px)');
|
||||
const phoneQuery = window.matchMedia('(max-width: 767px)');
|
||||
const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)');
|
||||
|
||||
const strideOf = (viewport) => {
|
||||
const card = viewport.querySelector('.routine__card');
|
||||
const track = viewport.querySelector('[data-routine-track]');
|
||||
if (!card) return 0;
|
||||
const gap = track ? parseFloat(window.getComputedStyle(track).columnGap) || 0 : 0;
|
||||
return card.getBoundingClientRect().width + gap;
|
||||
};
|
||||
|
||||
const updateProgress = (viewport) => {
|
||||
const section = viewport.closest('.routine');
|
||||
const bar = section && section.querySelector('[data-routine-bar]');
|
||||
if (!bar) return;
|
||||
const max = viewport.scrollWidth - viewport.clientWidth;
|
||||
const visible = viewport.scrollWidth > 0 ? viewport.clientWidth / viewport.scrollWidth : 1;
|
||||
const width = Math.min(Math.max(visible * 100, 12), 100);
|
||||
const travel = 100 - width;
|
||||
const progress = max <= 2 ? 0 : viewport.scrollLeft / max;
|
||||
bar.style.width = `${width}%`;
|
||||
bar.style.left = `${progress * travel}%`;
|
||||
};
|
||||
|
||||
const goTo = (viewport, index, behavior) => {
|
||||
const stride = strideOf(viewport);
|
||||
const count = viewport.querySelectorAll('.routine__card').length;
|
||||
if (!stride || !count) return;
|
||||
const wrapped = ((index % count) + count) % count;
|
||||
const max = Math.max(viewport.scrollWidth - viewport.clientWidth, 0);
|
||||
viewport.scrollTo({ left: Math.min(wrapped * stride, max), behavior });
|
||||
};
|
||||
|
||||
const boot = (section) => {
|
||||
const viewport = section.querySelector('[data-routine-viewport]');
|
||||
if (!viewport || viewport.dataset.ready === 'true') return;
|
||||
viewport.dataset.ready = 'true';
|
||||
|
||||
const pause = () => {
|
||||
if (viewport._routineTimer) window.clearInterval(viewport._routineTimer);
|
||||
viewport._routineTimer = null;
|
||||
};
|
||||
|
||||
const play = () => {
|
||||
pause();
|
||||
if (!sliderQuery.matches || reduceMotion.matches || viewport.dataset.paused === 'true') return;
|
||||
viewport._routineTimer = window.setInterval(() => {
|
||||
const max = viewport.scrollWidth - viewport.clientWidth;
|
||||
if (max <= 2) return;
|
||||
const stride = strideOf(viewport);
|
||||
const count = viewport.querySelectorAll('.routine__card').length;
|
||||
if (!stride || count < 2) return;
|
||||
const index = Math.round(viewport.scrollLeft / stride);
|
||||
const behavior = reduceMotion.matches ? 'auto' : 'smooth';
|
||||
goTo(viewport, index + 1 >= count ? 0 : index + 1, behavior);
|
||||
}, 4000);
|
||||
};
|
||||
|
||||
if (phoneQuery.matches) goTo(viewport, 0, 'auto');
|
||||
updateProgress(viewport);
|
||||
play();
|
||||
|
||||
viewport.addEventListener('scroll', () => updateProgress(viewport), { passive: true });
|
||||
viewport.addEventListener('pointerdown', () => {
|
||||
viewport.dataset.paused = 'true';
|
||||
pause();
|
||||
});
|
||||
viewport.addEventListener('pointerup', () => {
|
||||
window.setTimeout(() => {
|
||||
delete viewport.dataset.paused;
|
||||
play();
|
||||
}, 2500);
|
||||
});
|
||||
viewport.addEventListener('pointercancel', () => {
|
||||
delete viewport.dataset.paused;
|
||||
play();
|
||||
});
|
||||
|
||||
const onChange = () => {
|
||||
if (phoneQuery.matches) {
|
||||
const stride = strideOf(viewport);
|
||||
const index = stride ? Math.round(viewport.scrollLeft / stride) : 0;
|
||||
goTo(viewport, index, 'auto');
|
||||
}
|
||||
updateProgress(viewport);
|
||||
play();
|
||||
};
|
||||
sliderQuery.addEventListener('change', onChange);
|
||||
phoneQuery.addEventListener('change', onChange);
|
||||
window.addEventListener('resize', onChange);
|
||||
};
|
||||
|
||||
document.querySelectorAll('.routine').forEach(boot);
|
||||
if (window.__seasonRoutine) return;
|
||||
window.__seasonRoutine = true;
|
||||
document.addEventListener('shopify:section:load', (event) => {
|
||||
const section = event.target.querySelector('.routine');
|
||||
if (section) boot(section);
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
{% schema %}
|
||||
{
|
||||
"name": "t:routine.name",
|
||||
|
||||
+19
-1
@@ -5,7 +5,7 @@
|
||||
endif
|
||||
%}
|
||||
|
||||
<section class="search-page full-width">
|
||||
<section class="search-page full-width" data-collection>
|
||||
<div class="search-page__body">
|
||||
<h1 class="search-page__title">{{ search_heading | escape }}</h1>
|
||||
|
||||
@@ -31,6 +31,24 @@
|
||||
<p class="search-page__empty">{{ 'search.no_results_html' | t: terms: search_heading }}</p>
|
||||
{% else %}
|
||||
<p class="search-page__count">{{ 'search.results_for_html' | t: terms: search_heading, count: search.results_count }}</p>
|
||||
{%- liquid
|
||||
assign search_sort = search.sort_by | default: search.default_sort_by
|
||||
assign search_clear = routes.search_url | append: '?q=' | append: search.terms
|
||||
assign search_type = ''
|
||||
if search.types.size == 1
|
||||
assign search_type = search.types | first
|
||||
endif
|
||||
-%}
|
||||
{% render 'facets-toolbar',
|
||||
filters: search.filters,
|
||||
sort_options: search.sort_options,
|
||||
current_sort: search_sort,
|
||||
action_url: routes.search_url,
|
||||
clear_url: search_clear,
|
||||
count_label: '',
|
||||
results_type: search_type,
|
||||
terms: search.terms
|
||||
%}
|
||||
|
||||
{% paginate search.results by 9 %}
|
||||
<div class="search-page__grid">
|
||||
|
||||
@@ -33,6 +33,10 @@
|
||||
assign jar_alt = 'skin_match.photos.jar' | t
|
||||
assign dropper_alt = 'skin_match.photos.dropper' | t
|
||||
assign cheek_alt = 'skin_match.photos.cheek' | t
|
||||
assign serum_url = '/collections/hidratantes'
|
||||
assign dropper_url = '/collections/serum'
|
||||
assign cheek_url = '/collections/hidratacion'
|
||||
assign jar_url = '/collections/2-trata'
|
||||
%}
|
||||
|
||||
<section class="skin-match full-width">
|
||||
@@ -87,7 +91,7 @@
|
||||
</header>
|
||||
|
||||
<div class="skin-match__gallery">
|
||||
<div class="skin-match__photo skin-match__photo--serum">
|
||||
<a class="skin-match__photo skin-match__photo--serum" href="{{ serum_url }}">
|
||||
{% if section.settings.image_serum != blank %}
|
||||
{{
|
||||
section.settings.image_serum
|
||||
@@ -112,9 +116,9 @@
|
||||
decoding="async"
|
||||
>
|
||||
{% endif %}
|
||||
</div>
|
||||
</a>
|
||||
|
||||
<div class="skin-match__photo skin-match__photo--dropper">
|
||||
<a class="skin-match__photo skin-match__photo--dropper" href="{{ dropper_url }}">
|
||||
{% if section.settings.image_dropper != blank %}
|
||||
{{
|
||||
section.settings.image_dropper
|
||||
@@ -139,9 +143,9 @@
|
||||
decoding="async"
|
||||
>
|
||||
{% endif %}
|
||||
</div>
|
||||
</a>
|
||||
|
||||
<div class="skin-match__photo skin-match__photo--cheek">
|
||||
<a class="skin-match__photo skin-match__photo--cheek" href="{{ cheek_url }}">
|
||||
{% if section.settings.image_cheek != blank %}
|
||||
{{
|
||||
section.settings.image_cheek
|
||||
@@ -166,9 +170,9 @@
|
||||
decoding="async"
|
||||
>
|
||||
{% endif %}
|
||||
</div>
|
||||
</a>
|
||||
|
||||
<div class="skin-match__photo skin-match__photo--jar">
|
||||
<a class="skin-match__photo skin-match__photo--jar" href="{{ jar_url }}">
|
||||
{% if section.settings.image_jar != blank %}
|
||||
{{
|
||||
section.settings.image_jar
|
||||
@@ -193,7 +197,7 @@
|
||||
decoding="async"
|
||||
>
|
||||
{% endif %}
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<p class="skin-match__body">
|
||||
|
||||
@@ -10,6 +10,20 @@
|
||||
else
|
||||
assign subheading = 'testimonials.subheading' | t
|
||||
endif
|
||||
|
||||
assign visible_testimonials = 0
|
||||
for block in section.blocks
|
||||
assign slide_product = block.settings.product
|
||||
assign skip_slide = false
|
||||
if slide_product != blank
|
||||
unless slide_product.available
|
||||
assign skip_slide = true
|
||||
endunless
|
||||
endif
|
||||
unless skip_slide
|
||||
assign visible_testimonials = visible_testimonials | plus: 1
|
||||
endunless
|
||||
endfor
|
||||
%}
|
||||
|
||||
<section
|
||||
@@ -36,15 +50,28 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if section.blocks.size > 0 %}
|
||||
{% if visible_testimonials > 0 %}
|
||||
<div class="testimonials__stage">
|
||||
<div class="testimonials__copy">
|
||||
{% assign shown_slides = 0 %}
|
||||
{% for block in section.blocks %}
|
||||
{% liquid
|
||||
assign slide_product = block.settings.product
|
||||
assign skip_slide = false
|
||||
if slide_product != blank
|
||||
unless slide_product.available
|
||||
assign skip_slide = true
|
||||
endunless
|
||||
endif
|
||||
%}
|
||||
{% if skip_slide %}
|
||||
{% continue %}
|
||||
{% endif %}
|
||||
<div
|
||||
class="testimonials__slide"
|
||||
data-slide
|
||||
{{ block.shopify_attributes }}
|
||||
{% unless forloop.first %}hidden{% endunless %}
|
||||
{% if shown_slides > 0 %}hidden{% endif %}
|
||||
>
|
||||
<div class="testimonials__meta">
|
||||
<div class="testimonials__stars" role="img" aria-label="{{ 'testimonials.rating' | t: rating: block.settings.rating }}">
|
||||
@@ -64,6 +91,7 @@
|
||||
<p class="testimonials__quote">{{ block.settings.quote | escape }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% assign shown_slides = shown_slides | plus: 1 %}
|
||||
{% endfor %}
|
||||
|
||||
<div class="testimonials__nav">
|
||||
@@ -85,7 +113,20 @@
|
||||
</div>
|
||||
|
||||
<div class="testimonials__products">
|
||||
{% assign shown_products = 0 %}
|
||||
{% for block in section.blocks %}
|
||||
{% liquid
|
||||
assign slide_product = block.settings.product
|
||||
assign skip_slide = false
|
||||
if slide_product != blank
|
||||
unless slide_product.available
|
||||
assign skip_slide = true
|
||||
endunless
|
||||
endif
|
||||
%}
|
||||
{% if skip_slide %}
|
||||
{% continue %}
|
||||
{% endif %}
|
||||
{% liquid
|
||||
assign slide_product = block.settings.product
|
||||
assign variant = blank
|
||||
@@ -114,7 +155,7 @@
|
||||
endif
|
||||
endif
|
||||
%}
|
||||
<div class="testimonials__product" data-product {% unless forloop.first %}hidden{% endunless %}>
|
||||
<div class="testimonials__product" data-product {% if shown_products > 0 %}hidden{% endif %}>
|
||||
{% if slide_product != blank %}
|
||||
<div class="testimonials__media">
|
||||
<a class="testimonials__media-link" href="{{ slide_product.url }}">
|
||||
@@ -189,6 +230,7 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% assign shown_products = shown_products | plus: 1 %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
@@ -264,6 +306,7 @@
|
||||
if (!window.__seasonTestimonials) {
|
||||
window.__seasonTestimonials = true;
|
||||
document.addEventListener('submit', async (event) => {
|
||||
if (event.defaultPrevented) return;
|
||||
const form = event.target;
|
||||
if (!(form instanceof HTMLFormElement) || !form.classList.contains('testimonials__form')) return;
|
||||
const root = form.closest('[data-testimonials]');
|
||||
@@ -288,6 +331,7 @@
|
||||
window.location.href = root.dataset.checkoutUrl;
|
||||
return;
|
||||
}
|
||||
document.dispatchEvent(new CustomEvent('season:cart:open'));
|
||||
const cart = await fetch('/cart.js').then((result) => result.json());
|
||||
setCartCount(cart.item_count);
|
||||
} else if (data.description) {
|
||||
|
||||
Reference in New Issue
Block a user