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
@@ -4907,6 +4907,12 @@ var CartService = /** @class */ (function () {
4907
4907
  _this.toastrService.show('minimum-items-quantity', { quantity: item.product.variants[0].minimumItemsQuantity });
4908
4908
  return false;
4909
4909
  }
4910
+ if (item.product.variants[0].multipleQuantity && item.product.variants[0].multipleQuantity > 0) {
4911
+ if ((_this.getCountFromItemInCart(item.productCode) + quantity) % item.product.variants[0].multipleQuantity !== 0) {
4912
+ _this.toastrService.show('must-be-multiple', { quantity: item.product.variants[0].multipleQuantity });
4913
+ return false;
4914
+ }
4915
+ }
4910
4916
  return true;
4911
4917
  };
4912
4918
  this.validatePriceAndCredits = function (item, quantity) {
@@ -7445,28 +7451,6 @@ var CartEcComponent = /** @class */ (function (_super) {
7445
7451
  _this.creditAccountShowPrices = null;
7446
7452
  _this.showTaxLegend = false;
7447
7453
  _this.toDecimal = function (amount) { return _this.consts.toDecimal(amount); };
7448
- _this.actualizarCantidad = function (item, cantidad, stock, id) {
7449
- if (id) {
7450
- _this.isDisabled = true; // Actualiza la propiedad vinculada a `[disabled]`
7451
- if (cantidad > 0 && cantidad <= stock) {
7452
- _this.cartService.updateItemQuantity(item, cantidad);
7453
- }
7454
- else {
7455
- _this.toastrService.show('out-of-stock-actually');
7456
- }
7457
- setTimeout(function () {
7458
- _this.isDisabled = false;
7459
- }, 1000);
7460
- }
7461
- else {
7462
- if (cantidad > 0 && cantidad <= stock) {
7463
- _this.cartService.updateItemQuantity(item, cantidad);
7464
- }
7465
- else {
7466
- _this.toastrService.show('out-of-stock-actually');
7467
- }
7468
- }
7469
- };
7470
7454
  _this.redirectRegister = function () { return _this.router.navigateByUrl("/auth/login"); };
7471
7455
  _this.getVariants = function (product) {
7472
7456
  var item = product.product;
@@ -7543,6 +7527,47 @@ var CartEcComponent = /** @class */ (function (_super) {
7543
7527
  });
7544
7528
  this.ecOnInit();
7545
7529
  };
7530
+ CartEcComponent.prototype.actualizarCantidad = function (item, cantidad, stock, id) {
7531
+ var _this = this;
7532
+ var _a;
7533
+ var multipleQuantity = ((_a = item.product) === null || _a === void 0 ? void 0 : _a.variants) && item.product.variants.length > 0 ? item.product.variants[0].multipleQuantity : 0;
7534
+ var step = multipleQuantity && multipleQuantity > 0 ? multipleQuantity : 1;
7535
+ var newQuantity;
7536
+ if (typeof cantidad === 'string') {
7537
+ newQuantity = parseInt(cantidad, 10);
7538
+ if (newQuantity % step !== 0) {
7539
+ this.toastrService.show('must-be-multiple', { quantity: step });
7540
+ newQuantity = Math.round(newQuantity / step) * step;
7541
+ }
7542
+ }
7543
+ else {
7544
+ newQuantity = cantidad;
7545
+ if (newQuantity % step !== 0) {
7546
+ newQuantity = Math.round(newQuantity / step) * step;
7547
+ }
7548
+ }
7549
+ if (id) {
7550
+ this.isDisabled = true; // Actualiza la propiedad vinculada a `[disabled]`
7551
+ if (newQuantity > 0 && newQuantity <= stock) {
7552
+ this.cartService.updateItemQuantity(item, newQuantity);
7553
+ }
7554
+ else {
7555
+ this.toastrService.show('out-of-stock-actually');
7556
+ }
7557
+ setTimeout(function () {
7558
+ _this.isDisabled = false;
7559
+ }, 1000);
7560
+ }
7561
+ else {
7562
+ if (newQuantity > 0 && newQuantity <= stock) {
7563
+ this.cartService.updateItemQuantity(item, newQuantity);
7564
+ }
7565
+ else {
7566
+ this.toastrService.show('out-of-stock-actually');
7567
+ }
7568
+ }
7569
+ };
7570
+ ;
7546
7571
  CartEcComponent.prototype.redirectCheckout = function () {
7547
7572
  if (this.cartService.hasSufficientCreditsForCartTotal()) {
7548
7573
  this.router.navigateByUrl("/checkout");
@@ -10750,15 +10775,22 @@ var ProductDetailService = /** @class */ (function () {
10750
10775
  this.validateQuantity = function (quantity) {
10751
10776
  var actualQuantity = _this.cartService.getCountFromItemInCart(_this.variants[0].code);
10752
10777
  var asociatedData = _this.asociatedDataSubject.value;
10753
- console.log('La cantidad que llego: ', quantity, ' y la cantidad actual: ', actualQuantity);
10754
- if ((actualQuantity + quantity) > asociatedData.maximumItemsQuantity) {
10778
+ var totalQuantity = actualQuantity + quantity;
10779
+ console.log('La cantidad que llegó: ', quantity, ' y la cantidad actual: ', actualQuantity);
10780
+ if (asociatedData.maximumItemsQuantity && totalQuantity > asociatedData.maximumItemsQuantity) {
10755
10781
  _this.toastrService.show('maximum-items-quantity', { quantity: asociatedData.maximumItemsQuantity });
10756
10782
  return false;
10757
10783
  }
10758
- if ((actualQuantity + quantity) < asociatedData.minimumItemsQuantity) {
10784
+ if (asociatedData.minimumItemsQuantity && totalQuantity < asociatedData.minimumItemsQuantity) {
10759
10785
  _this.toastrService.show('minimum-items-quantity', { quantity: asociatedData.minimumItemsQuantity });
10760
10786
  return false;
10761
10787
  }
10788
+ if (asociatedData.multipleQuantity && asociatedData.multipleQuantity > 0) {
10789
+ if (totalQuantity % asociatedData.multipleQuantity !== 0) {
10790
+ _this.toastrService.show('must-be-multiple', { quantity: asociatedData.multipleQuantity });
10791
+ return false;
10792
+ }
10793
+ }
10762
10794
  return true;
10763
10795
  };
10764
10796
  this.validatePriceAndCredits = function (price) {
@@ -10989,29 +11021,51 @@ var ProductDetailEcComponent = /** @class */ (function (_super) {
10989
11021
  };
10990
11022
  /**
10991
11023
  * @description actualiza la variable quantity sumandole 'x' contenido.
10992
- * @param stock debe recibir un number que contenga el stock disponible.
10993
- * @param multipleQuantity debe recibir el multiplo de cantidad que se quiera incrementar.
11024
+ * @param stock número máximo disponible en stock.
11025
+ * @param changeAmount cantidad que se quiere sumar.
11026
+ * @param forceMultiple si es true, obliga a que el resultado sea múltiplo de changeAmount.
10994
11027
  */
10995
- _this.plus = function (stock, multipleQuantity) {
10996
- if (multipleQuantity && multipleQuantity > 0) {
10997
- stock ? (_this.quantity < stock ? _this.quantity = _this.quantity + multipleQuantity : _this.toastrService.show('out-of-stock-actually'))
10998
- : _this.quantity = _this.quantity + multipleQuantity;
11028
+ _this.plus = function (stock, changeAmount, forceMultiple) {
11029
+ if (changeAmount === void 0) { changeAmount = 1; }
11030
+ if (forceMultiple === void 0) { forceMultiple = false; }
11031
+ var newQuantity = _this.quantity + changeAmount;
11032
+ if (forceMultiple && changeAmount > 0) {
11033
+ if (_this.quantity < changeAmount) {
11034
+ newQuantity = changeAmount;
11035
+ }
11036
+ else {
11037
+ newQuantity = Math.ceil(newQuantity / changeAmount) * changeAmount;
11038
+ }
11039
+ }
11040
+ if (!stock || newQuantity <= stock) {
11041
+ _this.quantity = newQuantity;
10999
11042
  }
11000
11043
  else {
11001
- stock ? (_this.quantity < stock ? _this.quantity = _this.quantity + 1 : _this.toastrService.show('out-of-stock-actually'))
11002
- : _this.quantity = _this.quantity + 1;
11044
+ _this.toastrService.show('out-of-stock-actually');
11003
11045
  }
11004
11046
  };
11005
11047
  /**
11006
- * @description actualiza la varible quantity restandole 'x' contenido.
11007
- * @param multipleQuantity debe recibir el multiplo de cantidad que se quiera decrementar.
11008
- */
11009
- _this.less = function (multipleQuantity) {
11010
- if (multipleQuantity && multipleQuantity > 0) {
11011
- _this.quantity > multipleQuantity ? _this.quantity = _this.quantity - multipleQuantity : null;
11048
+ * @description actualiza la variable quantity restandole 'x' contenido.
11049
+ * @param changeAmount cantidad que se quiere restar.
11050
+ * @param forceMultiple si es true, obliga a que el resultado sea múltiplo de changeAmount.
11051
+ */
11052
+ _this.less = function (changeAmount, forceMultiple) {
11053
+ if (changeAmount === void 0) { changeAmount = 1; }
11054
+ if (forceMultiple === void 0) { forceMultiple = false; }
11055
+ var newQuantity = _this.quantity - changeAmount;
11056
+ if (forceMultiple && changeAmount > 0) {
11057
+ if (_this.quantity <= changeAmount) {
11058
+ newQuantity = changeAmount;
11059
+ }
11060
+ else {
11061
+ newQuantity = Math.floor(newQuantity / changeAmount) * changeAmount;
11062
+ }
11063
+ if (newQuantity < changeAmount) {
11064
+ newQuantity = changeAmount;
11065
+ }
11012
11066
  }
11013
- else {
11014
- _this.quantity > 1 ? _this.quantity = _this.quantity - 1 : null;
11067
+ if (newQuantity >= 1) {
11068
+ _this.quantity = newQuantity;
11015
11069
  }
11016
11070
  };
11017
11071
  _this.showContact = function () { return _this.show = true; };
@@ -18815,21 +18869,6 @@ var SidebarEcComponent = /** @class */ (function () {
18815
18869
  this.hideTaxes = false;
18816
18870
  this.creditAccountShowPrices = null;
18817
18871
  this.showTaxLegend = false;
18818
- this.actualizarCantidad = function (item, cantidad, stock, id) {
18819
- if (id) {
18820
- var elem_1 = document.getElementById(id);
18821
- elem_1.disabled = true;
18822
- cantidad > 0 && cantidad <= stock
18823
- ? _this.cartService.updateItemQuantity(item, cantidad)
18824
- : _this.toastrService.show('out-of-stock-actually');
18825
- setTimeout(function () {
18826
- elem_1.disabled = false;
18827
- }, 1000);
18828
- }
18829
- else {
18830
- cantidad > 0 && cantidad <= stock && _this.cartService.updateItemQuantity(item, cantidad);
18831
- }
18832
- };
18833
18872
  this.getVariants = function (product) {
18834
18873
  var item = product.product;
18835
18874
  if (item.variants && item.variants.length && item.variants[0].options && item.variants[0].options.length) {
@@ -18888,6 +18927,47 @@ var SidebarEcComponent = /** @class */ (function () {
18888
18927
  _this.creditAccountShowPrices = showPrice;
18889
18928
  });
18890
18929
  };
18930
+ SidebarEcComponent.prototype.actualizarCantidad = function (item, cantidad, stock, id) {
18931
+ var _a;
18932
+ var multipleQuantity = ((_a = item.product) === null || _a === void 0 ? void 0 : _a.variants) && item.product.variants.length > 0 ? item.product.variants[0].multipleQuantity : 0;
18933
+ var step = multipleQuantity && multipleQuantity > 0 ? multipleQuantity : 1;
18934
+ var newQuantity;
18935
+ if (typeof cantidad === 'string') {
18936
+ newQuantity = parseInt(cantidad, 10);
18937
+ if (newQuantity % step !== 0) {
18938
+ this.toastrService.show('must-be-multiple', { quantity: step });
18939
+ newQuantity = Math.round(newQuantity / step) * step;
18940
+ }
18941
+ }
18942
+ else {
18943
+ newQuantity = cantidad;
18944
+ if (newQuantity % step !== 0) {
18945
+ newQuantity = Math.round(newQuantity / step) * step;
18946
+ }
18947
+ }
18948
+ if (id) {
18949
+ var elem_1 = document.getElementById(id);
18950
+ if (elem_1) {
18951
+ elem_1.disabled = true;
18952
+ }
18953
+ if (newQuantity > 0 && newQuantity <= stock) {
18954
+ this.cartService.updateItemQuantity(item, newQuantity);
18955
+ }
18956
+ else {
18957
+ this.toastrService.show('out-of-stock-actually');
18958
+ }
18959
+ if (elem_1) {
18960
+ setTimeout(function () {
18961
+ elem_1.disabled = false;
18962
+ }, 1000);
18963
+ }
18964
+ }
18965
+ else {
18966
+ if (newQuantity > 0 && newQuantity <= stock) {
18967
+ this.cartService.updateItemQuantity(item, newQuantity);
18968
+ }
18969
+ }
18970
+ };
18891
18971
  SidebarEcComponent.prototype.redirectDetailProduct = function (product) {
18892
18972
  var variant = product.variants[0];
18893
18973
  var path = '/product/';