Order/Product max quantity fix
This commit is contained in:
parent
a43dc391fb
commit
d82d7a6aee
|
|
@ -232,10 +232,12 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
|||
foreach (var item in orderProducts)
|
||||
{
|
||||
var product = await _productService.GetProductByIdAsync(item.Id);
|
||||
if (product == null)
|
||||
if (product == null || product.StockQuantity - item.Quantity < 0)
|
||||
{
|
||||
_logger.Error($"(product == null); {item}");
|
||||
continue;
|
||||
var errorText = $"product == null || product.StockQuantity - item.Quantity < 0; productId: {product?.Id}; product?.StockQuantity - item.Quantity: {product?.StockQuantity - item.Quantity}";
|
||||
|
||||
_logger.Error($"{errorText}");
|
||||
throw new Exception($"{errorText}");
|
||||
}
|
||||
|
||||
//if (productDtosById.TryGetValue(item.Id, out var productDto))
|
||||
|
|
@ -450,10 +452,11 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
|||
{
|
||||
result.Add(new
|
||||
{
|
||||
label = product.Name,
|
||||
label = $"{product.Name} [KÉSZLET: {product.StockQuantity}]",
|
||||
value = product.Id,
|
||||
sku = product.Sku,
|
||||
price = product.Price
|
||||
price = product.Price,
|
||||
stockQuantity = product.StockQuantity
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -847,6 +847,7 @@
|
|||
name: product.label,
|
||||
sku: product.sku || '',
|
||||
quantity: 1,
|
||||
stockQuantity : product.stockQuantity,
|
||||
price: product.price || 0
|
||||
};
|
||||
|
||||
|
|
@ -876,7 +877,7 @@
|
|||
);
|
||||
|
||||
var quantityCell = $('<td>').html(
|
||||
'<input type="number" class="form-control form-control-sm" min="1" value="' + product.quantity + '" data-index="' + index + '" />'
|
||||
'<input type="number" class="form-control form-control-sm" min="1" max="' + product.stockQuantity + '" value="' + product.quantity + '" data-index="' + index + '" />'
|
||||
);
|
||||
|
||||
var priceCell = $('<td>').html(
|
||||
|
|
|
|||
Loading…
Reference in New Issue