Table of Contents

Class OrderService

Namespace
Dynamicweb.Ecommerce.Orders
Assembly
Dynamicweb.Ecommerce.dll
The OrderService class providing methods for querying and saving The Order aggregate to and from persistence.
public class OrderService : ICacheStorage<string, Order>, ICacheStorage<string>, ICacheStorage
Inheritance
OrderService
Implements
Inherited Members

Constructors

OrderService()

public OrderService()

Methods

CalculateDiscounts(Order)

Calculates the discounts for this Order. If RecalculateDiscountsNeeded is false or if Calculate is false, discounts will not be calculated.
public void CalculateDiscounts(Order order)

Parameters

order Order
The Order.

CalculateDiscounts(Order, Language)

Calculates the discounts for this Order. If RecalculateDiscountsNeeded is false or if Calculate is false, discounts will not be calculated.
[Obsolete("Use overload with order only instead.")]
public void CalculateDiscounts(Order order, Language language)

Parameters

order Order
The Order.
language Language

CalculateDiscounts(Order, Language, Currency, Country)

[Obsolete("Use overload with order only instead.")]
public void CalculateDiscounts(Order order, Language language, Currency currency, Country country)

Parameters

order Order
language Language
currency Currency
country Country

CalculateShippingFee(Order, string)

Calculates shipping fees for an order given a shipping method id
public ShippingCalculationResult CalculateShippingFee(Order order, string shippingMethodId)

Parameters

order Order
shippingMethodId string

Returns

ShippingCalculationResult

Capture(Order)

Performs capture on the order and stores the resulting OrderCaptureInfo on the order.
public OrderCaptureInfo Capture(Order order)

Parameters

order Order
The Order.

Returns

OrderCaptureInfo
The generated OrderCaptureInfo object, or null if capture is not supported.

Capture(Order, long, bool)

Performs capture on the order and stores the resulting OrderCaptureInfo on the order.
public OrderCaptureInfo Capture(Order order, long amount, bool final)

Parameters

order Order
The Order.
amount long
The amount that is multiplied by 100.
final bool
The capture is final.

Returns

OrderCaptureInfo
The generated OrderCaptureInfo object, or null if capture is not supported.

ClearCache()

Resets all keys to the default value for objects stored in the object cache
public void ClearCache()

ClearCache(IEnumerable<string>)

Resets the specified keys to the default value for objects stored in the object cache
public void ClearCache(IEnumerable<string> keys)

Parameters

keys IEnumerable<string>
Keys to reset

ClearCache(string)

Resets the specified key to the default value for objects stored in the object cache
public void ClearCache(string key)

Parameters

key string
Key to reset

ClearCachedPrices(Order)

Clears the cached prices.
public void ClearCachedPrices(Order order)

Parameters

order Order
The Order.

Complete(Order)

Sets the order complete state to true.
public void Complete(Order order)

Parameters

order Order
The Order.

CreateOrderLine(Order, Product, double, StockUnit, PriceInfo)

Adds a new OrderLine to the OrderLineCollection of the Order based on the given Product.
[Obsolete("Use 'Ecommerce.Services.OrderLines.Create' instead")]
public OrderLine CreateOrderLine(Order order, Product product, double quantity, StockUnit unit, PriceInfo unitPrice)

Parameters

order Order
The Order.
product Product
The Product.
quantity double
The quantity.
unit StockUnit
The stock uint.
unitPrice PriceInfo
The unit price.

Returns

OrderLine
The OrderLine that was added to the Order.

CreateOrderLine(Order, string, double, PriceInfo, OrderLineType, string, string)

Adds a new OrderLine to the OrderLineCollection of the Order with the given OrderLineType and the given text.
[Obsolete("Use 'Ecommerce.Services.OrderLines.Create' instead")]
public OrderLine CreateOrderLine(Order order, string text, double quantity, PriceInfo unitPrice, OrderLineType type, string parentOrderLineId, string discountId)

Parameters

