Class OrderViewModelExtensions
- Namespace
- Dynamicweb.Ecommerce.Frontend
- Assembly
- Dynamicweb.Ecommerce.dll
Extensions for OrderViewModel providing helpers to filter and aggregate order lines.
public static class OrderViewModelExtensions
- Inheritance
-
OrderViewModelExtensions
- Inherited Members
Remarks
All methods defensively handle null input and return an empty enumerable or 0 when the source data is unavailable.
Methods
GetBillingAddress(OrderViewModel)
Builds an AddressViewModel representing the customer's billing address based on the OrderViewModel.
public static AddressViewModel? GetBillingAddress(this OrderViewModel order)
Parameters
orderOrderViewModelThe order view model. If null, null is returned.
Returns
- AddressViewModel
A populated AddressViewModel for billing, or null if the
orderis null. The following fields are mapped:- Address, Address2, Zip, City, Country, CountryCode, Company, State, Email, Phone, Name, HouseNumber
The AddressKind is set to Billing, and
Activeis set totrue.
GetDeliveryAddress(OrderViewModel)
Builds an AddressViewModel representing the delivery/shipping address based on the OrderViewModel.
public static AddressViewModel? GetDeliveryAddress(this OrderViewModel order)
Parameters
orderOrderViewModelThe order view model. If null, null is returned.
Returns
- AddressViewModel
A populated AddressViewModel for delivery, or null if the
orderis null. The following fields are mapped:- Address, Address2, Zip, City, Country, CountryCode, Company, State, Email, Phone, Name, HouseNumber
The AddressKind is set to Billing, and
Activeis set totrue.
GetDiscountOrderLines(OrderViewModel)
Returns discount related order lines (Discount, ProductDiscount).
public static IEnumerable<OrderLineViewModel> GetDiscountOrderLines(this OrderViewModel order)
Parameters
orderOrderViewModelThe order view model.
Returns
- IEnumerable<OrderLineViewModel>
Enumerable of discount order lines or empty if unavailable.
GetOrderDiscounts(OrderViewModel)
Represents discounts applied at the order level. Returns order discount lines (Discount) that are not tied to a specific product or order line.
public static IEnumerable<OrderLineViewModel> GetOrderDiscounts(this OrderViewModel order)
Parameters
orderOrderViewModelThe order view model.
Returns
- IEnumerable<OrderLineViewModel>
Enumerable of order level discount lines or empty if unavailable.
GetOrderLineDiscounts(OrderViewModel)
Represents discounts applied to individual order lines/products. Returns discount lines (ProductDiscount) that are tied to a specific product line.
public static IEnumerable<OrderLineViewModel> GetOrderLineDiscounts(this OrderViewModel order)
Parameters
orderOrderViewModelThe order view model.
Returns
- IEnumerable<OrderLineViewModel>
Enumerable of product specific discount lines or empty if unavailable.
GetOrderLinesByTypes(OrderViewModel, IEnumerable<OrderLineType>)
Returns order lines matching any of the provided order line types.
public static IEnumerable<OrderLineViewModel> GetOrderLinesByTypes(this OrderViewModel order, IEnumerable<OrderLineType> orderLineTypes)
Parameters
orderOrderViewModelThe order view model. If null an empty sequence is returned.
orderLineTypesIEnumerable<OrderLineType>Collection of order line types to include. If null or empty an empty sequence is returned.
Returns
- IEnumerable<OrderLineViewModel>
Enumerable of matching order lines, or empty if none / invalid input. Only lines with a non-null OrderLineType are evaluated.
GetProductOrderLines(OrderViewModel)
Returns product related order lines (Product, Fixed, GiftCard, PointProduct).
public static IEnumerable<OrderLineViewModel> GetProductOrderLines(this OrderViewModel order)
Parameters
orderOrderViewModelThe order view model.
Returns
- IEnumerable<OrderLineViewModel>
Enumerable of product order lines or empty if unavailable.
IsActiveCart(OrderViewModel)
Determines whether the specified order represents the currently active cart.
public static bool IsActiveCart(this OrderViewModel order)
Parameters
orderOrderViewModelThe order view model.
Returns
SumProductQuantities(OrderViewModel)
Calculates the total quantity of all order lines with type Product, Fixed, PointProduct or GiftCard.
public static double SumProductQuantities(this OrderViewModel order)
Parameters
orderOrderViewModelThe order view model.
Returns
- double
Total quantity across qualifying product lines, or 0 if input/order lines are null.
TryGetLedgerPaymentInfo(OrderViewModel, out LedgerPaymentInfoViewModel?)
Exposes the LedgerPaymentInfo of the OrderViewModel
public static bool TryGetLedgerPaymentInfo(this OrderViewModel order, out LedgerPaymentInfoViewModel? ledgerPaymentInfoViewModel)
Parameters
orderOrderViewModelThe order view model
ledgerPaymentInfoViewModelLedgerPaymentInfoViewModelThe Ledger payment info view model
Returns
TryGetOrderState(OrderViewModel, out OrderStateViewModel?)
Gets the order state information for the specified order.
public static bool TryGetOrderState(this OrderViewModel order, out OrderStateViewModel? state)
Parameters
orderOrderViewModelThe order view model.
stateOrderStateViewModelThe state view model.
Returns
- bool
Order state view model or null if order or state ID is null.