Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Nauman 98 posts 118 karma points
    Oct 12, 2010 @ 12:52
    Nauman
    0

    get order details

    Hi

    I want to get all the details of an order as soon as it is placed. order number, amount, order items etc. I think there is an order pipeline that could be helpful.

    Can you please guide me through .NET example to acheive this and how to integrate with uCommerce?

    Nauman

  • Søren Spelling Lund 1797 posts 2786 karma points
    Oct 12, 2010 @ 21:05
    Søren Spelling Lund
    0

    Hi Nauman,

    Not sure what you need. Do you want the order completed or just to retrieve an order already placed? 

  • Nauman 98 posts 118 karma points
    Oct 13, 2010 @ 07:22
    Nauman
    0

    Hi Soren

    I want get details of an order which is placed right now. Let me explain more, I want to add orders in my some other software using API, so when an order is placed in ucommerce, i want to get details of this particular order and send to my API, so what I want is:

    -- get the details of an order as soon as it is placed

    -- ability to get the details of the order being placed in .NET

    I hope this makes sense.

    Regards

    Nauman

  • Søren Spelling Lund 1797 posts 2786 karma points
    Oct 13, 2010 @ 09:07
    Søren Spelling Lund
    0

    Thanks for clarifying.

    The simplest way to place an order from an external system is to wrap the uCommerce API in a webservice and that. The call would basically have to create a new basket, add some products to it, and finally execute the Basket pipeline and the Checkout Pipeline.

    The code would look something like this. What I do is create a new order, save that, add a product called "MyProduct", and finally execute the basket pipeline to get my totals tallied and the checkout pipeline to get an order number assigned and a couple of other things.

    var catalogGroup = ProductCatalogGroup.SingleOrDefault(g => g.Name.Equals("MyStore");
    var catalog = ProductCatalog.SingleOrDefault(c => c.Name.Equals("MyCatalog"));
    
    var order = new PurchaseOrder();
    order.OrderStatusId = 1;// Order Status == Basket
    order.ProductCatalogGroup = catalogGroup;
    order.CurrencyId = catalog.PriceGroups.First().Currencies.First().CurrencyId;
    order.BasketId = Guid.NewGuid();
    order.CreatedDate = DateTime.Now;
    order.Save();
    
    order.AddProduct(catalog, Product.Single(x => x.Sku = "MyProduct"), 1, 10.00m, true);
    
    var basketPipeline = PipelineFactory.Create<PurchaseOrder>("Basket");
    PipelineExecutionResult result = basketPipeline.Execute(order);
    
    var checkoutPipeline = PipelineFactory.Create<PurchaseOrder>("Checkout");
    PipelineExecutionResult result = checkoutPipeline.Execute(order);
    
    // order now contains a fresh purchase order that you can can use from your own code
    Hope this helps.
  • Nauman 98 posts 118 karma points
    Oct 13, 2010 @ 09:56
    Nauman
    0

    Soren

    Thanks for the help but my question was something way around. I do not want to add another order from external resource.

    I want to get the order details at the time when order is placed within ucommerce and then send these order details to my external software through API.

    If I can get the details of the order from ucommerce, I can take care of rest of the things.

    Your help is highly appreciated.

    Nauman

  • Søren Spelling Lund 1797 posts 2786 karma points
    Oct 13, 2010 @ 10:01
    Søren Spelling Lund
    0

    Sorry about that :)

    You have a couple of options to support this. The easiest option is to grab new orders using a scheduled task. Basically you'll create a service which runs once an hours or more often if that's needed. The service will load all orders created between the last run time and the current one. Orders can be loaded by their CompletedDate which is set during checkout.

    Another option is to hook into the Checkout pipeline and transfer the order as the final step of checkout. The only caveat to this approach is that pipelines are executed synchronously which means that if the system you're sending the order to is slow to respond the customer will notice.

  • Nauman 98 posts 118 karma points
    Oct 13, 2010 @ 10:09
    Nauman
    0

    Soren

    Is there a ucommerce library that I can use in my .NET code that exposes the order placed last? If yes how can I use that?

    Nauman

  • Søren Spelling Lund 1797 posts 2786 karma points
    Oct 13, 2010 @ 10:36
    Søren Spelling Lund
    0

    There is. If you reference the uCommerce.dll assembly you'll have access to the APIs.

  • Nauman 98 posts 118 karma points
    Oct 13, 2010 @ 11:05
    Nauman
    0

    Where to configure the .NET code so that it is called when order is placed.

    Any help how I can access the checkout pipeline and get the order details?

    Nauman

  • Nauman 98 posts 118 karma points
    Oct 13, 2010 @ 14:55
    Nauman
    0

    Soren, any help available please?

  • Søren Spelling Lund 1797 posts 2786 karma points
    Oct 13, 2010 @ 16:59
    Søren Spelling Lund
    0

    Hi Nauman,

    You can read more abut pipelines in the article uCommerce Pipelines Explained. The pipeline you want is called Checkout. You can find the configuration for that in /Umbraco/uCommerce/Pipelines/Checkout.config.

  • Nauman 98 posts 118 karma points
    Oct 14, 2010 @ 10:32
    Nauman
    0

    Soren

    Please just guide me through how can I get list of all the orders? I have written following code

    UCommerce.Entities.PurchaseOrder po = new UCommerce.Entities.PurchaseOrder();
    int orderId = po.OrderId; // this is showing 0
    DateTime orderdate = po.CreatedDate; // this is showing a raw date

    Please suggest how to get all the orders recursively?

    Nauman

  • Søren Spelling Lund 1797 posts 2786 karma points
    Oct 14, 2010 @ 11:14
    Søren Spelling Lund
    0

    You can accomplish that with the following piece of code. The idea here is that each time you load orders from the system you save the date and time in lastExecutedDate. Next time you run the code you only ask for orders placed after lastExecutionDate which will give you new orders only. 

    PurchaseOrder.All().Where(purchaseOrder => purchaseOrder.CompletedDate >= lastExecutedDate);

    If you just want all orders in the system you can loose the .Where() part of the call, but I would advise against it as performance over time will degrade if you see any significant order volume which will cause you to load up more and more orders. 

Please Sign in or register to post replies

Write your reply to:

Draft