ng-easycommerce 0.0.679 → 0.0.680
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 +3 -0
- package/bundles/ng-easycommerce.umd.js +162 -27
- 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/cart-ec/cart-ec.component.js +26 -1
- package/esm2015/lib/ec-component/multiple-items-to-cart-ec/multiple-items-to-cart-ec.component.js +75 -2
- package/esm2015/lib/ec-component/product-detail-ec/product-detail-ec.component.js +65 -28
- package/esm5/lib/ec-component/cart-ec/cart-ec.component.js +26 -1
- package/esm5/lib/ec-component/multiple-items-to-cart-ec/multiple-items-to-cart-ec.component.js +75 -2
- package/esm5/lib/ec-component/product-detail-ec/product-detail-ec.component.js +64 -27
- package/fesm2015/ng-easycommerce.js +163 -28
- package/fesm2015/ng-easycommerce.js.map +1 -1
- package/fesm5/ng-easycommerce.js +162 -27
- package/fesm5/ng-easycommerce.js.map +1 -1
- package/lib/ec-component/cart-ec/cart-ec.component.d.ts +2 -0
- package/lib/ec-component/multiple-items-to-cart-ec/multiple-items-to-cart-ec.component.d.ts +8 -0
- package/lib/ec-component/product-detail-ec/product-detail-ec.component.d.ts +15 -4
- package/ng-easycommerce.metadata.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
# Version 0.0.680
|
|
2
|
+
- Se agrega funciones para que la botonera de añadir al carrito funcione con la cantidad minima de compra del articulo predefinida.
|
|
3
|
+
- Tambien al usar el + o el - se subiran las cantidades teniendo en cuenta que sea multiplo de lo configurado en backoffice para el articulo.
|
|
1
4
|
# version 0.0.679
|
|
2
5
|
- fix(collection): ensure loading state is reset correctly
|
|
3
6
|
# version 0.0.678
|
|
@@ -7844,6 +7844,31 @@
|
|
|
7844
7844
|
_this.cartLoading = false;
|
|
7845
7845
|
_this.enableFieldNotesInArticleFile = false;
|
|
7846
7846
|
_this.toDecimal = function (amount) { return _this.consts.toDecimal(amount); };
|
|
7847
|
+
_this.cartItemPlus = function (item) {
|
|
7848
|
+
var _a, _b;
|
|
7849
|
+
var multipleQty = ((_a = item.product.variants[0]) === null || _a === void 0 ? void 0 : _a.multipleQuantity) || 0;
|
|
7850
|
+
var step = multipleQty || 1;
|
|
7851
|
+
var stock = (_b = item.product.variants[0]) === null || _b === void 0 ? void 0 : _b.stock;
|
|
7852
|
+
var current = item.quantity;
|
|
7853
|
+
var next = step > 1 && current % step !== 0
|
|
7854
|
+
? Math.ceil(current / step) * step
|
|
7855
|
+
: current + step;
|
|
7856
|
+
_this.actualizarCantidad(item, next, stock, 'cartPlus');
|
|
7857
|
+
};
|
|
7858
|
+
_this.cartItemLess = function (item) {
|
|
7859
|
+
var _a, _b, _c;
|
|
7860
|
+
var multipleQty = ((_a = item.product.variants[0]) === null || _a === void 0 ? void 0 : _a.multipleQuantity) || 0;
|
|
7861
|
+
var minimumQty = ((_b = item.product.variants[0]) === null || _b === void 0 ? void 0 : _b.minimumItemsQuantity) || 0;
|
|
7862
|
+
var step = multipleQty || 1;
|
|
7863
|
+
var floor = minimumQty || step;
|
|
7864
|
+
var current = item.quantity;
|
|
7865
|
+
var next = step > 1 && current % step !== 0
|
|
7866
|
+
? Math.floor(current / step) * step
|
|
7867
|
+
: current - step;
|
|
7868
|
+
if (next >= floor) {
|
|
7869
|
+
_this.actualizarCantidad(item, next, (_c = item.product.variants[0]) === null || _c === void 0 ? void 0 : _c.stock, 'cartLess');
|
|
7870
|
+
}
|
|
7871
|
+
};
|
|
7847
7872
|
_this.redirectRegister = function () { return _this.router.navigateByUrl("/auth/login"); };
|
|
7848
7873
|
_this.getVariants = function (product) {
|
|
7849
7874
|
var item = product.product;
|
|
@@ -13941,6 +13966,9 @@
|
|
|
13941
13966
|
_this.hidePrices = false;
|
|
13942
13967
|
_this.creditAccountShowPrices = null;
|
|
13943
13968
|
_this.enableFieldNotesInArticleFile = false;
|
|
13969
|
+
_this.quantityError = '';
|
|
13970
|
+
_this.minimumItemsQty = null;
|
|
13971
|
+
_this.multipleQty = null;
|
|
13944
13972
|
_this.addToCart = function () {
|
|
13945
13973
|
var _a;
|
|
13946
13974
|
var note = ((_a = _this.comments) === null || _a === void 0 ? void 0 : _a.trim()) || null;
|
|
@@ -13956,22 +13984,25 @@
|
|
|
13956
13984
|
};
|
|
13957
13985
|
/**
|
|
13958
13986
|
* @description actualiza la variable quantity sumandole 'x' contenido.
|
|
13987
|
+
* Si hay un multipleQuantity configurado, hace snap al siguiente múltiplo válido
|
|
13988
|
+
* cuando la cantidad actual ya es inválida.
|
|
13959
13989
|
* @param stock número máximo disponible en stock.
|
|
13960
|
-
* @param changeAmount cantidad que se quiere sumar.
|
|
13961
|
-
* @param forceMultiple si es true, obliga a que el resultado sea múltiplo de changeAmount.
|
|
13990
|
+
* @param changeAmount cantidad que se quiere sumar (ignorado si multipleQty está seteado).
|
|
13991
|
+
* @param forceMultiple legacy — si es true, obliga a que el resultado sea múltiplo de changeAmount.
|
|
13962
13992
|
*/
|
|
13963
13993
|
_this.plus = function (stock, changeAmount, forceMultiple) {
|
|
13964
13994
|
if (changeAmount === void 0) { changeAmount = 1; }
|
|
13965
13995
|
if (forceMultiple === void 0) { forceMultiple = false; }
|
|
13996
|
+
var step = _this.multipleQty || changeAmount;
|
|
13966
13997
|
var currentQuantity = Number(_this.quantity);
|
|
13967
|
-
var newQuantity
|
|
13968
|
-
if (
|
|
13969
|
-
|
|
13970
|
-
|
|
13971
|
-
|
|
13972
|
-
|
|
13973
|
-
|
|
13974
|
-
|
|
13998
|
+
var newQuantity;
|
|
13999
|
+
if (step > 1) {
|
|
14000
|
+
newQuantity = currentQuantity % step !== 0
|
|
14001
|
+
? Math.ceil(currentQuantity / step) * step
|
|
14002
|
+
: currentQuantity + step;
|
|
14003
|
+
}
|
|
14004
|
+
else {
|
|
14005
|
+
newQuantity = currentQuantity + step;
|
|
13975
14006
|
}
|
|
13976
14007
|
if (!stock || newQuantity <= stock) {
|
|
13977
14008
|
_this.quantity = newQuantity;
|
|
@@ -13979,35 +14010,59 @@
|
|
|
13979
14010
|
else {
|
|
13980
14011
|
_this.toastrService.show('out-of-stock-actually');
|
|
13981
14012
|
}
|
|
14013
|
+
_this.validateDetail();
|
|
13982
14014
|
};
|
|
13983
14015
|
/**
|
|
13984
14016
|
* @description actualiza la variable quantity restandole 'x' contenido.
|
|
13985
|
-
*
|
|
13986
|
-
*
|
|
14017
|
+
* Si hay un multipleQuantity configurado, hace snap al múltiplo válido inferior
|
|
14018
|
+
* cuando la cantidad actual ya es inválida.
|
|
14019
|
+
* @param changeAmount cantidad que se quiere restar (ignorado si multipleQty está seteado).
|
|
14020
|
+
* @param minimum cantidad mínima permitida (ignorado si minimumItemsQty está seteado).
|
|
14021
|
+
* @param forceMultiple legacy — si es true, obliga a que el resultado sea múltiplo de changeAmount.
|
|
13987
14022
|
*/
|
|
13988
14023
|
_this.less = function (changeAmount, minimum, forceMultiple) {
|
|
13989
14024
|
if (changeAmount === void 0) { changeAmount = 1; }
|
|
13990
14025
|
if (minimum === void 0) { minimum = 1; }
|
|
13991
14026
|
if (forceMultiple === void 0) { forceMultiple = false; }
|
|
13992
|
-
var
|
|
13993
|
-
|
|
13994
|
-
|
|
13995
|
-
|
|
13996
|
-
|
|
13997
|
-
|
|
13998
|
-
|
|
13999
|
-
}
|
|
14000
|
-
if (newQuantity < changeAmount) {
|
|
14001
|
-
newQuantity = changeAmount;
|
|
14002
|
-
}
|
|
14027
|
+
var step = _this.multipleQty || changeAmount;
|
|
14028
|
+
var floor = _this.minimumItemsQty || (step > 1 ? step : minimum);
|
|
14029
|
+
var newQuantity;
|
|
14030
|
+
if (step > 1) {
|
|
14031
|
+
newQuantity = _this.quantity % step !== 0
|
|
14032
|
+
? Math.floor(_this.quantity / step) * step
|
|
14033
|
+
: _this.quantity - step;
|
|
14003
14034
|
}
|
|
14004
|
-
|
|
14005
|
-
_this.quantity
|
|
14035
|
+
else {
|
|
14036
|
+
newQuantity = _this.quantity - step;
|
|
14037
|
+
}
|
|
14038
|
+
_this.quantity = newQuantity >= floor ? newQuantity : floor;
|
|
14039
|
+
_this.validateDetail();
|
|
14040
|
+
};
|
|
14041
|
+
_this.onQuantityInput = function (value) {
|
|
14042
|
+
var parsed = parseInt(value, 10);
|
|
14043
|
+
if (!isNaN(parsed)) {
|
|
14044
|
+
_this.quantity = parsed;
|
|
14045
|
+
_this.validateDetail();
|
|
14046
|
+
}
|
|
14047
|
+
};
|
|
14048
|
+
_this.validateDetail = function () {
|
|
14049
|
+
if (_this.minimumItemsQty && _this.quantity < _this.minimumItemsQty) {
|
|
14050
|
+
_this.quantityError = 'La cantidad debe ser al menos ' + _this.minimumItemsQty;
|
|
14051
|
+
}
|
|
14052
|
+
else if (_this.multipleQty && _this.quantity % _this.multipleQty !== 0) {
|
|
14053
|
+
_this.quantityError = 'La cantidad debe ser m\u00faltiplo de ' + _this.multipleQty;
|
|
14006
14054
|
}
|
|
14007
14055
|
else {
|
|
14008
|
-
_this.
|
|
14056
|
+
_this.quantityError = '';
|
|
14009
14057
|
}
|
|
14010
14058
|
};
|
|
14059
|
+
_this.isQuantityValidDetail = function () {
|
|
14060
|
+
if (_this.minimumItemsQty && _this.quantity < _this.minimumItemsQty)
|
|
14061
|
+
return false;
|
|
14062
|
+
if (_this.multipleQty && _this.quantity % _this.multipleQty !== 0)
|
|
14063
|
+
return false;
|
|
14064
|
+
return true;
|
|
14065
|
+
};
|
|
14011
14066
|
_this.showContact = function () { return _this.show = true; };
|
|
14012
14067
|
_this.hideContact = function () { return _this.show = false; };
|
|
14013
14068
|
_this.thereIsMoreInfo = function (product) {
|
|
@@ -14089,6 +14144,13 @@
|
|
|
14089
14144
|
});
|
|
14090
14145
|
_this.comments = (_o = (_m = match) === null || _m === void 0 ? void 0 : _m.comments, (_o !== null && _o !== void 0 ? _o : ''));
|
|
14091
14146
|
});
|
|
14147
|
+
this.productService.asociatedData$.subscribe(function (ad) {
|
|
14148
|
+
var _a, _b;
|
|
14149
|
+
_this.minimumItemsQty = ((_a = ad) === null || _a === void 0 ? void 0 : _a.minimumItemsQuantity) || null;
|
|
14150
|
+
_this.multipleQty = ((_b = ad) === null || _b === void 0 ? void 0 : _b.multipleQuantity) || null;
|
|
14151
|
+
_this.quantity = _this.minimumItemsQty || _this.multipleQty || 1;
|
|
14152
|
+
_this.quantityError = '';
|
|
14153
|
+
});
|
|
14092
14154
|
};
|
|
14093
14155
|
ProductDetailEcComponent.prototype.ngOnDestroy = function () {
|
|
14094
14156
|
var _a;
|
|
@@ -19309,7 +19371,77 @@
|
|
|
19309
19371
|
_this.totalItems = new core.EventEmitter();
|
|
19310
19372
|
_this.total = 0;
|
|
19311
19373
|
_this.countItems = 0;
|
|
19374
|
+
_this.quantity = 1;
|
|
19375
|
+
_this.spanInfo = '';
|
|
19312
19376
|
_this.optionsProductForVariant = function () { return _this.product.productWithUniqueVariant; };
|
|
19377
|
+
_this.plus = function (product, stock, multipleQuantity) {
|
|
19378
|
+
if (multipleQuantity && multipleQuantity > 0) {
|
|
19379
|
+
var next = _this.quantity % multipleQuantity !== 0
|
|
19380
|
+
? Math.ceil(_this.quantity / multipleQuantity) * multipleQuantity
|
|
19381
|
+
: _this.quantity + multipleQuantity;
|
|
19382
|
+
stock ? (next <= stock ? _this.quantity = next : _this.toastService.show('out-of-stock-actually'))
|
|
19383
|
+
: _this.quantity = next;
|
|
19384
|
+
_this.setQuantity(_this.quantity, product);
|
|
19385
|
+
_this.validateQuantity(_this.quantity, product);
|
|
19386
|
+
}
|
|
19387
|
+
else {
|
|
19388
|
+
stock ? (_this.quantity < stock ? _this.quantity = _this.quantity + 1 : _this.toastService.show('out-of-stock-actually'))
|
|
19389
|
+
: _this.quantity = _this.quantity + 1;
|
|
19390
|
+
_this.setQuantity(_this.quantity, product);
|
|
19391
|
+
}
|
|
19392
|
+
};
|
|
19393
|
+
_this.less = function (product, multipleQuantity, minimumItemsQuantity) {
|
|
19394
|
+
if (multipleQuantity && multipleQuantity >= 0) {
|
|
19395
|
+
var minimum = minimumItemsQuantity || multipleQuantity;
|
|
19396
|
+
var next = _this.quantity % multipleQuantity !== 0
|
|
19397
|
+
? Math.floor(_this.quantity / multipleQuantity) * multipleQuantity
|
|
19398
|
+
: _this.quantity - multipleQuantity;
|
|
19399
|
+
if (next >= minimum) {
|
|
19400
|
+
_this.quantity = next;
|
|
19401
|
+
}
|
|
19402
|
+
_this.setQuantity(_this.quantity, product);
|
|
19403
|
+
_this.validateQuantity(_this.quantity, product);
|
|
19404
|
+
}
|
|
19405
|
+
else {
|
|
19406
|
+
_this.quantity > 0 ? _this.quantity = _this.quantity - 1 : null;
|
|
19407
|
+
_this.setQuantity(_this.quantity, product);
|
|
19408
|
+
}
|
|
19409
|
+
};
|
|
19410
|
+
_this.isQuantityValid = function (quantity, item) {
|
|
19411
|
+
var _a, _b, _c, _d, _e, _f;
|
|
19412
|
+
var minimumItemsQuantity = (_c = (_b = (_a = item) === null || _a === void 0 ? void 0 : _a.variants) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.minimumItemsQuantity;
|
|
19413
|
+
var multipleQuantity = (_f = (_e = (_d = item) === null || _d === void 0 ? void 0 : _d.variants) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.multipleQuantity;
|
|
19414
|
+
if (minimumItemsQuantity && quantity < minimumItemsQuantity)
|
|
19415
|
+
return false;
|
|
19416
|
+
if (multipleQuantity && quantity % multipleQuantity !== 0)
|
|
19417
|
+
return false;
|
|
19418
|
+
return true;
|
|
19419
|
+
};
|
|
19420
|
+
_this.validateQuantity = function (quantity, item) {
|
|
19421
|
+
var _a, _b, _c, _d, _e, _f;
|
|
19422
|
+
var minimumItemsQuantity = (_c = (_b = (_a = item) === null || _a === void 0 ? void 0 : _a.variants) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.minimumItemsQuantity;
|
|
19423
|
+
var multipleQuantity = (_f = (_e = (_d = item) === null || _d === void 0 ? void 0 : _d.variants) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.multipleQuantity;
|
|
19424
|
+
_this.spanInfo = '';
|
|
19425
|
+
if (minimumItemsQuantity && quantity < minimumItemsQuantity) {
|
|
19426
|
+
_this.spanInfo = 'La cantidad debe ser al menos ' + minimumItemsQuantity;
|
|
19427
|
+
}
|
|
19428
|
+
else if (multipleQuantity && quantity % multipleQuantity !== 0) {
|
|
19429
|
+
_this.spanInfo = 'La cantidad debe ser m\u00faltiplo de ' + multipleQuantity;
|
|
19430
|
+
}
|
|
19431
|
+
};
|
|
19432
|
+
_this.buildButtons = function (asociatedData) {
|
|
19433
|
+
var maximumNumberOfButtons = 6;
|
|
19434
|
+
if (asociatedData.multipleQuantity) {
|
|
19435
|
+
var maximum = asociatedData.maximumItemsQuantity || asociatedData.stock;
|
|
19436
|
+
var minimum = asociatedData.minimumItemsQuantity || asociatedData.multipleQuantity;
|
|
19437
|
+
var buttons = [];
|
|
19438
|
+
for (var i = minimum; i <= maximum; i = i + asociatedData.multipleQuantity) {
|
|
19439
|
+
buttons.push(i);
|
|
19440
|
+
}
|
|
19441
|
+
return buttons.length > maximumNumberOfButtons ? buttons.slice(0, maximumNumberOfButtons) : buttons;
|
|
19442
|
+
}
|
|
19443
|
+
return undefined;
|
|
19444
|
+
};
|
|
19313
19445
|
_this.setQuantity = function (value, product) {
|
|
19314
19446
|
var quantity = Number(value) > product.currentOption.stock ? product.currentOption.stock : Number(value);
|
|
19315
19447
|
product.productToCartItem = {
|
|
@@ -19345,8 +19477,11 @@
|
|
|
19345
19477
|
return _this;
|
|
19346
19478
|
}
|
|
19347
19479
|
MultipleItemsToCartEcComponent.prototype.ngOnInit = function () {
|
|
19348
|
-
var _a;
|
|
19480
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
19349
19481
|
this.product.productWithUniqueVariant = (_a = this.productService) === null || _a === void 0 ? void 0 : _a.getProductWithUniqueVariant(this.product, this.getObjectParamsWithVariant());
|
|
19482
|
+
var minQty = (_d = (_c = (_b = this.product) === null || _b === void 0 ? void 0 : _b.variants) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.minimumItemsQuantity;
|
|
19483
|
+
var multipleQty = (_g = (_f = (_e = this.product) === null || _e === void 0 ? void 0 : _e.variants) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.multipleQuantity;
|
|
19484
|
+
this.quantity = minQty || multipleQty || 1;
|
|
19350
19485
|
this.ecOnInit();
|
|
19351
19486
|
};
|
|
19352
19487
|
MultipleItemsToCartEcComponent.ctorParameters = function () { return [
|