order Order
The Order.
text string
The line text.
quantity double
The quantity.
unitPrice PriceInfo
The unit price.
type OrderLineType
The order line price.
parentOrderLineId string
The parent order line ID.
discountId string
The discount ID.

Returns

OrderLine
The OrderLine that was added to the Order.

Delete(string)

Deletes the order.
public void Delete(string orderId)

Parameters

orderId string
The Order ID.

DowngradeToCart(Order)

Converts the order back to cart.
public void DowngradeToCart(Order order)

Parameters

order Order
The Order.

DowngradeToCart(Order, bool)

Converts the order back to cart.
public void DowngradeToCart(Order order, bool markDeleted)

Parameters

order Order
The Order.
markDeleted bool
Mark initial order as deleted.

FindOrders(string, string, string, string, bool, string)

Finds the orders by parameters.
public IEnumerable<Order> FindOrders(string keyword, string stateId, string startdate, string enddate, bool showCart, string shopId)

Parameters

keyword string
The search keyword.
stateId string
The state ID.
startdate string
The search interval start date. Field used for search is OrderDate.
enddate string
The search interval end date. Field used for search is OrderDate.
showCart bool
The value indicating whether the carts should be included in results or not.
shopId string
The shop ID.

Returns

IEnumerable<Order>
The collection of the Order.

ForcePriceRecalculation(Order)

Forces the recalculation of the Price.
public void ForcePriceRecalculation(Order order)

Parameters

order Order
The Order.

GetAll()

Gets all orders in solution.
public IEnumerable<Order> GetAll()

Returns

IEnumerable<Order>
The collection of the Order.

GetAllOrderVersions(string)

Gets all versions for the order.
[Obsolete("Use 'GetAllVersions' instead")]
public IEnumerable<Order> GetAllOrderVersions(string orderId)

Parameters

orderId string
The Order ID.

Returns

IEnumerable<Order>
The collection of the Order.

GetAllVersions(string)

Gets all versions for the order.
public IEnumerable<Order> GetAllVersions(string orderId)

Parameters

orderId string
The Order ID.

Returns

IEnumerable<Order>
The collection of the Order.

GetByAutoId(int)

Gets the order by auto ID.
public Order GetByAutoId(int orderAutoId)

Parameters

orderAutoId int
The Auto ID.

Returns

Order
The Order, or null, if nothing found.

GetById(string)

Gets the order by ID.
public Order GetById(string orderId)

Parameters

orderId string
The Order ID.

Returns

Order
The Order, or null, if nothing found.

GetBySecret(string)

Gets the order by secret.
public Order GetBySecret(string secret)

Parameters

secret string
The order secret.

Returns

Order
The Order, or null, if nothing found.

GetCartFormName(string)

Gets the name of the cart form.
public string GetCartFormName(string orderId)

Parameters

orderId string
The Cart ID.

Returns

string
"CartForm_[ID]"

GetCompletedOrders(int, string, string)

Gets the compleated orders.
public IEnumerable<Order> GetCompletedOrders(int customerId, string customerNumber, string shopIds)

Parameters

customerId int
The customer ID. Set to 0 to skip this argument.
customerNumber string
The customer number. Set to "" to skip this argument.
shopIds string
The shop IDs. Set to "" to skip this argument.

Returns

IEnumerable<Order>
The collection of the Order.

GetCountry(Order)

Gets the country for order based on order language id.
[Obsolete("Use Order.VatCountry instead.")]
public Country GetCountry(Order order)

Parameters

order Order

Returns

Country

Remarks

If order have not set language id returns default country based on default solution language or any existent country.

GetCustomerOrdersByType(int, string, OrderType, int, bool, string, DateTime)

Gets customer's orders of specified type.
public IEnumerable<Order> GetCustomerOrdersByType(int customerId, string shopIds, OrderType orderType, int recurringOrderId, bool useCustomerNumber, string orderContextIds, DateTime fromDate)

Parameters

customerId int
The User ID.
shopIds string
The Shops IDs.
orderType OrderType
The OrderType.
recurringOrderId int
The ID of the recerring order.
useCustomerNumber bool
If set to true, search by customer number, otherwise search by customer ID.
orderContextIds string
The order context IDs.
fromDate DateTime

