Skip to main content
With the $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
{{= $wsOrderHistory | json }}
JSON output
{
  "load": "ƒ()",
  "loadList": "ƒ()"
}
Note: ƒ() denotes a function. Methods overview
MethodReturn typeDescription
loadList()arrayReturns a list of the last 50 orders.
load()mapReturns a single order based on an order ID.

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 template orderHistory.htm.

Variables

No variables are available for $wsOrderHistory.

Methods

$wsOrderHistory.loadList()

Returns a list of the last 50 orders. Signature
$wsOrderHistory.loadList()
Return value
Array - List of order maps.
Example that loads the order history into a variable.
{{ var $myOrderListVariable = $wsOrderHistory.loadList() }}

$wsOrderHistory.load()

Returns a single order based on an order ID. Signature
$wsOrderHistory.load(orderId)
Return value
Map - Order map with all order data.
Parameters
NameTypeRequiredDescription
orderIdstringyesID of the order to be loaded.
Example that loads an order into a variable.
{{ var $order = $wsOrderHistory.load("12345") }}
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:
{
  "general": {
    "orderId": "...",
    "dateTime": "...",
    "shopId": "...",
    "subshopId": "...",
    "sessionId": "...",
    "shopLanguage": "...",
    "testMode": true/false
  },
  "order": {
    "priceType": "...",
    "currencyIso": "...",
    "currencySymbol": "...",
    "defaultTaxRate": "...",
    "paymentId": "...",
    "paymentOrderText": "...",
    "delivererId": "...",
    "delivererOrderText": "...",
    "deliveryCost": "...",
    "deliveryTaxRate": "...",
    "subtotal": "...",
    "total": "...",
    "tax": "...",
    "totalDiscount": "..."
  },
  "customer": {
    "accountType": "...",
    "accountId": "...",
    "email": "...",
    "ipAddress": "..."
  },
  "orderList": {
    "items": [...]
  },
  "billAddress": { ... },
  "shippingAddress": { ... },
  "freeFields": { ... }
}
Variables overview General variables:
VariableTypeDescription
generalmapMap with general information about the order.
orderIdstringID of the order.
dateTimestringDate and time of the order.
shopIdstringID of the shop in which the order was placed.
subshopIdstringID of the subshop in which the order was placed.
sessionIdstringID of the session in which the order was placed.
shopLanguagestringLanguage of the shop in which the order was placed.
testModeboolChecks whether the order was executed in test mode.
Order information:
VariableTypeDescription
ordermapMap with data about the order (prices, shipping, payment method, etc.)
priceTypestringPrice type: "net" or "gross".
currencyIsostringISO code of the currency (e.g. "EUR").
currencySymbolstringCurrency symbol (e.g. "€").
defaultTaxRatestringStandard tax rate.
paymentIdstringID of the payment method.
paymentOrderTextstringDescription of the payment method.
delivererIdstringID of the shipping method.
delivererOrderTextstringDescription of the shipping method.
deliveryCoststringShipping costs.
deliveryTaxRatestringTax rate of the shipping costs.
subtotalstringGoods value of the order.
totalstringTotal price of the order.
taxstringTotal taxes of the order.
totalDiscountstringTotal discount of the order.
Customer information:
VariableTypeDescription
customermapMap with data about the buyer.
accountTypestringAccount type: "Guest" or "Existing customer".
accountIdstringID of the account.
emailstringEmail of the buyer.
ipAddressstringIP address of the buyer.
Additional information:
VariableTypeDescription
orderListmapMap with data about ordered items.
itemsarrayList of ordered products.
billAddressmapMap with billing address data.
shippingAddressmapMap with shipping address data.
freeFieldsmapMap with free fields specified with the order.

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.
{{if $wsViews.current.params.orderHistorySelect}}
	{{var $myOrder = $wsOrderHistory.load($wsViews.current.params.orderHistorySelect)}}
{{ /if }}

General map - general info

The map $myOrder.general loads general information such as order ID and order date.
Order ID: {{= $myOrder.general.orderId }}
Order date: {{= $myOrder.general.dateTime }}
Shop ID: {{= $myOrder.general.shopId }}
Subshop ID: {{= $myOrder.general.subshopId }}
Session ID: {{= $myOrder.general.sessionId }}
Shop language: {{= $myOrder.general.shopLanguage }}
Order placed in test mode: {{ if $myOrder.general.testMode }}True{{ /if }}

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.
Price "net" or "gross": {{= $myOrder.order.priceType }}
ISO code of the currency: {{= $myOrder.order.currencyIso }}
Currency symbol: {{= $myOrder.order.currencySymbol }}
Standard tax rate: {{= $myOrder.order.defaultTaxRate }}
ID of payment method: {{= $myOrder.order.paymentId }}
Description of payment method: {{= $myOrder.order.paymentOrderText }}
ID of shipping method: {{= $myOrder.order.delivererId }}
Description of shipping method: {{= $myOrder.order.delivererOrderText }}
Extra costs of shipping method: {{= $myOrder.order.deliveryCost }}
Tax rate of shipping costs: {{= $myOrder.order.deliveryTaxRate }}
Goods value: {{= $myOrder.order.subtotal }}
Total price: {{= $myOrder.order.total }}
Total taxes: {{= $myOrder.order.tax }}
Total discount: {{= $myOrder.order.totalDiscount }}

Customer map - customer info

The map $myOrder.customer loads customer info such as address and customer number.
Account type ("Guest" or "Existing customer"): {{= $myOrder.customer.accountType }}
Account ID: {{= $myOrder.customer.accountId }}
Buyer's email: {{= $myOrder.customer.email }}
Buyer's IP address: {{= $myOrder.customer.ipAddress }}

Actions

No actions are available for $wsOrderHistory.