Ajustes antes de produccion
This commit is contained in:
+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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user