Posts Tagged ‘post order’
After placing order, there are many cases where the order modification may happen. Commerce server allows us to modify the purchase order but make sure you don’t allow any modifications of purchase after some stage. For example, don’t allow purchase order modification once the ordered products are dispatched. In this article, I am explaining how to remove items from purchase order.
Here is the code snippet used to simulate modifications to an order.
|
OrderContext OrderContext = CommerceContext.Current.OrderSystem; OrderGroupCollection ogCollection= OrderContext.GetPurchaseOrdersForUser(new Guid(userId)); |
For example, I created an order with three products and order total is coming to 221$ (as shown in the figure below.)
In the code, I am taking the order of the user, removing first item from the order, running basket and total pipeline. Note: If you don’t execute pipelines the code will not give any error but the totals will be wrong.
After executing the code the order details are shown below.
A product of price 9$ is removed from the order and the current total is decreased to 212.40$.
If you like this post, please click on our sponsor advertisement.