Returns

IEnumerable<Order>
The collection of the Order.

GetCustomerOrdersByType(int, string, OrderType, int, bool, string, DateTime, bool)

Gets customer's orders of specified type.
public IEnumerable<Order> GetCustomerOrdersByType(int customerId, string shopIds, OrderType orderType, int recurringOrderId, bool useCustomerNumber, string orderContextIds, DateTime fromDate, bool includeImpersonation)

Parameters

customerId int
The User ID.
shopIds string
The Shops IDs.
orderType OrderType
The OrderType.
recurringOrderId int
The ID of the recerring order.
useCustomerNumber bool
If set to true, search by customer number, otherwise search by customer ID.
orderContextIds string
The order context IDs.
fromDate DateTime
includeImpersonation bool
The orders will be retrieved for user considering users he can impersonate.

Returns

IEnumerable<Order>
The collection of the Order.

Remarks

The parameter "useCustomerNumber" doesn't work when IncludeImpersonation is set to true

GetCustomerOrdersByType(int, string, OrderType, int, bool, string, DateTime, bool, bool)

Gets customer's orders of specified type.
public IEnumerable<Order> GetCustomerOrdersByType(int customerId, string shopIds, OrderType orderType, int recurringOrderId, bool useCustomerNumber, string orderContextIds, DateTime fromDate, bool includeImpersonation, bool isCart)

Parameters

customerId int
The User ID.
shopIds string
The Shops IDs.
orderType OrderType
The OrderType.
recurringOrderId int
The ID of the recerring order.
useCustomerNumber bool
If set to true, search by customer number, otherwise search by customer ID.
orderContextIds string
The order context IDs.
fromDate DateTime
includeImpersonation bool
The orders will be retrieved for user considering users he can impersonate.
isCart bool
If set to true, search orders in cart state.

Returns

IEnumerable<Order>
The collection of the Order.

Remarks

The parameter "useCustomerNumber" doesn't work when IncludeImpersonation is set to true

GetCustomerUnclosedOrders(int)

Gets unclosed orders of customer.
public IEnumerable<Order> GetCustomerUnclosedOrders(int customerId)

Parameters

customerId int
The User ID.

Returns

IEnumerable<Order>
The collection of the Order.

GetFeeCountry(Order)

Gets the VAT country for order based on delivery country code or customer country code.
[Obsolete("Use Order.VatCountry instead.")]
public Country GetFeeCountry(Order order)

Parameters

order Order

Returns

Country

GetLastFailedRecurringOrderId(int)

Gets the last failed recurring order ID.
public string GetLastFailedRecurringOrderId(int recurringOrderId)

Parameters

recurringOrderId int
The recurring order ID.

Returns

string
The Order ID.

GetOrder(int)

Gets the order by auto ID.
[Obsolete("Use 'GetByAutoId' instead")]
public Order GetOrder(int orderAutoId)

Parameters

orderAutoId int
The Auto ID.

Returns

Order
The Order, or null, if nothing found.

GetOrder(string)

Gets the order by ID.
[Obsolete("Use 'GetById' instead")]
public Order GetOrder(string orderId)

Parameters

orderId string
The Order ID.

Returns

Order
The Order, or null, if nothing found.

GetOrderForCurrentUser(string)

Gets the order for current user.
public Order GetOrderForCurrentUser(string orderId)

Parameters

orderId string
The order identifier.

Returns

Order
The Order, or null, if nothing found or user hasn't access to it.

GetOrderForCurrentUser(string, bool)

Gets the order for current user.
public Order GetOrderForCurrentUser(string orderId, bool includeImpersonation)

Parameters

orderId string
The order identifier.
includeImpersonation bool

Returns

Order
The Order, or null, if nothing found or user hasn't access to it.

GetOrders()

Gets all orders in solution.
[Obsolete("Use 'GetAll' instead")]
public IEnumerable<Order> GetOrders()

Returns

IEnumerable<Order>
The collection of the Order.

GetOrdersBySearch(OrderSearchFilter)

