ng-easycommerce 0.0.624 → 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.
@@ -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");
@@ -18844,21 +18869,6 @@ var SidebarEcComponent = /** @class */ (function () {
18844
18869
  this.hideTaxes = false;
18845
18870
  this.creditAccountShowPrices = null;
18846
18871
  this.showTaxLegend = false;
18847
- this.actualizarCantidad = function (item, cantidad, stock, id) {
18848
- if (id) {
18849
- var elem_1 = document.getElementById(id);
18850
- elem_1.disabled = true;
18851
- cantidad > 0 && cantidad <= stock
18852
- ? _this.cartService.updateItemQuantity(item, cantidad)
18853
- : _this.toastrService.show('out-of-stock-actually');
18854
- setTimeout(function () {
18855
- elem_1.disabled = false;
18856
- }, 1000);
18857
- }
18858
- else {
18859
- cantidad > 0 && cantidad <= stock && _this.cartService.updateItemQuantity(item, cantidad);
18860
- }
18861
- };
18862
18872
  this.getVariants = function (product) {
18863
18873
  var item = product.product;
18864
18874
  if (item.variants && item.variants.length && item.variants[0].options && item.variants[0].options.length) {
@@ -18917,6 +18927,47 @@ var SidebarEcComponent = /** @class */ (function () {
18917
18927
  _this.creditAccountShowPrices = showPrice;
18918
18928
  });
18919
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
+ };
18920
18971
  SidebarEcComponent.prototype.redirectDetailProduct = function (product) {
18921
18972
  var variant = product.variants[0];
18922
18973
  var path = '/product/';