$wsOrderHistory module, you can load and display the order history of a logged-in customer in the frontend. This allows customers to view their past orders, retrieve order details, and place reorders, for example. In this section, you will learn how to load the order list and individual orders.
Module overview
Example / excerpt of$wsOrderHistory
ƒ() denotes a function.
Methods overview
Templates
The order history can be loaded in any template and is typically integrated into the account area. Logged-in customers can view it in the templateorderHistory.htm.
Variables
No variables are available for$wsOrderHistory.
Methods
$wsOrderHistory.loadList()
Returns a list of the last 50 orders. Signature$wsOrderHistory.loadList()
Return valueArray - List of order maps.
Example that loads the order history into a variable.
$wsOrderHistory.load()
Returns a single order based on an order ID. Signature$wsOrderHistory.load(orderId)
Return valueMap - Order map with all order data.
Parameters
Example that loads an order into a variable.
By using the
$wsOrderHistory.load function, various variables are available to retrieve and output order data. Below is an overview of which variables are available.Order data (return value of $wsOrderHistory.load())
First, it is necessary to assign the map with the order data, as shown in the example above, to a local variable. This can then be used at various places in the template. JSON output of the variable:
Order information:
Customer information:
Additional information:
Delivery status (deliveryStatus)
The deliveryStatus area contains the delivery status of the order. It is only present when a delivery status has been set for the order in the Admin Interface. Therefore always check the field with {{ if $order.deliveryStatus }} before outputting it.
The delivery status is maintained in the Admin Interface under Orders and is distinguished in two ways:
Scope (type):
global– The status applies to the entire order (all products are delivered in one package).splitted– The order is delivered in multiple packages; each package carries its own status and a list of the items it contains.
global: statusType; with splitted, per package: deliveryStatusType):
tracking– A tracking number (trackingNumber) and a shipping service provider (trackingVendorId) have been recorded.trackingVendorIdcorresponds to theidof the checkout.shipTrack configuration.manual– A freely worded status text has been entered in the Admin Interface.
deliveryStatus is only provided by load(). The entries from loadList() do not contain the field – if needed, reload the order via its ID.
Structure for a global status with tracking data:
splitted):
Example
Display the delivery status of an order. Before display,
$wsShipTrack.zipCodeConfirmed() is used to check whether the customer has confirmed the ZIP code of the order; if not, the confirmation form of the ConfirmZipCode action is shown.
If the delivery status is set and the ZIP code has been confirmed, either the manual status text or the tracking information is shown, depending on the configuration – with package delivery per package including the contained items. As long as the ZIP code has not been confirmed, the confirmation form is shown instead.
Example for displaying order history data
Display order data
After an order has been loaded from the order history and assigned to a variable, the order data can be accessed via the available maps. In this example, the order is assigned to the variable$myOrder. The order data can be loaded from this variable and freely placed in the template.
General map - general info
The map$myOrder.general loads general information such as order ID and order date.
Order map - info about the order
The map$myOrder.order loads technical info such as costs, payment method, shipping method, and discounts of the order.
Customer map - customer info
The map$myOrder.customer loads customer info such as address and customer number.
Actions
No actions are available for$wsOrderHistory. For confirming the ZIP code before displaying the delivery status, see the ConfirmZipCode action of the $wsShipTrack module.
Related links
- $wsAccount
- $wsShipTrack - Shipment tracking: for a tracking number from
deliveryStatus, loads the tracking information from the shipping provider and checks the ZIP code confirmation.
