ng-easycommerce 0.0.623 → 0.0.625

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.
Files changed (30) hide show
  1. package/README.md +6 -0
  2. package/assets/ec-i18n/ct.json +2 -1
  3. package/assets/ec-i18n/en.json +2 -1
  4. package/assets/ec-i18n/es.json +1 -0
  5. package/assets/ec-i18n/fr.json +2 -1
  6. package/assets/ec-i18n/gl.json +2 -1
  7. package/assets/ec-i18n/pr.json +2 -1
  8. package/bundles/ng-easycommerce.umd.js +136 -56
  9. package/bundles/ng-easycommerce.umd.js.map +1 -1
  10. package/bundles/ng-easycommerce.umd.min.js +1 -1
  11. package/bundles/ng-easycommerce.umd.min.js.map +1 -1
  12. package/esm2015/lib/ec-component/cart-ec/cart-ec.component.js +41 -23
  13. package/esm2015/lib/ec-component/product-detail-ec/product-detail-ec.component.js +35 -17
  14. package/esm2015/lib/ec-component/sidebar-ec/sidebar-ec.component.js +42 -16
  15. package/esm2015/lib/services/cart.service.js +7 -1
  16. package/esm2015/lib/services/products/product-detail.service.js +11 -4
  17. package/esm5/lib/ec-component/cart-ec/cart-ec.component.js +42 -23
  18. package/esm5/lib/ec-component/product-detail-ec/product-detail-ec.component.js +39 -17
  19. package/esm5/lib/ec-component/sidebar-ec/sidebar-ec.component.js +42 -16
  20. package/esm5/lib/services/cart.service.js +7 -1
  21. package/esm5/lib/services/products/product-detail.service.js +11 -4
  22. package/fesm2015/ng-easycommerce.js +131 -56
  23. package/fesm2015/ng-easycommerce.js.map +1 -1
  24. package/fesm5/ng-easycommerce.js +136 -56
  25. package/fesm5/ng-easycommerce.js.map +1 -1
  26. package/lib/ec-component/cart-ec/cart-ec.component.d.ts +1 -1
  27. package/lib/ec-component/product-detail-ec/product-detail-ec.component.d.ts +9 -7
  28. package/lib/ec-component/sidebar-ec/sidebar-ec.component.d.ts +1 -1
  29. package/ng-easycommerce.metadata.json +1 -1
  30. package/package.json +1 -1
package/README.md CHANGED
@@ -1,3 +1,9 @@
1
+ # version 0.0.625
2
+ - Se modifico la funcion `actualizarCantidad` en `cart-ec.component` y `sidebar-ec.component` para que tengan en cuenta la suma o resta de cantidades por múltiplos.
3
+ - En `cart.service` se agregó la validación para asegurar que la cantidad ingresada sea múltiplo del valor permitido.
4
+ # version 0.0.624
5
+ - Se modificaron las funciones `plus` y `less` en `product-detail.component` para que tengan en cuenta la suma o resta de cantidades por múltiplos.
6
+ - En `product-detail.service` se agregó la validación para asegurar que la cantidad ingresada sea múltiplo del valor permitido.
1
7
  # version 0.0.623
2
8
  - Arreglo traducciones en checkout, y texto flotante.
3
9
  # version 0.0.622
@@ -294,5 +294,6 @@
294
294
  "national-taxes": "Impostos nacionals",
295
295
  "taxes": "Impostos",
296
296
  "price-without-national-taxes": "Preu sense impostos nacionals",
297
- "this-payment-method-cannot-be-used": "Aquest mètode de pagament no es pot utilitzar"
297
+ "this-payment-method-cannot-be-used": "Aquest mètode de pagament no es pot utilitzar",
298
+ "must-be-multiple": "La quantitat total ha de ser un múltiple de {{quantity}}"
298
299
  }
@@ -405,5 +405,6 @@
405
405
  "clientTaxes": "Taxes per customer",
406
406
  "email_already_registered": "The email entered is already registered.",
