Table of Contents

Class OrderExtensions

Namespace
Dynamicweb.Ecommerce.Frontend
Assembly
Dynamicweb.Ecommerce.dll

Provides extension methods for the Order class.

public static class OrderExtensions
Inheritance
OrderExtensions
Inherited Members

Methods

ToCartViewModel(Order)

Converts an Order to a CartViewModel.

public static CartViewModel ToCartViewModel(this Order order)

Parameters

order Order

The order to convert.

Returns

CartViewModel

A CartViewModel representing the cart or null if order is null.

Examples

CartViewModel? cartViewModel = Common.Context.Cart.ToCartViewModel();

Remarks

The CartViewModel is usually used for mini carts and information on cart content. The OrderViewModel returned by ToOrderViewModel(Order) is more comprehensive model with more information

ToOrderViewModel(Order)

Converts an Order to an OrderViewModel.

public static OrderViewModel ToOrderViewModel(this Order order)

Parameters

order Order

The order to convert.

Returns

OrderViewModel

An OrderViewModel representing the order or null if order is null.

Examples

OrderViewModel? orderViewModel = Common.Context.Cart.ToOrderViewModel();

TryGetCartViewModel(Order, out CartViewModel?)

Tries to get the CartViewModel from the specified Order.

public static bool TryGetCartViewModel(this Order order, out CartViewModel? cartViewModel)

Parameters

order Order

The order from which to retrieve the view model.

cartViewModel CartViewModel

The resulting CartViewModel if successful; otherwise, null.

Returns

bool

true if the view model was successfully retrieved; otherwise, false.

TryGetOrderViewModel(Order, out OrderViewModel?)

Tries to get the OrderViewModel from the specified Order.

public static bool TryGetOrderViewModel(this Order order, out OrderViewModel? orderViewModel)

Parameters

order Order

The order from which to retrieve the view model.

orderViewModel OrderViewModel

The resulting OrderViewModel if successful; otherwise, null.

Returns

bool

true if the view model was successfully retrieved; otherwise, false.

To top