Gets orders by search settings
public OrderSearchResult GetOrdersBySearch(OrderSearchFilter filter)

Parameters

filter OrderSearchFilter
Search filter

Returns

OrderSearchResult

GetPreviousOrderIds(int)

Gets the previous recurring orders IDs.
public IEnumerable<string> GetPreviousOrderIds(int recurringOrderId)

Parameters

recurringOrderId int
The recurring order ID.

Returns

IEnumerable<string>
The collection of the order IDs.

GetProductOrderLines(Order)

Gets an OrderLineCollection containing all OrderLine objects where OrderLine.Product is not null.
public OrderLineCollection GetProductOrderLines(Order order)

Parameters

order Order

Returns

OrderLineCollection

Remarks

The function returns order lines of type: Product, Fixed, PointProduct and GiftCard.

GetPropertyType(Order, string)

Gets the property type.
public string GetPropertyType(Order order, string propertyName)

Parameters

order Order
The Order.
propertyName string
The name of the property.

Returns

string
The property type.

GetPropertyValue(Order, string)

Gets the property value.
public object GetPropertyValue(Order order, string propertyName)

Parameters

order Order
The Order.
propertyName string
The name of the property.

Returns

object
The property value.

GetTopOrders(int)

Gets the specified number of the top Orders, ordered by creation date (descending), then by order ID (descending).
public IEnumerable<Order> GetTopOrders(int count)

Parameters

count int
The count of Orders.

Returns

IEnumerable<Order>
The collection of the Order.

GetTotalPurchasesByCustomerId(int, DateTime, Currency)

Gets the total purchase price by customer ID.
public PriceInfo GetTotalPurchasesByCustomerId(int customerId, DateTime fromDate, Currency priceCurrency)

Parameters

customerId int
The User ID.
fromDate DateTime
The search interval start date. Field used for search is OrderDate.
priceCurrency Currency
The Currency.

Returns

PriceInfo
The PriceInfo object.

IsComplete(string)

Gets the value determines whether the order is completed or not.
public bool IsComplete(string orderId)

Parameters

orderId string
The Order ID.

Returns

bool
true, if the Order is completed, otherwise, false.

IsOrderComplete(string)

Gets the value determines whether the order is completed or not.
[Obsolete("Use 'IsComplete' instead")]
public bool IsOrderComplete(string orderId)

Parameters

orderId string
The Order ID.

Returns

bool
true, if the Order is completed, otherwise, false.

MarkOrderAsDeleted(Order)

Marks the Order as deleted and set deleted order state if it exists.
public void MarkOrderAsDeleted(Order order)

Parameters

order Order
The Order.

Remarks

If order has related RecurringOrder the recurring is stopped.

OrderLineBuilder(Order, OrderLineBuilderConfig)

Builds an OrderLine based on the given OrderLineBuilderConfig.
[Obsolete("Use 'Ecommerce.Services.OrderLines.OrderLineBuilder' instead")]
public OrderLine OrderLineBuilder(Order order, OrderLineBuilderConfig builderConfiguration)

Parameters

order Order
builderConfiguration OrderLineBuilderConfig
The builder configuration.

Returns

OrderLine
The OrderLine.

RemoveNoneActiveProducts(Order)

Removes all orderlines that is of type Product and that no longer exist in the database. Also removes products according to the control panel settings: Active, on stock, price is zero.
public void RemoveNoneActiveProducts(Order order)

Parameters

order Order
The Order.

RemoveOrderCache(string)

Removes order and its order lines from cache.
public void RemoveOrderCache(string orderId)

Parameters

orderId string
The Order ID.

Save(Order)

Saves the order.
public void Save(Order order)

Parameters

order Order
The order.

Save(Order, bool)

Saves the order.
public void Save(Order order, bool saveOldVersion)

Parameters

order Order
The order.
saveOldVersion bool
Determines whether the Order should be saved to history.

SaveGatewayResult(Order)

Saves the gateway result.
public void SaveGatewayResult(Order order)

Parameters

order Order
The Order.

