ng-easycommerce 0.0.570 → 0.0.572
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 +7 -0
- package/assets/bancardCatastro.html +1 -1
- package/assets/ec-i18n/ct.json +2 -1
- package/assets/ec-i18n/en.json +2 -1
- package/assets/ec-i18n/es.json +2 -1
- package/assets/ec-i18n/fr.json +2 -1
- package/assets/ec-i18n/gl.json +2 -1
- package/assets/ec-i18n/pr.json +2 -1
- package/bundles/ng-easycommerce.umd.js +113 -3
- 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/build-your-ec/build-your-ec.component.js +2 -2
- package/esm2015/lib/ec-component/cart-ec/cart-ec.component.js +9 -2
- package/esm2015/lib/ec-component/header-ec/header-ec.component.js +7 -1
- package/esm2015/lib/services/cart.service.js +66 -2
- package/esm2015/lib/services/products/product-detail.service.js +29 -1
- package/esm5/lib/ec-component/build-your-ec/build-your-ec.component.js +2 -2
- package/esm5/lib/ec-component/cart-ec/cart-ec.component.js +9 -2
- package/esm5/lib/ec-component/header-ec/header-ec.component.js +8 -1
- package/esm5/lib/services/cart.service.js +70 -2
- package/esm5/lib/services/products/product-detail.service.js +29 -1
- package/fesm2015/ng-easycommerce.js +108 -3
- package/fesm2015/ng-easycommerce.js.map +1 -1
- package/fesm5/ng-easycommerce.js +113 -3
- package/fesm5/ng-easycommerce.js.map +1 -1
- package/lib/ec-component/cart-ec/cart-ec.component.d.ts +2 -2
- package/lib/ec-component/header-ec/header-ec.component.d.ts +3 -0
- package/lib/services/cart.service.d.ts +19 -0
- package/lib/services/products/product-detail.service.d.ts +9 -3
- package/ng-easycommerce.metadata.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# version 0.0.572
|
|
2
|
+
- Se implementó la lógica para gestionar un observable `balanceCustomerSubject` en `cart.service` que contiene los datos referentes al crédito del usuario.
|
|
3
|
+
- 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.
|
|
4
|
+
- Se mostraron mensajes de retroalimentación para casos de créditos insuficientes.
|
|
5
|
+
- Se modifica `build-your-ec.component.html` para que permita retroceder en los pasos.
|
|
6
|
+
# version 0.0.571
|
|
7
|
+
- Update Bancard Version
|
|
1
8
|
# version 0.0.570
|
|
2
9
|
- Se actualizaron los mensajes de error para aclarar que los pedidos no se pueden repetir si el carrito no está vacío.
|
|
3
10
|
- Se modifica cuando un articulo no esta activado pero si su variante. Tambien cuando en endpoint devuelve un 404 Not found redirige a la home.
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
console.log('Datos cargados desde catastro_data:', catastro_data);
|
|
14
14
|
|
|
15
15
|
let script_tag = document.createElement('script');
|
|
16
|
-
script_tag.setAttribute('src', catastro_data.environment + '/checkout/javascript/dist/bancard-checkout-
|
|
16
|
+
script_tag.setAttribute('src', catastro_data.environment + '/checkout/javascript/dist/bancard-checkout-4.0.0.js');
|
|
17
17
|
document.head.appendChild(script_tag);
|
|
18
18
|
|
|
19
19
|
let styles = {
|
package/assets/ec-i18n/ct.json
CHANGED
|
@@ -273,5 +273,6 @@
|
|
|
273
273
|
"will_contact": "Un cop percebuda la transferència, ens posarem en contacte amb vostè per informar l'estat de la seva compra",
|
|
274
274
|
"date": "Data",
|
|
275
275
|
"repeat-order": "Repetir comanda",
|
|
276
|
-
"no-products-to-add": "No hi ha productes per afegir"
|
|
276
|
+
"no-products-to-add": "No hi ha productes per afegir",
|
|
277
|
+
"not-enough-credits": "No té prou crèdits per comprar aquest producte"
|
|
277
278
|
}
|
package/assets/ec-i18n/en.json
CHANGED
|
@@ -375,5 +375,6 @@
|
|
|
375
375
|
"instructions": "Instructions",
|
|
376
376
|
"error-convertibility": "Convertibility error. Try again later.",
|
|
377
377
|
"repeat-order": "Repeat order",
|
|
378
|
-
"no-products-to-add": "You have no products to add"
|
|
378
|
+
"no-products-to-add": "You have no products to add",
|
|
379
|
+
"not-enough-credits": "You do not have enough credits to make this purchase."
|
|
379
380
|
}
|
package/assets/ec-i18n/es.json
CHANGED
|
@@ -380,5 +380,6 @@
|
|
|
380
380
|
"success-review": "Su reseña fue enviada",
|
|
381
381
|
"error-convertibility": "Se produjo un error al realizar la conversión",
|
|
382
382
|
"repeat-order": "Repetir pedido",
|
|
383
|
-
"no-products-to-add": "No hay productos para agregar"
|
|
383
|
+
"no-products-to-add": "No hay productos para agregar",
|
|
384
|
+
"not-enough-credits": "No tiene suficientes créditos para comprar este producto"
|
|
384
385
|
}
|
package/assets/ec-i18n/fr.json
CHANGED
|
@@ -265,5 +265,6 @@
|
|
|
265
265
|
"will_contact": "Une fois le virement reçu, nous vous contacterons pour vous informer de l'état de votre achat",
|
|
266
266
|
"date": "Date",
|
|
267
267
|
"repeat-order": "Répéter la commande",
|
|
268
|
-
"no-products-to-add": "Aucun produit à ajouter"
|
|
268
|
+
"no-products-to-add": "Aucun produit à ajouter",
|
|
269
|
+
"not-enough-credits": "Vous n'avez pas assez de crédits pour acheter ce produit"
|
|
269
270
|
}
|
package/assets/ec-i18n/gl.json
CHANGED
|
@@ -273,5 +273,6 @@
|
|
|
273
273
|
"will_contact": "Unha vez recibida a transferencia, porémonos en contacto con vostede para informarche do estado da súa compra",
|
|
274
274
|
"date": "Data",
|
|
275
275
|
"repeat-order": "Repetir pedido",
|
|
276
|
-
"no-products-to-add": "Non hai produtos para engadir"
|
|
276
|
+
"no-products-to-add": "Non hai produtos para engadir",
|
|
277
|
+
"not-enough-credits": "Non ten suficientes créditos para realizar a compra"
|
|
277
278
|
}
|
package/assets/ec-i18n/pr.json
CHANGED
|
@@ -273,5 +273,6 @@
|
|
|
273
273
|
"will_contact": "Assim que a transferência for recebida, entraremos em contato para informá-lo sobre o status de sua compra",
|
|
274
274
|
"date": "Encontro",
|
|
275
275
|
"repeat-order": "Repetir pedido",
|
|
276
|
-
"no-products-to-add": "Não há produtos para adicionar"
|
|
276
|
+
"no-products-to-add": "Não há produtos para adicionar",
|
|
277
|
+
"not-enough-credits": "Você não tem créditos suficientes para fazer essa compra"
|
|
277
278
|
}
|
|
@@ -4524,6 +4524,14 @@
|
|
|
4524
4524
|
this.cartSubject = new rxjs.BehaviorSubject(null);
|
|
4525
4525
|
this.requestInProcess = new rxjs.BehaviorSubject(false);
|
|
4526
4526
|
this.promotionsSubject = new rxjs.BehaviorSubject([]);
|
|
4527
|
+
this.balanceCustomerSubject = new rxjs.BehaviorSubject({
|
|
4528
|
+
allowAnyPaymentMethod: false,
|
|
4529
|
+
allowExceedBalance: false,
|
|
4530
|
+
creditAmount: 0,
|
|
4531
|
+
showMax: false,
|
|
4532
|
+
showPrice: false,
|
|
4533
|
+
remainingCredits: 0,
|
|
4534
|
+
});
|
|
4527
4535
|
this.items = [];
|
|
4528
4536
|
this.count = 0;
|
|
4529
4537
|
this.locale = "";
|
|
@@ -4545,6 +4553,12 @@
|
|
|
4545
4553
|
this.cart = this.cartSubject.asObservable();
|
|
4546
4554
|
this.promotions = this.promotionsSubject.asObservable();
|
|
4547
4555
|
this.deleting = false;
|
|
4556
|
+
this.balanceCustomer$ = this.balanceCustomerSubject.asObservable();
|
|
4557
|
+
this.allowAnyPaymentMethod$ = this.balanceCustomer$.pipe(operators.map(function (data) { return data.allowAnyPaymentMethod; }));
|
|
4558
|
+
this.allowExceedBalance$ = this.balanceCustomer$.pipe(operators.map(function (data) { return data.allowExceedBalance; }));
|
|
4559
|
+
this.creditAmount$ = this.balanceCustomer$.pipe(operators.map(function (data) { return data.creditAmount; }));
|
|
4560
|
+
this.showMax$ = this.balanceCustomer$.pipe(operators.map(function (data) { return data.showMax; }));
|
|
4561
|
+
this.showPrice$ = this.balanceCustomer$.pipe(operators.map(function (data) { return data.showPrice; }));
|
|
4548
4562
|
this.getAddressBook = function () { return __awaiter$5(_this, void 0, void 0, function () { return __generator$5(this, function (_a) {
|
|
4549
4563
|
return [2 /*return*/, this.connection.get(this.addressBookApi()).pipe(operators.map(function (res) { var _a; return ((_a = res) === null || _a === void 0 ? void 0 : _a.length) && res.map(function (addres) { return addres && __assign$9(__assign$9({}, addres), { selected: addres.default }); }) || null; })).toPromise()];
|
|
4550
4564
|
}); }); };
|
|
@@ -4654,6 +4668,7 @@
|
|
|
4654
4668
|
this.resetCart = function (next) {
|
|
4655
4669
|
_this.items = [];
|
|
4656
4670
|
_this.cartSubject.next(null);
|
|
4671
|
+
_this.updateBalanceAttributes(null);
|
|
4657
4672
|
_this.cart_token = null;
|
|
4658
4673
|
_this.cartItemsSubject.next([]);
|
|
4659
4674
|
_this.count = 0;
|
|
@@ -4664,6 +4679,7 @@
|
|
|
4664
4679
|
this.updateCartObj = function (cart, emitEvent) {
|
|
4665
4680
|
if (emitEvent === void 0) { emitEvent = true; }
|
|
4666
4681
|
_this.cartSubject.next(cart);
|
|
4682
|
+
_this.updateBalanceAttributes(cart);
|
|
4667
4683
|
emitEvent && _this.analyticsService.callEvent('add_to_cart', cart);
|
|
4668
4684
|
_this.promotionsSubject.next(_this.orderUtils.getPromotions(cart, true));
|
|
4669
4685
|
cart.couponCode
|
|
@@ -4770,7 +4786,7 @@
|
|
|
4770
4786
|
return __spread$3(items, paramsMerge);
|
|
4771
4787
|
};
|
|
4772
4788
|
this.updateItemQuantity = function (item, quantity) {
|
|
4773
|
-
if (_this.validateQuantity(item, quantity)) {
|
|
4789
|
+
if (_this.validateQuantity(item, quantity) && (_this.validatePriceAndCredits(item, quantity))) {
|
|
4774
4790
|
_this.connection.put(_this.updateItemQuantityApi(_this.findItemByIdVariant(item.variant_id)), { 'quantity': Number(quantity) }).subscribe(function (res) { return _this.updateCartObj(res) && _this.updateCartItemQuantity(item.variant_id, Number(quantity)); }, function (err) { return _this.handleError(err); });
|
|
4775
4791
|
}
|
|
4776
4792
|
};
|
|
@@ -4785,6 +4801,38 @@
|
|
|
4785
4801
|
}
|
|
4786
4802
|
return true;
|
|
4787
4803
|
};
|
|
4804
|
+
this.validatePriceAndCredits = function (item, quantity) {
|
|
4805
|
+
if (_this.balanceCustomerSubject.value.creditAmount === null) {
|
|
4806
|
+
return true;
|
|
4807
|
+
}
|
|
4808
|
+
if (_this.balanceCustomerSubject.value.remainingCredits === undefined) {
|
|
4809
|
+
return false;
|
|
4810
|
+
}
|
|
4811
|
+
var unitPrice = item.total / item.quantity;
|
|
4812
|
+
var additionalQuantity = quantity - item.quantity;
|
|
4813
|
+
if (additionalQuantity <= 0) {
|
|
4814
|
+
return true;
|
|
4815
|
+
}
|
|
4816
|
+
var additionalCost = unitPrice * additionalQuantity;
|
|
4817
|
+
if (additionalCost > _this.balanceCustomerSubject.value.remainingCredits) {
|
|
4818
|
+
_this.toastrService.show('not-enough-credits');
|
|
4819
|
+
return false;
|
|
4820
|
+
}
|
|
4821
|
+
return true;
|
|
4822
|
+
};
|
|
4823
|
+
this.hasSufficientCreditsForCartTotal = function () {
|
|
4824
|
+
if (_this.balanceCustomerSubject.value.creditAmount === null) {
|
|
4825
|
+
return true;
|
|
4826
|
+
}
|
|
4827
|
+
if (_this.balanceCustomerSubject.value.remainingCredits === undefined) {
|
|
4828
|
+
return false;
|
|
4829
|
+
}
|
|
4830
|
+
if (_this.cartSubject.value.totals.total > _this.balanceCustomerSubject.value.creditAmount) {
|
|
4831
|
+
_this.toastrService.show('not-enough-credits');
|
|
4832
|
+
return false;
|
|
4833
|
+
}
|
|
4834
|
+
return true;
|
|
4835
|
+
};
|
|
4788
4836
|
this.calculateStockCounts = function (item, quantity) {
|
|
4789
4837
|
if (item.product.stock < item.quantity + quantity) {
|
|
4790
4838
|
// this.toastrService.show('out-of-stock');
|
|
@@ -4930,6 +4978,12 @@
|
|
|
4930
4978
|
// }, 100);
|
|
4931
4979
|
return item;
|
|
4932
4980
|
}); };
|
|
4981
|
+
this.getCreditAmount = function () {
|
|
4982
|
+
return _this.balanceCustomerSubject.pipe(operators.map(function (balanceCustomer) { var _a, _b; return _b = (_a = balanceCustomer) === null || _a === void 0 ? void 0 : _a.creditAmount, (_b !== null && _b !== void 0 ? _b : null); }));
|
|
4983
|
+
};
|
|
4984
|
+
this.getRemainingCredits = function () {
|
|
4985
|
+
return _this.balanceCustomerSubject.pipe(operators.map(function (balanceCustomer) { var _a; return (_a = balanceCustomer) === null || _a === void 0 ? void 0 : _a.remainingCredits; }));
|
|
4986
|
+
};
|
|
4933
4987
|
this.requestInProcess.next(true);
|
|
4934
4988
|
this.items = JSON.parse(localStorage.getItem('cart')) || [];
|
|
4935
4989
|
this.cart_token = localStorage.getItem('cart_token') || null;
|
|
@@ -5003,6 +5057,20 @@
|
|
|
5003
5057
|
return subtotal - total;
|
|
5004
5058
|
}));
|
|
5005
5059
|
};
|
|
5060
|
+
CartService$1.prototype.updateBalanceAttributes = function (cartData) {
|
|
5061
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
5062
|
+
var balanceData = {
|
|
5063
|
+
allowAnyPaymentMethod: (_b = (_a = cartData) === null || _a === void 0 ? void 0 : _a.allowAnyPaymentMethod, (_b !== null && _b !== void 0 ? _b : false)),
|
|
5064
|
+
allowExceedBalance: (_d = (_c = cartData) === null || _c === void 0 ? void 0 : _c.allowExceedBalance, (_d !== null && _d !== void 0 ? _d : false)),
|
|
5065
|
+
creditAmount: (_f = (_e = cartData) === null || _e === void 0 ? void 0 : _e.creditAmount, (_f !== null && _f !== void 0 ? _f : null)),
|
|
5066
|
+
showMax: (_h = (_g = cartData) === null || _g === void 0 ? void 0 : _g.showMax, (_h !== null && _h !== void 0 ? _h : false)),
|
|
5067
|
+
showPrice: (_k = (_j = cartData) === null || _j === void 0 ? void 0 : _j.showPrice, (_k !== null && _k !== void 0 ? _k : false)),
|
|
5068
|
+
remainingCredits: ((_l = cartData) === null || _l === void 0 ? void 0 : _l.creditAmount) && ((_m = cartData) === null || _m === void 0 ? void 0 : _m.creditAmount) >= ((_o = cartData) === null || _o === void 0 ? void 0 : _o.totals.total)
|
|
5069
|
+
? ((_p = cartData) === null || _p === void 0 ? void 0 : _p.creditAmount) - ((_q = cartData) === null || _q === void 0 ? void 0 : _q.totals.total)
|
|
5070
|
+
: 0,
|
|
5071
|
+
};
|
|
5072
|
+
this.balanceCustomerSubject.next(balanceData);
|
|
5073
|
+
};
|
|
5006
5074
|
CartService$1.ctorParameters = function () { return [
|
|
5007
5075
|
{ type: ConnectionService },
|
|
5008
5076
|
{ type: ToastService },
|
|
@@ -7208,7 +7276,14 @@
|
|
|
7208
7276
|
cantidad > 0 && cantidad <= stock ? _this.cartService.updateItemQuantity(item, cantidad) : _this.toastrService.show('out-of-stock-actually');
|
|
7209
7277
|
}
|
|
7210
7278
|
};
|
|
7211
|
-
_this.redirectCheckout = function () {
|
|
7279
|
+
_this.redirectCheckout = function () {
|
|
7280
|
+
if (_this.cartService.hasSufficientCreditsForCartTotal()) {
|
|
7281
|
+
_this.router.navigateByUrl("/checkout");
|
|
7282
|
+
}
|
|
7283
|
+
else {
|
|
7284
|
+
console.warn("No se puede redirigir al checkout debido a una validación fallida.");
|
|
7285
|
+
}
|
|
7286
|
+
};
|
|
7212
7287
|
_this.redirectRegister = function () { return _this.router.navigateByUrl("/auth/login"); };
|
|
7213
7288
|
_this.getVariants = function (product) {
|
|
7214
7289
|
var item = product.product;
|
|
@@ -9486,8 +9561,15 @@
|
|
|
9486
9561
|
this.paramsService.parameters.subscribe(function (res) { return _this.params = res; });
|
|
9487
9562
|
var mediaQuery = window.matchMedia('(max-width: 992px)');
|
|
9488
9563
|
this.mediaMenu = mediaQuery.matches;
|
|
9564
|
+
this.subscribeToBalance();
|
|
9489
9565
|
this.ecOnInit();
|
|
9490
9566
|
};
|
|
9567
|
+
HeaderEcComponent.prototype.subscribeToBalance = function () {
|
|
9568
|
+
var _this = this;
|
|
9569
|
+
this.balanceSubscription = this.cartService.balanceCustomer$.subscribe(function (balanceData) {
|
|
9570
|
+
_this.balanceAttributes = balanceData;
|
|
9571
|
+
});
|
|
9572
|
+
};
|
|
9491
9573
|
HeaderEcComponent.ctorParameters = function () { return [
|
|
9492
9574
|
{ type: router.Router },
|
|
9493
9575
|
{ type: Constants },
|
|
@@ -9976,6 +10058,7 @@
|
|
|
9976
10058
|
_this.optionsSubject.next(_this.getOptions());
|
|
9977
10059
|
variant_code ? _this.updateVariants(variant_code) : _this.updateVariants();
|
|
9978
10060
|
_this.variants.length && _this.generateAsociatedDataFromVariants();
|
|
10061
|
+
_this.fetchCartData();
|
|
9979
10062
|
//this.analyticsService.callEvent('view_item', { ...product, currency: this.constants.currency.code })
|
|
9980
10063
|
// variant_code && this.analyticsService.callEvent('view_item', { ...product, currency: this.constants.currency.code })
|
|
9981
10064
|
};
|
|
@@ -10188,6 +10271,31 @@
|
|
|
10188
10271
|
}
|
|
10189
10272
|
return true;
|
|
10190
10273
|
};
|
|
10274
|
+
this.validatePriceAndCredits = function (price) {
|
|
10275
|
+
if (_this.creditAmount === null) {
|
|
10276
|
+
console.log('No hay configuración de créditos para este usuario.');
|
|
10277
|
+
return true;
|
|
10278
|
+
}
|
|
10279
|
+
if (_this.remainingCredits === undefined) {
|
|
10280
|
+
return false;
|
|
10281
|
+
}
|
|
10282
|
+
if (price > _this.remainingCredits) {
|
|
10283
|
+
_this.toastrService.show('not-enough-credits');
|
|
10284
|
+
return false;
|
|
10285
|
+
}
|
|
10286
|
+
return true;
|
|
10287
|
+
};
|
|
10288
|
+
this.fetchCartData = function () {
|
|
10289
|
+
_this.cartService.getTotalAmount().subscribe(function (totalAmount) {
|
|
10290
|
+
_this.currentTotalAmount = totalAmount;
|
|
10291
|
+
});
|
|
10292
|
+
_this.cartService.getCreditAmount().subscribe(function (creditAmount) {
|
|
10293
|
+
_this.creditAmount = creditAmount;
|
|
10294
|
+
});
|
|
10295
|
+
_this.cartService.getRemainingCredits().subscribe(function (remainingCredits) {
|
|
10296
|
+
_this.remainingCredits = remainingCredits;
|
|
10297
|
+
});
|
|
10298
|
+
};
|
|
10191
10299
|
// Cuando haya modelos de respuesta, validamos que no se intente cargar un producto incompleto
|
|
10192
10300
|
this.isProductValid = function (product) { return true; };
|
|
10193
10301
|
/**
|
|
@@ -10242,6 +10350,8 @@
|
|
|
10242
10350
|
return;
|
|
10243
10351
|
if (!this.validateQuantity(quantity))
|
|
10244
10352
|
return;
|
|
10353
|
+
if (!this.validatePriceAndCredits(product_selected.price * quantity))
|
|
10354
|
+
return;
|
|
10245
10355
|
this.cartService.addToCart(this.makeAffordableProduct(product_selected), quantity, variant.code);
|
|
10246
10356
|
};
|
|
10247
10357
|
;
|
|
@@ -15948,7 +16058,7 @@
|
|
|
15948
16058
|
_this.prev = function (index) {
|
|
15949
16059
|
if (index === void 0) { index = -1; }
|
|
15950
16060
|
_this.values.pop();
|
|
15951
|
-
|
|
16061
|
+
// this.attributes.pop();
|
|
15952
16062
|
_this.total.pop();
|
|
15953
16063
|
_this.taxonCode = 0;
|
|
15954
16064
|
_this.noMoreCoincidences = false;
|