407
407
  "mail-enter": "Mail",
408
- "this-payment-method-cannot-be-used": "This payment method cannot be used"
408
+ "this-payment-method-cannot-be-used": "This payment method cannot be used",
409
+ "must-be-multiple": "The total quantity must be a multiple of {{quantity}}"
409
410
  }
@@ -174,6 +174,7 @@
174
174
  "men-fashion": "Hombres",
175
175
  "mercado-pago": "Mercado Pago",
176
176
  "minimum-items-quantity": "La cantidad minima de compra del producto es {{quantity}}",
177
+ "must-be-multiple": "La cantidad total debe ser múltiplo de {{quantity}}",
177
178
  "most-expensive-first": "Mayor precio",
178
179
  "my-account": "Mi cuenta",
179
180
  "my-account-description": "Desde el panel de Mi cuenta, tiene la capacidad de ver una instantánea de la actividad reciente de su cuenta y actualizar su información personal. Seleccione un enlace de abajo para ver o editar información.",
@@ -286,5 +286,6 @@
286
286
  "national-taxes": "Taxes nationales",
287
287
  "taxes": "Taxes",
288
288
  "price-without-national-taxes": "Prix sans taxes nationales",
289
- "this-payment-method-cannot-be-used": "Ce mode de paiement ne peut pas être utilisé"
289
+ "this-payment-method-cannot-be-used": "Ce mode de paiement ne peut pas être utilisé",
290
+ "must-be-multiple": "La quantité totale doit être un multiple de {{quantity}}"
290
291
  }
@@ -294,5 +294,6 @@
294
294
  "national-taxes": "Impostos nacionais",
295
295
  "taxes": "Impostos",
296
296
  "price-without-national-taxes": "Prezo sen impostos nacionais",
297
- "this-payment-method-cannot-be-used": "Este método de pago non pode ser usado"
297
+ "this-payment-method-cannot-be-used": "Este método de pago non pode ser usado",
298
+ "must-be-multiple": "A cantidade total debe ser múltiplo de {{quantity}}"
298
299
  }
@@ -294,5 +294,6 @@
294
294
  "national-taxes": "Impostos nacionais",
295
295
  "taxes": "Impostos",
296
296
  "price-without-national-taxes": "Preço sem impostos nacionais",
297
- "this-payment-method-cannot-be-used": "Este método de pagamento não pode ser utilizado"
297
+ "this-payment-method-cannot-be-used": "Este método de pagamento não pode ser utilizado",
298
+ "must-be-multiple": "A quantidade total deve ser um múltiplo de {{quantity}}"
298
299
  }
@@ -4893,6 +4893,12 @@
4893
4893
  _this.toastrService.show('minimum-items-quantity', { quantity: item.product.variants[0].minimumItemsQuantity });
4894
4894
  return false;
4895
4895
  }
4896
+ if (item.product.variants[0].multipleQuantity && item.product.variants[0].multipleQuantity > 0) {
4897
+ if ((_this.getCountFromItemInCart(item.productCode) + quantity) % item.product.variants[0].multipleQuantity !== 0) {
4898
+ _this.toastrService.show('must-be-multiple', { quantity: item.product.variants[0].multipleQuantity });
4899
+ return false;
4900
+ }
4901
+ }
4896
4902
  return true;
4897
4903
  };
