More in this section

Forums / Developing with Sitefinity / ShoppingCartId and OrderID Relation

ShoppingCartId and OrderID Relation

2 posts, 0 answered
  1. Amanda Shafer
    Amanda Shafer avatar
    198 posts
    12 Oct 2012
    10 Jul 2014
    Link to this post
    How are ShoppingcartID and OrderID related? Can I get a CartOrder if I have an OrderID?
  2. Sabrie Nedzhip
    Sabrie Nedzhip avatar
    534 posts
    17 Aug 2017
    15 Jul 2014
    Link to this post
    Hi Amanda,

    You can get the CartOrder by the order number. Here is an article from our documentation with samples on how you can query cart orders. In your case, if you have the orderID, you can get the order by orderID using the sample code from the following article from our documentation. Here is a sample code for your reference:

    public static Order GetOrderById(Guid orderId)
        OrdersManager ordersManager = OrdersManager.GetManager();
        Order order = ordersManager.GetOrder(orderId);
        return order;

    When you have the order, you can get its order number and then get the cart order by the order number:

    public static CartOrder GetCartOrderByOrderNumber(int cartOrderNumber)
                OrdersManager ordersManager = OrdersManager.GetManager();
                CartOrder cartOrder = ordersManager.GetCartOrders().SingleOrDefault(co => co.OrderNumber == cartOrderNumber);
                return cartOrder;

    In order to elaborate on this, please note that the CartOrder is the shopping cart to which you add the products you would like to purchase. Once you checkout and place the order, Sitefinity creates an order which is stored in the database. After placing the order, the information about the shopping cart is cleared at some moment. So, it is not guaranteed that you will be able to query the cart order by the order number.

    Sabrie Nedzhip
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
2 posts, 0 answered