Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

Dev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideLegal TermsGitHubDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Orders

Describes the Orders API handler in Optimizely Configured Commerce.

HTTP Verb – GET

URL – /api/v1/orders/{orderid}

Description –Return a single order record

Base – HandlerBase<GetOrderParameter, GetOrderResult>

Handlers –

OrderHandlerDescription
500GetSettingsPopulate IsRealTime, ReturnReasons and GetOrderLines properties of the result object
600GetRealTimeJobDefinitionGets real time order historydetail integration job and sets its parameters, if IsRealTime equals "true".
700ExecuteRealTimeJobExecutes real time order history detail integration job and save result dataset to RealTimeDataSet property on the result object, if IsRealTime equals "true".
800MapRealTimeDataSetParses OrderHistory and OrderHistoryLine dataset's tables and creates OrderHistory and OrderHistoryLine lists, which are saved as OrderHistory property, if IsRealTime equals "true".
900GetStoredOrderHistoryGets OrderHistory with OrderHistoryLine by OrderNumber and current customer number, save it to OrderHistory property and populate ShipViaDescription if OrderHistory has ShipCode, if IsRealTime equals "false".
1000GetLinesIf GetOrderLines property of the parameter object equals "true", maps OrderHistoryLines to GetOrderLineResults property on the result object and populates CanAddToCart, CanAddAllToCart, ShowTaxAndShipping properties of the result object.
1100GetShipmentsIf GetShipments property of the parameter object equals "true", populates Shipments property of the result object by order history ErpOrderNumber or WebOrderNumber using shipmentService.
1200GetCurrencyPopulate Currency property on the result object by OrderHistory's CurrencyCode.
1300GetStatusMappingPopulate OrderStatusMapping property on the result object by OrderHistory's Status.
1400CopyCustomPropertiesToResultCopy order history custom properties and order history lines custom properties to the result object.

HTTP Verb – GET

URL – /api/v1/orders

Description – Return a collection of orders

Base – HandlerBase<GetOrderCollectionParameter, GetOrderCollectionResult>

Handlers –

OrderHandlerDescription
500GetSettingsPopulate IsRealTime, ShowErpOrderNumber and GetOrderLines property of the result object
600GetRealTimeJobDefinitionGets real time order history integration job and sets its parameters, if IsRealTime equals "true".
700ExecuteRealTimeJobExecutes real time order history integration job and save result dataset into RealTimeDataSet property of the result object, if IsRealTime equals "true".
800MapRealTimeDataSetParses OrderHistory and OrderHistoryLine dataset's tables and creates OrderHistory and OrderHistoryLine lists, which are saved as OrdersQuery property, if IsRealTime equals "true".
900GetStoredCollectionQueryGets all OrderHistories with OrderHistoryLines, which belong to current customer, and save them to OrdersQuery, if IsRealTime equals "false".
1000ApplyFilteringToStoredCollectionQuery

Filters the OrdersQuery, if specified in the parameter and IsRealTime equals "false".

if StatusCollection property has any statuses, returns OrderHistories if StatusCollection contains their statusif OrderNumberproperty has value, returns OrderHistories if their order number equals OrderNumber propertyif OrderNumber property has value, returns OrderHistories if their order number equals OrderNumber propertyif CustomerPO property has value, returns OrderHistories if their CustomerPO equals CustomerPO propertyif CustomerSequence property doesn't equal "-1", returns OrderHistories if their CustomerSequence equals CustomerSequence property or emptyif ToDate property has value, returns OrderHistories if their OrderDate less or equals ToDate propertyif FromDate property has value, returns OrderHistories if their OrderDate more or equals FromDate propertyif OrderTotalOperator property has value, returns OrderHistories if their OrderTotal meets OrderTotalOperator propertyif Search property has value, returns OrderHistories if their properties contain Search property
1100ApplySortApplies a sort to the OrdersQuery. The query is sorted using the Sort property on the parameter object (in ascending order), otherwise the query is sorted by OrderDate (in descending order).
1200ApplyPagingApplies paging to the OrdersQuery. If the PageSize property on the parameter object has a value, the query is paged using the PageSize and Page properties on the parameter object.
1300ExecuteQueryExecutes the OrdersQuery after the query has been filtered, sorted, and paged. The result is stored in the OrderHistoryCollection property on the result object.
1400CreateGetOrderResultsIf OrderHistoryCollection property on the result object has values, they are transformed into a collection of OrderHistoryCollection objects using the GetOrderHandler handler. The result is stored in the GetOrderResults property on the result object.

HTTP Verb – GET

URL – /api/v1/orders/{orderid}?expand=shipments

Description – Gets the shipments for the order.

Base – HandlerBase<GetShipmentCollectionParameter, GetShipmentCollectionResult>

Handlers –

OrderHandlerDescription
500GetShipmentQueryCreates the shipment query that returns list of shipments by WebOrderNumber or ErpOrderNumber. The query is stored in the ShipmentQuery property on the result object.
600ApplySortApplies sorting to the ShipmentQuery property on the result object. If the Sort property on the parameter object has a value, the query will be sorted with that value. If the Sort property is empty, the query will be sorted by the ShipmentNumber property.
700ApplyPagingApplies paging to the ShipmentQuery. If the PageSize property on the parameter object has a value, the query is paged using the PageSize and Page properties on the parameter object.
800ExecuteQueryExecutes the ShipmentQuery after the query has been expanded, filtered, sorted, and paged. The result is stored in the Shipments property on the result object.
900CreateShipmentDtosIf the Shipments property has values on the result object, they are transformed into a collection of getShipmentResult objects using the shipmentService. The result is stored in the ShipmentDtos property on the result object.

HTTP Verb – PATCH

URL – /api/v1/orders/{orderid}

Description – Updates a single order

Base – HandlerBase<UpdateOrderParameter, UpdateOrderResult>

Handlers –

OrderHandlerDescription
500UpdateOrderRetrieves an order using the OrderNumber property on the parameter object. If a order is not found, an error is returned. If parameter object has Status property, updates order status. Retrieves OrderStatusMapping according to the status. The order is stored in the OrderResult property on the result object.

HTTP Verb – POST

URL – /api/v1/orders/{orderid}/returns

Description – Creates and sends an RMA request email

Base – HandlerBase<AddRmaParameter, AddRmaResult>

Handlers –

OrderHandlerDescription
500ValidateContextValidates UserProfileDto or Customer is not null in site context, otherwise return NotFound
600ValidateRmaValidates each RMA line quantity and also reasonCode, if code is required.
700PopulateEmailModelPopulates EmailModel property on the result object by order's and orderLines' information.
800SendEmailSends "Request RMA" email using email service.