Developer forum

Forum » Integration » Inventory Control in Live integration

Inventory Control in Live integration

Thaw Htun Lynn
Reply

Hi,

We are trying to implement inventory control logic in live integration for a project. Whenever we sent the CalculateOrder request, NAV will check the available stock of the product and will send back the products which doesn't have enough inventory by using new xml format. for example: <table name="ErrorInOrder"><product tableName="ErrorInOrder"><column name="ProductID">PROD111</column><column name="AvailableStock">2</column><product></table> 

1. If I get back the error xml,  a.) I need to change the orderline which is having this productID with the available stock and recalculate the cart. And then b.) display message to the user at the front end about the inventory. For the frist step (a), I am able to do it from Live integration source but I am having problem to display the message to the user at the front-end. Kindly help me how I can display error message to the user at the front-end if I got error message in Live Integration code.

2. We are able to control the first step to update the order with the availble stock in most of the step but we are not able to stop the cart to send the order to checkout handler. I try to subscirbe to the notification Dynamicweb.Notifications.eCommerce.Cart.OrderIsPassedToCheckoutHandler but I can't find any code or sample documentation to stop the order to sent to the checkout. Kindly let me know if there is a way i can stop the cart to send the order to checkout procress.

Thanks.

HLT


Replies

 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer

Hi Thaw

@1: Best option would be to make one or more custom fields on the order, and then fill them with information about the changes that was needed. Then display the message in the frontend - you can then remove the message again once displayed in the frontend.

@2: On the OrderIsPassedToCheckoutHandlerArgs argument you get from OrderIsPassedToCheckoutHandler notification, you have 2 properties - one of them is the instance of the checkouthandler that the customer has chosen. You can do 2 things - simple thing would be in the notification to simply redirect the user back to a specific step in the cart using response.redirect. Another option is to create you own version of a CheckoutHandler by inheriting the CheckoutHandler base class and set the CheckoutHandler property of the OrderIsPassedToCheckoutHandlerArgs  to an instance of your own handler. In the StartCheckout method of your own handler you can then do whatever logic you want - i.e. render a template telling what is wrong and that can stop from finalizing the order.

Hope this can give you some pointers.

BR Nicolai

Votes for this answer: 1
 
Thaw Htun Lynn
Reply

Dear Nicolai,

Thank you for your pointers. I will try with response.redirect in the notification.

Best regards,

Thaw

 

You must be logged in to post in the forum