Hi all,
Sometimes customers leave items in their cart for a few days, and when they return to complete the purchase, the stock may no longer be available or may be limited. I have a requirement to re-check the live stock levels from Business Central (BC) when a customer navigates to the checkout page, and then adjust the cart accordingly. I also need to display a message informing the customer about any changes made.
Here is the flow I’m planning to implement:
-
User navigates to the checkout page
-
Check live stock levels for all order line items
-
If stock is not available, remove the item from the cart
-
If the available stock is less than the requested quantity, reduce the quantity to the available stock level
-
Display a message at the top of the cart describing what was removed and what was adjusted
-
Recalculate totals, discounts, etc., based on the updated cart
I’ve done some research and found that the recommended approach is to use a notification subscriber. I reviewed the documentation below and identified two notifications that seem relevant to this requirement:
https://doc.dynamicweb.com/apix/api/Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.html
Could you please advise which of the following would be the most suitable for this scenario?
-
Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.Loaded
-
Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.BeforeRenderingNewStep
Appreciate your guidance.