Merchello stock level not adjusting after purchases
Hi,
I don't know if I'm missing something, but I have a Merchello 2.5.0 implementation in which we're selling tickets to events. The 'variant is shippable' checkbox on the products is NOT checked as there is no shipping element to the orders. The 'this variant has digital goods' is also NOT checked as the event tickets aren't downloads, they're handled by administrators. If we set an amount of stock on each product, that number does not change even after one of those products has been purchased via either Braintree or as a cash/invoice payment.
The Braintree orders are marked as Paid and Fulfilled in the Merchello admin area as soon as the purchase is completed, so this is when I'd expect the stock to be reduced. For invoice payments I'd expect stock to be reduced either when the order is placed or when the order is marked as paid via the Merchello admin interface, but neither happens. Nothing seems to effect the stock level.
Can anyone suggest what to do, as this is a pretty big show-stopper at the moment? Perhaps I've missed a setting somewhere?
I actually fixed it myself. Here's my solution on how I fixed it in my situation.
Inside the controller where I am handling my order finalizing I added this code:
// Get all the productkeys from the invoice
List<Guid> listProductKeys = invoice.Items.Where(i => i.LineItemType == LineItemType.Product).Select(p => p.ExtendedData.GetProductKey()).Distinct().ToList();
if (listProductKeys.Any()) {
//go through each productkey
foreach (Guid pk in listProductKeys) {
//sum the ordered quantity for that productkey
int qty = invoice.Items.Where(i => i.LineItemType == LineItemType.Product && i.ExtendedData.GetProductKey() == pk).Sum(p => p.Quantity);
//get the product
var product = _merchelloContext.Services.ProductService.GetByKey(pk);
var inventory = product.CatalogInventories.First();
//get the inventory
if (inventory != null) {
//subtract the ordered quantity
inventory.Count = inventory.Count - qty;
//save the product
_merchelloContext.Services.ProductService.Save(product);
}
}
}
Merchello stock level not adjusting after purchases
Hi,
I don't know if I'm missing something, but I have a Merchello 2.5.0 implementation in which we're selling tickets to events. The 'variant is shippable' checkbox on the products is NOT checked as there is no shipping element to the orders. The 'this variant has digital goods' is also NOT checked as the event tickets aren't downloads, they're handled by administrators. If we set an amount of stock on each product, that number does not change even after one of those products has been purchased via either Braintree or as a cash/invoice payment.
The Braintree orders are marked as Paid and Fulfilled in the Merchello admin area as soon as the purchase is completed, so this is when I'd expect the stock to be reduced. For invoice payments I'd expect stock to be reduced either when the order is placed or when the order is marked as paid via the Merchello admin interface, but neither happens. Nothing seems to effect the stock level.
Can anyone suggest what to do, as this is a pretty big show-stopper at the moment? Perhaps I've missed a setting somewhere?
Thanks
I am experiencing the same issue (also same merchello version). Did you find the solution to this problem?
I actually fixed it myself. Here's my solution on how I fixed it in my situation.
Inside the controller where I am handling my order finalizing I added this code:
I hope anyone can use this
is working on a reply...