Compare commits
No commits in common. "48597ae8c74b3bbacea05c9edfd1cdd4e5d3b73c" and "9a9139711fac8fd9b1472f9d50a1d4a3b9c00d53" have entirely different histories.
48597ae8c7
...
9a9139711f
2 changed files with 8 additions and 71 deletions
|
|
@ -19,7 +19,6 @@
|
|||
"stock_picking_batch",
|
||||
"account",
|
||||
"product_get_price_helper",
|
||||
"l10n_es_partner",
|
||||
],
|
||||
"data": [
|
||||
# Datos: Grupos propios
|
||||
|
|
|
|||
|
|
@ -436,74 +436,18 @@
|
|||
|
||||
_loadCart: function () {
|
||||
var cartKey = "eskaera_" + this.orderId + "_cart";
|
||||
var raw = localStorage.getItem(cartKey);
|
||||
this.cart = {};
|
||||
if (!raw) {
|
||||
console.log("Cart loaded: localStorage[" + cartKey + "] is empty");
|
||||
return;
|
||||
}
|
||||
var parsed;
|
||||
try {
|
||||
parsed = JSON.parse(raw);
|
||||
} catch (e) {
|
||||
console.warn("Cart load: invalid JSON in localStorage, dropping", e);
|
||||
localStorage.removeItem(cartKey);
|
||||
return;
|
||||
}
|
||||
// Legacy / corrupt shape (raw items object without cycle stamp) → drop.
|
||||
if (
|
||||
!parsed ||
|
||||
typeof parsed !== "object" ||
|
||||
!parsed.items ||
|
||||
!("cutoff_date" in parsed)
|
||||
) {
|
||||
console.log(
|
||||
"Cart load: legacy/unstamped value, dropping localStorage[" + cartKey + "]"
|
||||
);
|
||||
localStorage.removeItem(cartKey);
|
||||
return;
|
||||
}
|
||||
// Cycle mismatch (or no current cycle known) → drop. This is the
|
||||
// primary defence against stale carts surviving cycle rollover.
|
||||
if (!this._currentCutoffDate || parsed.cutoff_date !== this._currentCutoffDate) {
|
||||
console.log(
|
||||
"Cart load: cycle mismatch (stored=" +
|
||||
parsed.cutoff_date +
|
||||
", current=" +
|
||||
this._currentCutoffDate +
|
||||
"), dropping localStorage[" +
|
||||
cartKey +
|
||||
"]"
|
||||
);
|
||||
localStorage.removeItem(cartKey);
|
||||
return;
|
||||
}
|
||||
this.cart = parsed.items;
|
||||
console.log(
|
||||
"Cart loaded from localStorage[" +
|
||||
cartKey +
|
||||
"] (cycle " +
|
||||
parsed.cutoff_date +
|
||||
"):",
|
||||
this.cart
|
||||
);
|
||||
var savedCart = localStorage.getItem(cartKey);
|
||||
this.cart = savedCart ? JSON.parse(savedCart) : {};
|
||||
console.log("Cart loaded from localStorage[" + cartKey + "]:", this.cart);
|
||||
console.log("Raw localStorage value:", savedCart);
|
||||
},
|
||||
|
||||
_saveCart: function () {
|
||||
var cartKey = "eskaera_" + this.orderId + "_cart";
|
||||
var payload = JSON.stringify({
|
||||
cutoff_date: this._currentCutoffDate || null,
|
||||
items: this.cart,
|
||||
});
|
||||
localStorage.setItem(cartKey, payload);
|
||||
console.log(
|
||||
"Cart saved to localStorage[" +
|
||||
cartKey +
|
||||
"] (cycle " +
|
||||
(this._currentCutoffDate || "unknown") +
|
||||
"):",
|
||||
this.cart
|
||||
);
|
||||
var cartJson = JSON.stringify(this.cart);
|
||||
localStorage.setItem(cartKey, cartJson);
|
||||
console.log("Cart saved to localStorage[" + cartKey + "]:", this.cart);
|
||||
console.log("Verification - immediately read back:", localStorage.getItem(cartKey));
|
||||
},
|
||||
|
||||
_clearCurrentOrderCartSilently: function () {
|
||||
|
|
@ -549,15 +493,11 @@
|
|||
|
||||
xhr.onload = function () {
|
||||
if (xhr.status !== 200) {
|
||||
self._currentCutoffDate = null;
|
||||
done();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
var data = JSON.parse(xhr.responseText || "{}");
|
||||
// Capture current cycle marker so _loadCart can evict a
|
||||
// localStorage cart that belongs to a previous cycle.
|
||||
self._currentCutoffDate = data && data.cutoff_date ? data.cutoff_date : null;
|
||||
// Clear cart if order is closed, action requests clearance, or cutoff already passed
|
||||
var shouldClear = false;
|
||||
if (data) {
|
||||
|
|
@ -587,14 +527,12 @@
|
|||
}
|
||||
}
|
||||
} catch (e) {
|
||||
self._currentCutoffDate = null;
|
||||
console.warn("[groupOrderShop] check-status parse error", e);
|
||||
}
|
||||
done();
|
||||
};
|
||||
|
||||
xhr.onerror = function () {
|
||||
self._currentCutoffDate = null;
|
||||
done();
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue