Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I cannot figure it out how I can check for products current quantity.
Basically, I would check that once a user click on the update button in the bazaar, check for those products which are trackable and eventaully disallowing users from updating if the quantity is larger the that current stock.
Can anybody lead me pleasE?
Anyone can help me please?
You need to edit UpdateBasket action in BazaarBasketController...
I've done only for product variants and it looks like:
public ActionResult UpdateBasket(BasketTableModel model)
// The only thing that can be updated in this basket is the quantity
foreach (var item in model.Items.Where(item => this.Basket.Items.First(x => x.Key == item.Key).Quantity != item.Quantity))
var currentVariant = MerchelloServices.ProductVariantService.GetByKey(new Guid(item.ExtendedData.GetValue("merchProductVariantKey")));//David M
var catalogInventory = currentVariant.CatalogInventories.First();
if (item.Quantity > catalogInventory.Count)
ModelState.AddModelError("", "Maximum quantity of '" + item.Name + "' is " + catalogInventory.Count);
Also you should add hidden field to post value to action in BasketTable.cshtml:
@Html.HiddenFor(model => Model.Items[i].ExtendedData["merchProductVariantKey"])
Hidden should be in Model.Items loop ofc.
To display an error, add @Html.ValidationSummary(true)
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted