Hi Dynamicweb,
I am missing out a feature telling me if a product cannot be added to the cart due to low stock levels.
Right now the function just returns nothing and do not tell the reason for not adding the product to the cart.
' Check stock and reserve
If ProductReserve.Enabled AndAlso ProductToPutInCart.Type <> ProductType.Service AndAlso ol.HasType({OrderLine.OrderLineType.Product, OrderLine.OrderLineType.PointProduct}) Then
Dim cartStock As Double = ProductReserve.GetReservedAmount(ol.ProductID, ol.ProductVariantID) + QuantityOrderLine
If ProductReserve.GetReserveMode = ProductReserve.ReserveMode.modeCheckout Then
' When products is reserved only in checkout step we should take into account is there such product exist in cart
cartStock += EcomCart.OrderLines.Where(Function(cartLine) cartLine.ProductID = ProductID AndAlso cartLine.ProductVariantID = VariantID).Select(Function(cartLine) cartLine.Quantity).FirstOrDefault()
End If
If ProductToPutInCart.UnitStock < cartStock Then
Return Nothing
End If
End If
I hope to see this implemented in the standard solution soon, or at least adding a notification for being able to overrule and add information to the template.
The information to the template should include the current stock level so this can be shown to the customer.
Best regards,
Anders