Order service methods
Service providers are wrapper objects designed to make it easier to interact with Connect pipelines. The providers implement no logic other than calling Connect pipelines. All of the business logic is implemented in the pipeline processors.
The Order service provider contains the following methods for interacting with order data.
SubmitVisitorOrder method
|
Name: |
SubmitVisitorOrder |
|
Description: |
Creates an order based on the shopping cart. Calls the |
|
Usage: |
Called from Sitecore when a visitor is submitting the shopping cart to create an order. |
|
Signature: |
RequestResponse |
|
Input: | |
|
Cart – Cart. An instance of the shopping cart. | |
|
Output: | |
|
Order – Cart. When successful, an order is returned and because the order is inherited from the Cart this works fine but it must be cast as an order. In case of failure, an instance of the cart object is returned, potentially modified and augmented with more data and error comments. | |
|
SystemMessages - Collection of messages from the external system. |
Usage example:
var cartService = new CartServiceProvider();
// get the cart
var cart = cartService.CreateOrResumeCart(new CreateOrResumeCartRequest("MyShop", "Me")).Cart;
// add parties, payment and shipping info
cart.Parties = new List<Party>
{
new Party() { ExternalId = "1", PartyId = "{F73904C0-2A45-4A2F-A99B-F934ABDCFC99}", FirstName = "Joe", LastName = "Smith", Address1 = "123 Street", City = "Ottawa", State = "Ontario", Country = "Canada" },
new Party() { ExternalId = "2", PartyId = "{294B7DD1-7397-4322-996C-E87E592EF621}", FirstName = "Jane", LastName = "Smith", Address1 = "234 Street", City = "Toronto", State = "Ontario", Country = "Canada" }
};
cart.BuyerCustomerParty = new CartParty() { ExternalId = "1", PartyID = "{F73904C0-2A45-4A2F-A99B-F934ABDCFC99}" };
cart.AccountingCustomerParty = new CartParty() { ExternalId = "2", PartyID = "{294B7DD1-7397-4322-996C-E87E592EF621}" };
cart.Payment = new List<PaymentInfo>
{
new PaymentInfo() { ExternalId = "1" },
new PaymentInfo() { ExternalId = "2" },
};
cart.Shipping = new List<ShippingInfo>
{
new ShippingInfo() { ExternalId = "1" },
new ShippingInfo() { ExternalId = "2" },
};
cartService.SaveCart(new SaveCartRequest(cart));
var orderService = new OrderServiceProvider();
var request = new SubmitVisitorOrderRequest(cart);
var result = orderService.SubmitVisitorOrder(request);
var order = result.Order;
var orderId = order.OrderID;GetAvailableCountries method
This method returns the list of countries supported by the ECS.
|
Name: |
GetAvailableCountries |
|
Description: |
Provides a list of all countries supported by the ECS. |
|
Usage: |
Called from Sitecore |
|
Signature: |
RequestResponse |
|
Input: | |
|
Output: | |
|
SystemMessages - Collection of countries from the external system. |
Usage example:
var orderService = new OrderServiceProvider();
var request = new GetAvailableCountriesRequest();
var result = orderService.GetAvailableCountries(request);GetAvailableRegions method
Returns the list of regions in a country supported by the ECS.
|
Name: |
GetAvailableRegions |
|
Description: |
Provides a list of all the regions in a country supported by the ECS. |
|
Usage: |
Called from Sitecore |
|
Signature: |
RequestResponse |
|
Input: | |
|
CountryCode – The country to return regions for. | |
|
Output: | |
|
SystemMessages - Collection of countries from the external system. |
Usage example:
var orderService = new OrderServiceProvider();
var request = new GetAvailableRegionsRequest(“Canada”);
var result = orderService.GetAvailableRegions(request);GetVisitorOrder method
|
Name: |
GetVisitorOrder |
|
Description: |
Gets the order by the ID placed by the visitor. Calls the |
|
Usage: |
Called from Sitecore when the order details are needed for a specific order. |
|
Signature: |
RequestResponse |
|
Input: | |
|
ShopName – The name of the shop. | |
|
OrderId – The ID of the order. | |
|
CustomerID – Mandatory The ID of the customer/visitor/contact. If the customer ID is not provided there is a potential security risk that any visitor can access orders from all customers. | |
|
Output: | |
|
Order – An instance of the order object is returned. The order object is created by the external commerce system. | |
|
SystemMessages - Collection of messages from the external system. |
Usage example:
var orderService = new OrderServiceProvider();
// need a valid order id for the first param
var visitorOrderRequest = new GetVisitorOrderRequest("Order_7777", "Me", "MyShop");
var result = orderService.GetVisitorOrder(visitorOrderRequest);GetVisitorOrders method
|
Name: |
GetVisitorOrders |
|
Description: |
Gets the order summary data of orders placed by the given visitor. Calls the |
|
Usage: |
Called from Sitecore when the order history is needed for a visitor. |
|
Signature: |
RequestResponse |
|
Input: | |
|
ShopName - The name of the shop. | |
|
CustomerId – ID of the buyer customer party. | |
|
Output: | |
|
IReadOnlyCollection<OrderBase> – An instance of the order object is returned. The order object is created by the external commerce system. | |
|
SystemMessages - Collection of messages from the external system. |
Usage example:
var orderService = new OrderServiceProvider();
var visitorOrdersRequest = new GetVisitorOrdersRequest("Me", "MyShop");
var result = orderService.GetVisitorOrders(visitorOrdersRequest);OrderStatusChanged method
|
Name: |
OrderStatusChanged |
|
Description: |
Used to inform Sitecore that a change has been made to the status of an order. |
|
Usage: |
Called from Sitecore to inform Sitecore about changes to an order’s status. |
|
Signature: |
RequestResponse |
|
Input: |
OrderId - The ID of the order that the status has changed on. |
|
CustomerId - The ID of the customer associated to the order. | |
|
OrderStatus – The new status of the order. | |
|
Output: |
Usage example:
var orderService = new OrderServiceProvider();
var visitorOrdersRequest = new GetVisitorOrdersRequest("Me", "MyShop");
var result = orderService.GetVisitorOrders(visitorOrdersRequest);Reorder method
|
Name: |
Reorder |
|
Description: |
Adds one or more items from a previously placed order into the customer’s current cart. This calls the |
|
Usage: |
Called when a customer wishes to reorder one or more items from a previously placed order. |
|
Signature: |
RequestResponse |
|
Input: | |
|
ShopName – The name of the shop. | |
|
OrderId – Mandatory The ID of the order. | |
|
CustomerID – Mandatory The ID of the customer/visitor/contact. If the customer ID is not provided there is a potential security risk that any visitor can access orders from all customers. | |
|
ReorderLineExternalIds – Optional The external IDs of the order lines that are being reordered. If not specified, all items from the order are reordered. | |
|
ForceNewLines – Optional If true, the cart lines items is added as new cart lines in the customer cart. Otherwise, the lines are merged into existing cart lines if possible. Note This parameter is only supported if the external commerce system supports this functionality. | |
|
Output: | |
|
Cart – An instance of the customer’s new cart contents returned. | |
|
AddedCartLineExternalIds – A list containing the IDs of the lines that were added to the customer’s cart. | |
|
SystemMessages - Collection of messages from the external system. |
Usage example:
var orderService = new OrderServiceProvider();
// need a valid order id for the second param
var reorderRequest = new ReorderRequest("Me", "Order_7777");
var result = orderService.Reorder(reorderRequest);VisitorCancelOrder method
The purpose of this method is for a visitor to cancel an existing order if the option is present on the web shop and if business logic does not prevent it, for example, if the order has already been fulfilled and/or shipped.
This method is typically triggered when showing order details to the customer launched from the order history view and the customer chooses to cancel the order.
|
Name: |
VisitorCancelOrder |
|
Description: |
Used to cancel an order placed by the visitor. The decision on whether the order is canceled or not lies in the business logic in the external commerce system. Typically an order cannot be canceled once its shop owner has started fulfilling/processing it. If the order cannot be canceled, it must be reflected in the returned SystemMessages. |
|
Usage: |
Called from Sitecore. |
|
Signature: |
RequestResponse |
|
Input: | |
|
ShopName – Mandatory The name of the shop. | |
|
OrderId – Mandatory The ID of the order. | |
|
CustomerID – Mandatory The ID of the customer/visitor. If the customer ID is not provided there is a potential security risk that any visitor can access orders from all customers. | |
|
OrderLineExternalIds – Optional A list of the external IDs of the order lines to cancel. If not specified, all lines of the order are canceled. Note Connect does not support this parameter by default. It is the responsibility of the external commerce system connectors to handle this property. | |
|
Output: | |
|
SystemMessages - Collection of messages from the external system. | |
|
CancelledOrder – Contains the order that was canceled. Note It is the responsibility of the external commerce system connectors to populate this result property. | |
|
CancellationStatus – An extensible enumeration value that indicates the status of the order cancelation operation (that is, Granted, Denied, and so on). Note It is the responsibility of the external commerce system connectors to populate this result property. |
Usage example:
var orderService = new OrderServiceProvider();
// need a valid order id for the first param
var visitorCancelOrder = new VisitorCancelOrderRequest("Order_7777", "Me", "MyShop");
var result = orderService.VisitorCancelOrder(visitorCancelOrder);