diff --git a/src/Modules/SimplCommerce.Module.ShoppingCart/Areas/ShoppingCart/Controllers/CartController.cs b/src/Modules/SimplCommerce.Module.ShoppingCart/Areas/ShoppingCart/Controllers/CartController.cs index 775d74d503..54e199e0b5 100644 --- a/src/Modules/SimplCommerce.Module.ShoppingCart/Areas/ShoppingCart/Controllers/CartController.cs +++ b/src/Modules/SimplCommerce.Module.ShoppingCart/Areas/ShoppingCart/Controllers/CartController.cs @@ -101,6 +101,10 @@ public async Task List() [HttpPost("cart/update-item-quantity")] public async Task UpdateQuantity([FromBody] CartQuantityUpdate model) { + if(model.Quantity <= 0) + { + return Ok(new { Error = true, Message = _localizer["The quantity must be larger than zero"].Value }); + } var currentUser = await _workContext.GetCurrentUser(); var cart = await _cartService.GetActiveCart(currentUser.Id); diff --git a/src/Modules/SimplCommerce.Module.ShoppingCart/Services/CartService.cs b/src/Modules/SimplCommerce.Module.ShoppingCart/Services/CartService.cs index b40f951381..71cf146b63 100644 --- a/src/Modules/SimplCommerce.Module.ShoppingCart/Services/CartService.cs +++ b/src/Modules/SimplCommerce.Module.ShoppingCart/Services/CartService.cs @@ -59,6 +59,10 @@ public async Task AddToCart(long customerId, long productId, int quantit public async Task AddToCart(long customerId, long createdById, long productId, int quantity) { + if(quantity <= 0) + { + return Result.Fail(_localizer["The quantity must be larger than zero"].Value); + } var cart = await GetActiveCart(customerId, createdById); if (cart == null) {