ng-easycommerce 0.0.572 → 0.0.573
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/bundles/ng-easycommerce.umd.js +89 -5
- package/bundles/ng-easycommerce.umd.js.map +1 -1
- package/bundles/ng-easycommerce.umd.min.js +1 -1
- package/bundles/ng-easycommerce.umd.min.js.map +1 -1
- package/esm2015/lib/ec-component/cart-ec/cart-ec.component.js +52 -2
- package/esm5/lib/ec-component/cart-ec/cart-ec.component.js +86 -2
- package/fesm2015/ng-easycommerce.js +51 -1
- package/fesm2015/ng-easycommerce.js.map +1 -1
- package/fesm5/ng-easycommerce.js +89 -5
- package/fesm5/ng-easycommerce.js.map +1 -1
- package/lib/ec-component/cart-ec/cart-ec.component.d.ts +4 -1
- package/ng-easycommerce.metadata.json +1 -1
- package/package.json +1 -1
package/fesm5/ng-easycommerce.js
CHANGED
|
@@ -7261,6 +7261,17 @@ var __generator$8 = (this && this.__generator) || function (thisArg, body) {
|
|
|
7261
7261
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
7262
7262
|
}
|
|
7263
7263
|
};
|
|
7264
|
+
var __values = (this && this.__values) || function(o) {
|
|
7265
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
7266
|
+
if (m) return m.call(o);
|
|
7267
|
+
if (o && typeof o.length === "number") return {
|
|
7268
|
+
next: function () {
|
|
7269
|
+
if (o && i >= o.length) o = void 0;
|
|
7270
|
+
return { value: o && o[i++], done: !o };
|
|
7271
|
+
}
|
|
7272
|
+
};
|
|
7273
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
7274
|
+
};
|
|
7264
7275
|
var CartEcComponent = /** @class */ (function (_super) {
|
|
7265
7276
|
__extends$g(CartEcComponent, _super);
|
|
7266
7277
|
function CartEcComponent(cartService, authService, consts, productsService, router, modalService, toastrService, addressingService) {
|
|
@@ -7279,6 +7290,8 @@ var CartEcComponent = /** @class */ (function (_super) {
|
|
|
7279
7290
|
_this.promotions = [];
|
|
7280
7291
|
_this.cargando = false;
|
|
7281
7292
|
_this.channel = {};
|
|
7293
|
+
_this.updateStock = false;
|
|
7294
|
+
_this.exitUpdate = false;
|
|
7282
7295
|
_this.toDecimal = function (amount) { return _this.consts.toDecimal(amount); };
|
|
7283
7296
|
_this.actualizarCantidad = function (item, cantidad, stock, id) {
|
|
7284
7297
|
if (id) {
|
|
@@ -7533,7 +7546,78 @@ var CartEcComponent = /** @class */ (function (_super) {
|
|
|
7533
7546
|
$('#' + id).modal('hide');
|
|
7534
7547
|
};
|
|
7535
7548
|
CartEcComponent.prototype.checkStock = function (item) {
|
|
7536
|
-
|
|
7549
|
+
var e_1, _a;
|
|
7550
|
+
try {
|
|
7551
|
+
for (var _b = __values(item.product.variants), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
7552
|
+
var variant = _c.value;
|
|
7553
|
+
if (item.variant_id === variant.code) {
|
|
7554
|
+
if (variant.stock === 0) {
|
|
7555
|
+
this.updateStock = true;
|
|
7556
|
+
return '0';
|
|
7557
|
+
}
|
|
7558
|
+
else if (item.quantity > variant.stock) {
|
|
7559
|
+
this.updateStock = true;
|
|
7560
|
+
return variant.stock;
|
|
7561
|
+
}
|
|
7562
|
+
}
|
|
7563
|
+
}
|
|
7564
|
+
}
|
|
7565
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
7566
|
+
finally {
|
|
7567
|
+
try {
|
|
7568
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
7569
|
+
}
|
|
7570
|
+
finally { if (e_1) throw e_1.error; }
|
|
7571
|
+
}
|
|
7572
|
+
return false; // Solo se ejecuta si no se cumple la condición
|
|
7573
|
+
};
|
|
7574
|
+
CartEcComponent.prototype.updateAllStock = function () {
|
|
7575
|
+
var _this = this;
|
|
7576
|
+
var items = [];
|
|
7577
|
+
// Define la suscripción antes de usarla
|
|
7578
|
+
this.cartService.cartItems.subscribe(function (res) {
|
|
7579
|
+
res.forEach(function (item) {
|
|
7580
|
+
var e_2, _a;
|
|
7581
|
+
try {
|
|
7582
|
+
for (var _b = __values(item.product.variants), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
7583
|
+
var variant = _c.value;
|
|
7584
|
+
if (item.variant_id === variant.code && !_this.exitUpdate) {
|
|
7585
|
+
if (variant.stock === 0) {
|
|
7586
|
+
_this.cartService.deleteCartItem(item, false); // Borra el artículo
|
|
7587
|
+
}
|
|
7588
|
+
else if (item.quantity > variant.stock) {
|
|
7589
|
+
items.push({
|
|
7590
|
+
productCode: item.product.id,
|
|
7591
|
+
quantity: variant.stock,
|
|
7592
|
+
variantCode: variant.code,
|
|
7593
|
+
});
|
|
7594
|
+
}
|
|
7595
|
+
else {
|
|
7596
|
+
items.push({
|
|
7597
|
+
productCode: item.product.id,
|
|
7598
|
+
quantity: item.quantity,
|
|
7599
|
+
variantCode: variant.code,
|
|
7600
|
+
});
|
|
7601
|
+
}
|
|
7602
|
+
}
|
|
7603
|
+
}
|
|
7604
|
+
}
|
|
7605
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
7606
|
+
finally {
|
|
7607
|
+
try {
|
|
7608
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
7609
|
+
}
|
|
7610
|
+
finally { if (e_2) throw e_2.error; }
|
|
7611
|
+
}
|
|
7612
|
+
});
|
|
7613
|
+
if (items.length > 0 && !_this.exitUpdate) {
|
|
7614
|
+
// subscription.unsubscribe(); // Desuscríbete antes de actualizar
|
|
7615
|
+
_this.cartService.addAllToCart(items); // Actualiza el carrito
|
|
7616
|
+
_this.updateStock = false;
|
|
7617
|
+
_this.exitUpdate = true;
|
|
7618
|
+
// this.updateAllStock(); // Vuelve a verificar el stock
|
|
7619
|
+
}
|
|
7620
|
+
});
|
|
7537
7621
|
};
|
|
7538
7622
|
CartEcComponent.prototype.createDiscountMessage = function (saleprice, price) {
|
|
7539
7623
|
if (isNaN(saleprice) || isNaN(price) || saleprice >= price || saleprice <= 0 || price <= 0) {
|
|
@@ -8319,7 +8403,7 @@ var __generator$b = (this && this.__generator) || function (thisArg, body) {
|
|
|
8319
8403
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
8320
8404
|
}
|
|
8321
8405
|
};
|
|
8322
|
-
var __values = (this && this.__values) || function(o) {
|
|
8406
|
+
var __values$1 = (this && this.__values) || function(o) {
|
|
8323
8407
|
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
8324
8408
|
if (m) return m.call(o);
|
|
8325
8409
|
if (o && typeof o.length === "number") return {
|
|
@@ -8424,7 +8508,7 @@ var PaymentEcComponent = /** @class */ (function (_super) {
|
|
|
8424
8508
|
var e_1, _a;
|
|
8425
8509
|
var parent = e.target.parentElement.children;
|
|
8426
8510
|
try {
|
|
8427
|
-
for (var parent_1 = __values(parent), parent_1_1 = parent_1.next(); !parent_1_1.done; parent_1_1 = parent_1.next()) {
|
|
8511
|
+
for (var parent_1 = __values$1(parent), parent_1_1 = parent_1.next(); !parent_1_1.done; parent_1_1 = parent_1.next()) {
|
|
8428
8512
|
var button = parent_1_1.value;
|
|
8429
8513
|
if (button.classList.contains('active')) {
|
|
8430
8514
|
button.classList.remove('active');
|
|
@@ -8493,7 +8577,7 @@ var __decorate$S = (this && this.__decorate) || function (decorators, target, ke
|
|
|
8493
8577
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
8494
8578
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8495
8579
|
};
|
|
8496
|
-
var __values$
|
|
8580
|
+
var __values$2 = (this && this.__values) || function(o) {
|
|
8497
8581
|
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
8498
8582
|
if (m) return m.call(o);
|
|
8499
8583
|
if (o && typeof o.length === "number") return {
|
|
@@ -8582,7 +8666,7 @@ var ShipmentEcComponent = /** @class */ (function (_super) {
|
|
|
8582
8666
|
var e_1, _a;
|
|
8583
8667
|
var parent = e.target.parentElement.children;
|
|
8584
8668
|
try {
|
|
8585
|
-
for (var parent_1 = __values$
|
|
8669
|
+
for (var parent_1 = __values$2(parent), parent_1_1 = parent_1.next(); !parent_1_1.done; parent_1_1 = parent_1.next()) {
|
|
8586
8670
|
var button = parent_1_1.value;
|
|
8587
8671
|
if (button.classList.contains('active')) {
|
|
8588
8672
|
button.classList.remove('active');
|