4898
4904
  this.validatePriceAndCredits = function (item, quantity) {
@@ -7431,28 +7437,6 @@
7431
7437
  _this.creditAccountShowPrices = null;
7432
7438
  _this.showTaxLegend = false;
7433
7439
  _this.toDecimal = function (amount) { return _this.consts.toDecimal(amount); };
7434
- _this.actualizarCantidad = function (item, cantidad, stock, id) {
7435
- if (id) {
7436
- _this.isDisabled = true; // Actualiza la propiedad vinculada a `[disabled]`
7437
- if (cantidad > 0 && cantidad <= stock) {
7438
- _this.cartService.updateItemQuantity(item, cantidad);
7439
- }
7440
- else {
7441
- _this.toastrService.show('out-of-stock-actually');
7442
- }
7443
- setTimeout(function () {
7444
- _this.isDisabled = false;
7445
- }, 1000);
7446
- }
7447
- else {
7448
- if (cantidad > 0 && cantidad <= stock) {
7449
- _this.cartService.updateItemQuantity(item, cantidad);
7450
- }
7451
- else {
7452
- _this.toastrService.show('out-of-stock-actually');
7453
- }
7454
- }
7455
- };
7456
7440
  _this.redirectRegister = function () { return _this.router.navigateByUrl("/auth/login"); };
7457
7441
  _this.getVariants = function (product) {
7458
7442
  var item = product.product;
@@ -7529,6 +7513,47 @@
7529
7513
  });
7530
7514
  this.ecOnInit();
7531
7515
  };
