Developer forum

Forum » Development » Shoppingcart to Order

Shoppingcart to Order


Reply
Hi,

I need to develop a functionality where a logged in user can add and remove products from a shoppingcart during a week. Once a week the contents of the shoppingcart needs to be converted to an order. And this should alsp trigger the realtime sync to Navision.
Does anyone have any ideas about how to accomplish this?

Regards / Aki

Replies

 
Reply
Hi

The functionality of saving a cart on a user is already in DW, so that part you don't need to worry about.

For the part where the cart is converted to an order you need some custom code to be run once a week. You could build this as a notification subscriber that receives a notification on each page load (must be the most frequent notification).

In that subscriber you can use the eCommerce API to convert the cart to an order in these steps:

for each cart that needs to be converted do:
load the cart
call Order.UpdateCartToOrder() - this changes the id from CARTxxx to ORDERyyy and sets the IsCart property to false.
set IsComplete to true
save the order
call the static method Product.UpdateStock(yourOrder, OrderStockOperator.Negative) - this removes the products in the order from the stock.


Hope this helps a bit.

 - Lasse
 
Reply
Hi, 

Thanks for the input, it helps a bit.

Do you if that also triggers the sending of orders to navision if you have the NAV integration module installed.

/Aki
 
Reply
Hi Aki,

If the NAV module is installed, the Order.Completed notification (which triggers automatically) will send the order to Navision.

Regards /Morten

 

You must be logged in to post in the forum