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/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# version 0.0.573
|
|
2
|
+
- Se modifica y se agrega funcion para actualizar el stock y cambie al disponible en caso de que sea mayor. Tambien lo elimina en caso de que el stock sea 0.
|
|
1
3
|
# version 0.0.572
|
|
2
4
|
- Se implementó la lógica para gestionar un observable `balanceCustomerSubject` en `cart.service` que contiene los datos referentes al crédito del usuario.
|
|
3
5
|
- Se añadió la validaciónes en `cart.service` y `product-detail`, para verificar si el usuario tiene suficientes créditos antes de continuar con la compra.
|
|
@@ -7247,6 +7247,17 @@
|
|
|
7247
7247
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
7248
7248
|
}
|
|
7249
7249
|
};
|
|
7250
|
+
var __values = (this && this.__values) || function(o) {
|
|
7251
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
7252
|
+
if (m) return m.call(o);
|
|
7253
|
+
if (o && typeof o.length === "number") return {
|
|
7254
|
+
next: function () {
|
|
7255
|
+
if (o && i >= o.length) o = void 0;
|
|
7256
|
+
return { value: o && o[i++], done: !o };
|
|
7257
|
+
}
|
|
7258
|
+
};
|
|
7259
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
7260
|
+
};
|
|
7250
7261
|
var CartEcComponent = /** @class */ (function (_super) {
|
|
7251
7262
|
__extends$g(CartEcComponent, _super);
|
|
7252
7263
|
function CartEcComponent(cartService, authService, consts, productsService, router, modalService, toastrService, addressingService) {
|
|
@@ -7265,6 +7276,8 @@
|
|
|
7265
7276
|
_this.promotions = [];
|
|
7266
7277
|
_this.cargando = false;
|
|
7267
7278
|
_this.channel = {};
|
|
7279
|
+
_this.updateStock = false;
|
|
7280
|
+
_this.exitUpdate = false;
|
|
7268
7281
|
_this.toDecimal = function (amount) { return _this.consts.toDecimal(amount); };
|
|
7269
7282
|
_this.actualizarCantidad = function (item, cantidad, stock, id) {
|
|
7270
7283
|
if (id) {
|
|
@@ -7519,7 +7532,78 @@
|
|
|
7519
7532
|
$('#' + id).modal('hide');
|
|
7520
7533
|
};
|
|
7521
7534
|
CartEcComponent.prototype.checkStock = function (item) {
|
|
7522
|
-
|
|
7535
|
+
var e_1, _a;
|
|
7536
|
+
try {
|
|
7537
|
+
for (var _b = __values(item.product.variants), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
7538
|
+
var variant = _c.value;
|
|
7539
|
+
if (item.variant_id === variant.code) {
|
|
7540
|
+
if (variant.stock === 0) {
|
|
7541
|
+
this.updateStock = true;
|
|
7542
|
+
return '0';
|
|
7543
|
+
}
|
|
7544
|
+
else if (item.quantity > variant.stock) {
|
|
7545
|
+
this.updateStock = true;
|
|
7546
|
+
return variant.stock;
|
|
7547
|
+
}
|
|
7548
|
+
}
|
|
7549
|
+
}
|
|
7550
|
+
}
|
|
7551
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
7552
|
+
finally {
|
|
7553
|
+
try {
|
|
7554
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
7555
|
+
}
|
|
7556
|
+
finally { if (e_1) throw e_1.error; }
|
|
7557
|
+
}
|
|
7558
|
+
return false; // Solo se ejecuta si no se cumple la condición
|
|
7559
|
+
};
|
|
7560
|
+
CartEcComponent.prototype.updateAllStock = function () {
|
|
7561
|
+
var _this = this;
|
|
7562
|
+
var items = [];
|
|
7563
|
+
// Define la suscripción antes de usarla
|
|
7564
|
+
this.cartService.cartItems.subscribe(function (res) {
|
|
7565
|
+
res.forEach(function (item) {
|
|
7566
|
+
var e_2, _a;
|
|
7567
|
+
try {
|
|
7568
|
+
for (var _b = __values(item.product.variants), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
7569
|
+
var variant = _c.value;
|
|
7570
|
+
if (item.variant_id === variant.code && !_this.exitUpdate) {
|
|
7571
|
+
if (variant.stock === 0) {
|
|
7572
|
+
_this.cartService.deleteCartItem(item, false); // Borra el artículo
|
|
7573
|
+
}
|
|
7574
|
+
else if (item.quantity > variant.stock) {
|
|
7575
|
+
items.push({
|
|
7576
|
+
productCode: item.product.id,
|
|
7577
|
+
quantity: variant.stock,
|
|
7578
|
+
variantCode: variant.code,
|
|
7579
|
+
});
|
|
7580
|
+
}
|
|
7581
|
+
else {
|
|
7582
|
+
items.push({
|
|
7583
|
+
productCode: item.product.id,
|
|
7584
|
+
quantity: item.quantity,
|
|
7585
|
+
variantCode: variant.code,
|
|
7586
|
+
});
|
|
7587
|
+
}
|
|
7588
|
+
}
|
|
7589
|
+
}
|
|
7590
|
+
}
|
|
7591
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
7592
|
+
finally {
|
|
7593
|
+
try {
|
|
7594
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
7595
|
+
}
|
|
7596
|
+
finally { if (e_2) throw e_2.error; }
|
|
7597
|
+
}
|
|
7598
|
+
});
|
|
7599
|
+
if (items.length > 0 && !_this.exitUpdate) {
|
|
7600
|
+
// subscription.unsubscribe(); // Desuscríbete antes de actualizar
|
|
7601
|
+
_this.cartService.addAllToCart(items); // Actualiza el carrito
|
|
7602
|
+
_this.updateStock = false;
|
|
7603
|
+
_this.exitUpdate = true;
|
|
7604
|
+
// this.updateAllStock(); // Vuelve a verificar el stock
|
|
7605
|
+
}
|
|
7606
|
+
});
|
|
7523
7607
|
};
|
|
7524
7608
|
CartEcComponent.prototype.createDiscountMessage = function (saleprice, price) {
|
|
7525
7609
|
if (isNaN(saleprice) || isNaN(price) || saleprice >= price || saleprice <= 0 || price <= 0) {
|
|
@@ -8305,7 +8389,7 @@
|
|
|
8305
8389
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
8306
8390
|
}
|
|
8307
8391
|
};
|
|
8308
|
-
var __values = (this && this.__values) || function(o) {
|
|
8392
|
+
var __values$1 = (this && this.__values) || function(o) {
|
|
8309
8393
|
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
8310
8394
|
if (m) return m.call(o);
|
|
8311
8395
|
if (o && typeof o.length === "number") return {
|
|
@@ -8410,7 +8494,7 @@
|
|
|
8410
8494
|
var e_1, _a;
|
|
8411
8495
|
var parent = e.target.parentElement.children;
|
|
8412
8496
|
try {
|
|
8413
|
-
for (var parent_1 = __values(parent), parent_1_1 = parent_1.next(); !parent_1_1.done; parent_1_1 = parent_1.next()) {
|
|
8497
|
+
for (var parent_1 = __values$1(parent), parent_1_1 = parent_1.next(); !parent_1_1.done; parent_1_1 = parent_1.next()) {
|
|
8414
8498
|
var button = parent_1_1.value;
|
|
8415
8499
|
if (button.classList.contains('active')) {
|
|
8416
8500
|
button.classList.remove('active');
|
|
@@ -8479,7 +8563,7 @@
|
|
|
8479
8563
|
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;
|
|
8480
8564
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8481
8565
|
};
|
|
8482
|
-
var __values$
|
|
8566
|
+
var __values$2 = (this && this.__values) || function(o) {
|
|
8483
8567
|
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
8484
8568
|
if (m) return m.call(o);
|
|
8485
8569
|
if (o && typeof o.length === "number") return {
|
|
@@ -8568,7 +8652,7 @@
|
|
|
8568
8652
|
var e_1, _a;
|
|
8569
8653
|
var parent = e.target.parentElement.children;
|
|
8570
8654
|
try {
|
|
8571
|
-
for (var parent_1 = __values$
|
|
8655
|
+
for (var parent_1 = __values$2(parent), parent_1_1 = parent_1.next(); !parent_1_1.done; parent_1_1 = parent_1.next()) {
|
|
8572
8656
|
var button = parent_1_1.value;
|
|
8573
8657
|
if (button.classList.contains('active')) {
|
|
8574
8658
|
button.classList.remove('active');
|