ShoppingCartId and OrderID Relation

Posted by Community Admin on 04-Aug-2018 16:48

ShoppingCartId and OrderID Relation

All Replies

Posted by Community Admin on 10-Jul-2014 00:00

How are ShoppingcartID and OrderID related? Can I get a CartOrder if I have an OrderID?

Posted by Community Admin on 15-Jul-2014 00:00

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.

Regards,
Sabrie Nedzhip
Telerik
 
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
 

This thread is closed