---
title: Displaying and updating orders on MVC sites
related:
  - https://docs.kentico.com/k11/e-commerce-features/managing-your-store/orders.md
  - https://docs.kentico.com/k11/e-commerce-features/managing-your-store/orders/order-statuses.md
  - https://docs.kentico.com/k11/developing-websites/developing-sites-using-asp-net-mvc/developing-on-line-stores-in-mvc/checkout-process-in-mvc.md
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

After creating an [order](https://docs.kentico.com/k11/e-commerce-features/managing-your-store/orders.md), you may want to:

- Display information about the order's [status](https://docs.kentico.com/k11/e-commerce-features/managing-your-store/orders/order-statuses.md) and details to the [customers](https://docs.kentico.com/k11/e-commerce-features/managing-your-store/customers.md)
- Set the order's properties such as the [order status](https://docs.kentico.com/k11/e-commerce-features/managing-your-store/orders/order-statuses.md) or payment results
- Display a "My orders" section to the customers

You can use the [Kentico.Ecommerceintegration package](https://docs.kentico.com/k11/developing-websites/developing-sites-using-asp-net-mvc/starting-with-mvc-development/installing-kentico-integration-packages.md) and its built-in methods to cover these scenarios.

## Displaying and updating a specific order

You can get any order in the system by its ID. Use the **KenticoOrderRepository** class and its **GetById** method. The method returns an **Order** object that contains the order's properties.

> **Tip:** We recommend using a [dependency injection container](https://docs.kentico.com/k11/developing-websites/developing-sites-using-asp-net-mvc/developing-mvc-applications/initializing-kentico-services-with-dependency-injection.md) to initialize service instances. When configuring the lifetime scope for the _ShoppingService_ and _KenticoOrderRepository_ classes, create a separate instance for each request.

```csharp

        public OrderController()
        {
            shoppingService = new ShoppingService();
            orderRepository = new KenticoOrderRepository();
        }


```

Then, you can load whichever order by its ID and configure the order:

```csharp title="Getting an order"

            // Gets the order based on the order ID
            Order order = orderRepository.GetById(orderID);


```

```csharp title="Setting an order as paid"

            // Sets the order as paid
            order.SetAsPaid();


```

> **Tip:** See the [source code of the integration package](https://github.com/Kentico/Mvc) to get to know all of the available methods and properties.

## Displaying a list of orders

Displaying a list of orders is suitable especially for "My orders" sections in customers' profiles. You can get a complete collection of all customer's orders with the **GetByCustomerId** method in the **KenticoOrderRepository** class.

Initialize the **ShoppingService** and **KenticoOrderRepository** classes.

> **Tip:** We recommend using a [dependency injection container](https://docs.kentico.com/k11/developing-websites/developing-sites-using-asp-net-mvc/developing-mvc-applications/initializing-kentico-services-with-dependency-injection.md) to initialize service instances. When configuring the lifetime scope for the _ShoppingService_ and _KenticoOrderRepository_ classes, create a separate instance for each request.

```csharp

        public OrderController()
        {
            shoppingService = new ShoppingService();
            orderRepository = new KenticoOrderRepository();
        }


```

Then, get the current customer and list all their orders.

```csharp

            // Gets the current customer
            Customer currentCustomer = shoppingService.GetCurrentCustomer();

            // If the customer does not exist, returns error 404
            if (currentCustomer == null)
            {
                return HttpNotFound();
            }

            // Creates a view model representing a collection of the customer's orders
            OrdersViewModel model = new OrdersViewModel()
            {
                Orders = orderRepository.GetByCustomerId(currentCustomer.ID)
            };


```

In the example, the view model then contains a collection (_IEnumerable_) of the customer's orders.

### Reordering an existing order

If you want to enable the customer to reorder the same order, you can load the order's items and add them to the current shopping cart.

```csharp

            // Gets the order based on its ID
            Order order = orderRepository.GetById(orderId);

            // Gets the current visitor's shopping cart
            ShoppingCart cart = shoppingService.GetCurrentShoppingCart();

            // Loops through the items in the order and adds them to the shopping cart
            foreach (OrderItem item in order.OrderItems)
            {
                cart.AddItem(item.SKUID, item.Units);
            }

            // Evaluates the shopping cart
            cart.Evaluate();

            // Saves the shopping cart
            cart.Save();


```
