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.
package/README.md CHANGED
@@ -1,3 +1,6 @@
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.
1
4
  # version 0.0.624
2
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.
3
6
  - En `product-detail.service` se agregó la validación para asegurar que la cantidad ingresada sea múltiplo del valor permitido.
@@ -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");
@@ -18830,21 +18855,6 @@
18830
18855
  this.hideTaxes = false;
18831
18856
  this.creditAccountShowPrices = null;
18832
18857
  this.showTaxLegend = false;
18833
- this.actualizarCantidad = function (item, cantidad, stock, id) {
18834
- if (id) {
18835
- var elem_1 = document.getElementById(id);
18836
- elem_1.disabled = true;
18837
- cantidad > 0 && cantidad <= stock
18838
- ? _this.cartService.updateItemQuantity(item, cantidad)
18839
- : _this.toastrService.show('out-of-stock-actually');
18840
- setTimeout(function () {
18841
- elem_1.disabled = false;
18842
- }, 1000);
18843
- }
18844
- else {
18845
- cantidad > 0 && cantidad <= stock && _this.cartService.updateItemQuantity(item, cantidad);
18846
- }
18847
- };
18848
18858
  this.getVariants = function (product) {
18849
18859
  var item = product.product;
18850
18860
  if (item.variants && item.variants.length && item.variants[0].options && item.variants[0].options.length) {
@@ -18903,6 +18913,47 @@
18903
18913
  _this.creditAccountShowPrices = showPrice;
18904
18914
  });
18905
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
+ };
18906
18957
  SidebarEcComponent.prototype.redirectDetailProduct = function (product) {
18907
18958
  var variant = product.variants[0];
18908
18959
  var path = '/product/';