Posts Tagged ‘purchase 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;
ProfileContext profileContext = CommerceContext.Current.ProfileSystem;
Profile userProfile = profileContext.GetProfile(“GeneralInfo.email_address”, “ravi@ava.com”, “UserObject”);
string userId = new Guid().ToString();
if (userProfile != null)
{
       userId = userProfile["GeneralInfo.user_id"].Value.ToString();
}
else
{
       Response.Write(“Login Failed”);
}

OrderGroupCollection ogCollection= OrderContext.GetPurchaseOrdersForUser(new Guid(userId));
OrderGroup og = ogCollection[0];
PurchaseOrder po = OrderContext.GetPurchaseOrder(new Guid(userId), og.OrderGroupId);
Response.Write(“Item Total Before removing item:” + po.OrderForms[0].Total.ToString());
po.OrderForms[0].LineItems.Remove(0);
PipelineInfo pipeLineInfo = new PipelineInfo(“basket”);
po.RunPipeline(pipeLineInfo);
pipeLineInfo = new PipelineInfo(“total”);
po.RunPipeline(pipeLineInfo);
po.Save();
Response.Write(“Item Total After removing item:” + po.OrderForms[0].Total.ToString());

 

For example, I created an order with three products and order total is coming to 221$ (as shown in the figure below.)

Purchase Order before removing item.

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.

Purchase Order after removing item.

 

A product of price 9$ is removed from the order and the current total is decreased to 212.40$.

Related Articles


If you like this post, please click on our sponsor advertisement.


Most of the medium and small ecommerce application support generic order process where the user has to add their products to shopping cart, manually checkout the basket, provide shipping, billing addresses and payment details. This is five page refresh process. The process will be applicable to the customer who wants to buy more products at once. Most of the customer will buy single product at a time and only few customers will perform bulk orders. To help single purchase buyers, we can implement Quick order.

Quick Order (or single click ordering) is a very useful and powerful tool and can be built for ecommerce customers and customer service representatives (CSR), who works from back office.  By allowing customer to make their purchase quickly and in reduced steps will encourage them to come back and make another purchase in the future.  CSR can reduce the call time with the customer if s/he can order the product in reduced steps which improves efficiency.  Quick order application via the automated IVR system can provide 24×7 accesses for customer to purchase on phone. Quick order process will work well with the registered user and may/may not work with anonymous user.

Registered User:
View Product -> Click Quick Order button -> Order confirmation (if required) – > Order Display

Non-register user:
View Product -> Click Quick Order button -> Accept Billing & Shipping Address -> Accept Payment  -> Order confirmation (if required) – > Order Display For quick order process, we have to do some customizations in commerce server.

  1. Extend commerce server profile System to capture following details
    1. Default billing address 
    2. Default shipping address.
    3. Default Payment Method.  
    4. Default Credit/Debit card (if payment method is credit card)  
  2. In the registration form, try to accept following details from the customer
    1. Billing address
    2. Shipping address
    3. Payment details

The application can use the information available in the user profile while performing quick checkout. So, when the user clicks on quick check button on product page, the following actions should take place.

  1. Input Values expected from UI – User Id, Catalog Name, and Product Id.
  2. Retrieve commerce server context of catalog, order and profile subsystems.
  3. Create new basket.
  4. Retrieve user profile properties like address Id, credit card Id, etc.
  5. Retrieve product details from Catalog subsystem and populate into basket.
  6. Retrieve address details from profile subsystem and populate into basket.
  7. Retrieve payment details (credit card) from Order subsystem and populate into basket.
  8. Execute pipelines in the following order and then convert basket into Purchase Order.  
    1. Basket  
    2. Total  
    3. Checkout  

Click here to download Quick checkout code

Related Articles


If you like this post, please click on our sponsor advertisement.


Follow me on Google+
Couldn't get data from google+
Sign up for Newsletter