7516
+ CartEcComponent.prototype.actualizarCantidad = function (item, cantidad, stock, id) {
7517
+ var _this = this;
7518
+ var _a;
7519
+ var multipleQuantity = ((_a = item.product) === null || _a === void 0 ? void 0 : _a.variants) && item.product.variants.length > 0 ? item.product.variants[0].multipleQuantity : 0;
7520
+ var step = multipleQuantity && multipleQuantity > 0 ? multipleQuantity : 1;
7521
+ var newQuantity;
7522
+ if (typeof cantidad === 'string') {
7523
+ newQuantity = parseInt(cantidad, 10);
7524
+ if (newQuantity % step !== 0) {
7525
+ this.toastrService.show('must-be-multiple', { quantity: step });
7526
+ newQuantity = Math.round(newQuantity / step) * step;
7527
+ }
7528
+ }
7529
+ else {
7530
+ newQuantity = cantidad;
7531
+ if (newQuantity % step !== 0) {
7532
+ newQuantity = Math.round(newQuantity / step) * step;
7533
+ }
7534
+ }
7535
+ if (id) {
7536
+ this.isDisabled = true; // Actualiza la propiedad vinculada a `[disabled]`
7537
+ if (newQuantity > 0 && newQuantity <= stock) {
7538
+ this.cartService.updateItemQuantity(item, newQuantity);
7539
+ }
7540
+ else {
7541
+ this.toastrService.show('out-of-stock-actually');
7542
+ }
7543
+ setTimeout(function () {
7544
+ _this.isDisabled = false;
7545
+ }, 1000);
7546
+ }
7547
+ else {
7548
+ if (newQuantity > 0 && newQuantity <= stock) {
7549
+ this.cartService.updateItemQuantity(item, newQuantity);
7550
+ }
7551
+ else {
7552
+ this.toastrService.show('out-of-stock-actually');
7553
+ }
7554
+ }
7555
+ };
7556
+ ;
7532
7557
  CartEcComponent.prototype.redirectCheckout = function () {
7533
7558
  if (this.cartService.hasSufficientCreditsForCartTotal()) {
7534
7559
  this.router.navigateByUrl("/checkout");
@@ -10736,15 +10761,22 @@
10736
10761
  this.validateQuantity = function (quantity) {
10737
10762
  var actualQuantity = _this.cartService.getCountFromItemInCart(_this.variants[0].code);
10738
10763
  var asociatedData = _this.asociatedDataSubject.value;
10739
- console.log('La cantidad que llego: ', quantity, ' y la cantidad actual: ', actualQuantity);
10740
- if ((actualQuantity + quantity) > asociatedData.maximumItemsQuantity) {
10764
+ var totalQuantity = actualQuantity + quantity;
10765
+ console.log('La cantidad que llegó: ', quantity, ' y la cantidad actual: ', actualQuantity);
10766
+ if (asociatedData.maximumItemsQuantity && totalQuantity > asociatedData.maximumItemsQuantity) {
10741
10767
  _this.toastrService.show('maximum-items-quantity', { quantity: asociatedData.maximumItemsQuantity });
10742
10768
  return false;
10743
10769
  }
10744
- if ((actualQuantity + quantity) < asociatedData.minimumItemsQuantity) {
10770
+ if (asociatedData.minimumItemsQuantity && totalQuantity < asociatedData.minimumItemsQuantity) {
10745
10771
  _this.toastrService.show('minimum-items-quantity', { quantity: asociatedData.minimumItemsQuantity });
10746
10772
  return false;
10747
10773
  }
10774
+ if (asociatedData.multipleQuantity && asociatedData.multipleQuantity > 0) {
10775
+ if (totalQuantity % asociatedData.multipleQuantity !== 0) {
10776
+ _this.toastrService.show('must-be-multiple', { quantity: asociatedData.multipleQuantity });
10777
+ return false;
10778
+ }
10779
+ }
10748
10780
  return true;
10749
10781
  };
10750
10782
  this.validatePriceAndCredits = function (price) {
@@ -10975,29 +11007,51 @@
10975
11007
  };
10976
11008
  /**
10977
11009
  * @description actualiza la variable quantity sumandole 'x' contenido.
10978
- * @param stock debe recibir un number que contenga el stock disponible.
10979
- * @param multipleQuantity debe recibir el multiplo de cantidad que se quiera incrementar.
11010
+ * @param stock número máximo disponible en stock.
11011
+ * @param changeAmount cantidad que se quiere sumar.
11012
+ * @param forceMultiple si es true, obliga a que el resultado sea múltiplo de changeAmount.
10980
11013
  */
10981
- _this.plus = function (stock, multipleQuantity) {
10982
- if (multipleQuantity && multipleQuantity > 0) {
10983
- stock ? (_this.quantity < stock ? _this.quantity = _this.quantity + multipleQuantity : _this.toastrService.show('out-of-stock-actually'))
10984
- : _this.quantity = _this.quantity + multipleQuantity;
11014
+ _this.plus = function (stock, changeAmount, forceMultiple) {
11015
+ if (changeAmount === void 0) { changeAmount = 1; }
11016
+ if (forceMultiple === void 0) { forceMultiple = false; }
11017
+ var newQuantity = _this.quantity + changeAmount;
11018
+ if (forceMultiple && changeAmount > 0) {
11019
+ if (_this.quantity < changeAmount) {
11020
+ newQuantity = changeAmount;
11021
+ }
11022
+ else {
11023
+ newQuantity = Math.ceil(newQuantity / changeAmount) * changeAmount;
11024
+ }
11025
+ }
11026
+ if (!stock || newQuantity <= stock) {
11027
+ _this.quantity = newQuantity;
10985
11028
  }
10986
11029
  else {
10987
- stock ? (_this.quantity < stock ? _this.quantity = _this.quantity + 1 : _this.toastrService.show('out-of-stock-actually'))
10988
- : _this.quantity = _this.quantity + 1;
11030
+ _this.toastrService.show('out-of-stock-actually');
10989
11031
  }
10990
11032
  };
10991
11033
  /**
10992
- * @description actualiza la varible quantity restandole 'x' contenido.
10993
- * @param multipleQuantity debe recibir el multiplo de cantidad que se quiera decrementar.
10994
- */
10995
- _this.less = function (multipleQuantity) {
10996
- if (multipleQuantity && multipleQuantity > 0) {
10997
- _this.quantity > multipleQuantity ? _this.quantity = _this.quantity - multipleQuantity : null;
11034
+ * @description actualiza la variable quantity restandole 'x' contenido.
11035
+ * @param changeAmount cantidad que se quiere restar.
11036
+ * @param forceMultiple si es true, obliga a que el resultado sea múltiplo de changeAmount.
11037
+ */
11038
+ _this.less = function (changeAmount, forceMultiple) {
11039
+ if (changeAmount === void 0) { changeAmount = 1; }
11040
+ if (forceMultiple === void 0) { forceMultiple = false; }
11041
+ var newQuantity = _this.quantity - changeAmount;
11042
+ if (forceMultiple && changeAmount > 0) {
11043
+ if (_this.quantity <= changeAmount) {
11044
+ newQuantity = changeAmount;
11045
+ }
11046
+ else {
11047
+ newQuantity = Math.floor(newQuantity / changeAmount) * changeAmount;
11048
+ }
11049
+ if (newQuantity < changeAmount) {
11050
+ newQuantity = changeAmount;
11051
+ }
10998
11052
  }
10999
- else {
11000
- _this.quantity > 1 ? _this.quantity = _this.quantity - 1 : null;
11053
+ if (newQuantity >= 1) {
11054
+ _this.quantity = newQuantity;
11001
11055
  }
11002
11056
  };
11003
11057
  _this.showContact = function () { return _this.show = true; };
@@ -18801,21 +18855,6 @@
18801
18855
  this.hideTaxes = false;
18802
18856
  this.creditAccountShowPrices = null;
18803
18857
  this.showTaxLegend = false;
18804
- this.actualizarCantidad = function (item, cantidad, stock, id) {
18805
- if (id) {
18806
- var elem_1 = document.getElementById(id);
18807
- elem_1.disabled = true;
18808
- cantidad > 0 && cantidad <= stock
18809
- ? _this.cartService.updateItemQuantity(item, cantidad)
18810
- : _this.toastrService.show('out-of-stock-actually');
18811
- setTimeout(function () {
18812
- elem_1.disabled = false;
18813
- }, 1000);
18814
- }
18815
- else {
18816
- cantidad > 0 && cantidad <= stock && _this.cartService.updateItemQuantity(item, cantidad);
18817
- }
18818
- };
18819
18858
  this.getVariants = function (product) {
18820
18859
  var item = product.product;
18821
18860
  if (item.variants && item.variants.length && item.variants[0].options && item.variants[0].options.length) {
@@ -18874,6 +18913,47 @@
18874
18913
  _this.creditAccountShowPrices = showPrice;
18875
18914
  });
18876
18915
  };
18916
+ SidebarEcComponent.prototype.actualizarCantidad = function (item, cantidad, stock, id) {
18917
+ var _a;
18918
+ var multipleQuantity = ((_a = item.product) === null || _a === void 0 ? void 0 : _a.variants) && item.product.variants.length > 0 ? item.product.variants[0].multipleQuantity : 0;
18919
+ var step = multipleQuantity && multipleQuantity > 0 ? multipleQuantity : 1;
18920
+ var newQuantity;
18921
+ if (typeof cantidad === 'string') {
18922
+ newQuantity = parseInt(cantidad, 10);
18923
+ if (newQuantity % step !== 0) {
18924
+ this.toastrService.show('must-be-multiple', { quantity: step });
18925
+ newQuantity = Math.round(newQuantity / step) * step;
18926
+ }
18927
+ }
18928
+ else {
18929
+ newQuantity = cantidad;
18930
+ if (newQuantity % step !== 0) {
18931
+ newQuantity = Math.round(newQuantity / step) * step;
18932
+ }
18933
+ }
18934
+ if (id) {
18935
+ var elem_1 = document.getElementById(id);
18936
+ if (elem_1) {
18937
+ elem_1.disabled = true;
18938
+ }
18939
+ if (newQuantity > 0 && newQuantity <= stock) {
18940
+ this.cartService.updateItemQuantity(item, newQuantity);
18941
+ }
18942
+ else {
18943
+ this.toastrService.show('out-of-stock-actually');
18944
+ }
18945
+ if (elem_1) {
18946
+ setTimeout(function () {
18947
+ elem_1.disabled = false;
18948
+ }, 1000);
18949
+ }
18950
+ }
18951
+ else {
18952
+ if (newQuantity > 0 && newQuantity <= stock) {
18953
+ this.cartService.updateItemQuantity(item, newQuantity);
18954
+ }
18955
+ }
18956
+ };
18877
18957
  SidebarEcComponent.prototype.redirectDetailProduct = function (product) {
18878
18958
  var variant = product.variants[0];
18879
18959
  var path = '/product/';