Welcome to MSDN Blogs Sign in | Join | Help

Data Tools and Software Testing

Old model-based testers never die; they just transition to a higher state.

Syndication

News

    These postings are provided "AS IS" with no warranties, and confer no rights.
    Use of included script and code samples are subject to the terms specified here.

CS 2007 - Orders Data Management Sample Code

The Orders subsystem in Commerce Server 2007 offers some really powerful new APIs which can make your life easier. Some of the various operations and scenarios enabled by these APIs are:

  • Searching for Baskets and Orders
  • Deleting Baskets (probably you need to build a utility or windows service which will delete you Baskets regularly – such as older than 2 days)
  • Updating PurchaseOrders (even bulk updates are possible!)
  • Deleting PurchaseOrders
  • Create, update, delete new PaymentMethods and ShippingMethods
  • And even more complex scenarios such accepting a cart from a vendor and placing it as an order on your site, via the AcceptBasket API. 

Well, to do all of these and more, you can get started in a very simple manner as follows. I shall assume that you have the StarterSite, CSharpSite or your own custom site unpackaged and running on the development box.

 

The code to create the required management objects would look like (note that I show examples of both in-proc and out-of-proc order management context creation – you should use the one that fits the requirements of your application better):

 

            //This creates the OrderManagementContext in an Out-of-proc mode and all the APIs go over the web service - so this is more flexible and portable

            OrderServiceAgent orderAgent = new OrderServiceAgent(settings.OrdersWebServiceURL);

            OrderManagementContext outOfProcOrderMgtContext = OrderManagementContext.Create(orderAgent);

 

            //This creates the OrderManagementContext in an in-proc mode (Commerce Server has to be installed locally) and is therefore faster

            OrderSiteAgent orderSiteAgent = new OrderSiteAgent("StarterSite");  //Or whatever your site name is

            OrderManagementContext inProcOrderMgtContext = OrderManagementContext.Create(orderSiteAgent);

 

            //Now you can access the particular manager object you are interested in

            //depending on what you want to do and you can use one of the management context objects created above - you would have created either one or the other

            BasketManager basketMgr = outOfProcOrderMgtContext.BasketManager;

            PurchaseOrderManager poMgr = outOfProcOrderMgtContext.PurchaseOrderManager;

            PaymentMethodManager pmtMethodMgr = outOfProcOrderMgtContext.PaymentMethodManager;

            ShippingMethodManager shipMethodMgr = outOfProcOrderMgtContext.ShippingMethodManager;

 

The neat thing about CS 2007 is that almost all the subsystems work in a similar way (not exactly the same way though) – so a similar pattern can help you get started with the Marketing, Profiles or the Catalog subsystems as well. Party on!

Published Thursday, May 25, 2006 8:21 PM by nihitk

Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: CS 2007 - Orders Data Management Sample Code @ Friday, May 26, 2006 8:25 AM

Nihit,

Very, very cool!

Jeff

Jeff Lynch

# Commerce Server 2007: A Few Great Posts! @ Friday, May 26, 2006 9:26 AM

Now that the Commerce Server team has a few spare minutes on their hands (only a few I'd imagine) they've begun to write some great posts about the new release candidate.

Jeff Lynch [MVP]

# re: CS 2007 - Orders Data Management Sample Code @ Friday, October 06, 2006 4:54 PM

Nihit

Do you know of clients that use the CS2007 catalog component as ther master product catalog repository ?

Sabin Ephrem

# re: CS 2007 - Orders Data Management Sample Code @ Sunday, October 08, 2006 1:16 PM

Hi Sabin,

I am not sure I understand what you mean by "master product catalog repository". If you mean whether any customers use the CS 2007 Catalog system as the only system for storing catalog data then the answer is a definite Yes!

Thanks,

Nihit

nihitk

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
Page view tracker