SendEmail(Order, ref PageView, string, IEnumerable<string>, string, string, ref Template)

Sends the mail to the specified addresses.
public bool SendEmail(Order order, ref PageView pageView, string subject, IEnumerable<string> toMailAddresses, string fromMailAddress, string fromMailName, ref Template mailTemplate)

Parameters

order Order
The Order.
pageView PageView
The page view.
subject string
The subject.
toMailAddresses IEnumerable<string>
The recipients email addresses.
fromMailAddress string
The sender email address.
fromMailName string
The sender name.
mailTemplate Template
The templpate.

Returns

bool
true if mail was successfully sent, otherwise false.

SendEmail(Order, ref PageView, string, string, string, string, ref Template)

Sends the mail to the specified address.
public bool SendEmail(Order order, ref PageView pageView, string subject, string toMailAddress, string fromMailAddress, string fromMailName, ref Template mailTemplate)

Parameters

order Order
The Order.
pageView PageView
The page view.
subject string
The subject.
toMailAddress string
The recipient email address.
fromMailAddress string
The sender email address.
fromMailName string
The sender name.
mailTemplate Template
The templpate.

Returns

bool
true if mail was successfully sent, otherwise false.

SetDefaultState(Order)

Set default state for the order, cart or quote.
public void SetDefaultState(Order order)

Parameters

order Order
The Order.

SetOrderComplete(Order)

Sets the order complete state to true.
[Obsolete("Use 'Complete' instead")]
public void SetOrderComplete(Order order)

Parameters

order Order
The Order.

SetUserDetailsOnOrder(Order, User, bool)

public void SetUserDetailsOnOrder(Order order, User user, bool doSave)

Parameters

order Order
user User
doSave bool

UpdateCartState(Order, string)

Updates the cart state.
public void UpdateCartState(Order cart, string stateId)

Parameters

cart Order
The cart.
stateId string
The new cart state.

UpdateCartToOrder(Order)

Updates the cart to order.
public void UpdateCartToOrder(Order order)

Parameters

order Order
The Order.

UpdateCartToOrder(Order, bool)

public void UpdateCartToOrder(Order order, bool sendNotifyOrderStateChangedMail)

Parameters

order Order
sendNotifyOrderStateChangedMail bool

UpdateCartToQuote(Order)

Updates the cart to quote.
public void UpdateCartToQuote(Order order)

Parameters

order Order
The Order.

UpdateGatewayResult(Order, bool)

Updates the gateway result.
public void UpdateGatewayResult(Order order, bool setComplete)

Parameters

order Order
The Order.
setComplete bool
If set to true, the Order complete state will be also set to true.

UpdateOrderId(Order, string)

Updates the Order ID.
public void UpdateOrderId(Order order, string newOrderId)

Parameters

order Order
The Order.
newOrderId string
The new Order ID.

UpdateQuoteState(Order, string)

Updates the quote state.
public void UpdateQuoteState(Order order, string stateId)

Parameters

order Order
The quote.
stateId string
The new quote state.

UpdateStepInfo(Order)

Updates the order step information.
public void UpdateStepInfo(Order order)

Parameters

order Order
The Order.

UpdateVat(Order, double)

Updates the order VAT.
public void UpdateVat(Order order, double newVat)

Parameters

order Order
The Order.
newVat double
The new VAT value.

UpdateVat(Order, double, double)

Updates the order VAT.
public void UpdateVat(Order order, double newVat, double newVatPercent)

Parameters

order Order
The Order.
newVat double
The new VAT value.
newVatPercent double
The new VAT percent value.

ValidatePricesInDatabase(Order, ref double, ref double, ref double)

Validates the prices in database.
public bool ValidatePricesInDatabase(Order order, ref double orderPrice, ref double orderlinePrice, ref double priceDifference)

Parameters

order Order
The Order.
orderPrice double
Sets the order price if prices are invalid.
orderlinePrice double
Sets the order lines price if prices are invalid.
priceDifference double
Sets the price difference if prices are invalid.

Returns

bool
true if prices are valid, otherwise false.
To top