Delen via


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!

Comments

  • Anonymous
    May 26, 2006
    Nihit,

    Very, very cool!

    Jeff
  • Anonymous
    May 26, 2006
    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.

  • Anonymous
    October 06, 2006
    The comment has been removed
  • Anonymous
    October 08, 2006
    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