Skip to main content
With the $wsShipTrack module, you can access shipment tracking and delivery checks. You can use this for example for tracking displays or zip code validation for delivery.

Module overview

Example / excerpt of $wsShipTrack
{{= $wsShipTrack | json }}
JSON output
{
  "getTracking": "ƒ()",
  "zipCodeConfirmed": "ƒ()"
}
Note: ƒ() denotes a function. Methods overview
MethodReturn typeDescription
getTracking()mapReturns tracking information from a shipping service provider for specific shipments.
zipCodeConfirmed()boolReturns whether the zip code for a specific order has already been confirmed.

Templates

Shipment tracking and zip code checks are typically used in the following places:
  • Order confirmation: tracking link after dispatch of the order.
  • Customer account: overview of shipment tracking for past orders.
  • Checkout: zip code validation for delivery options.

Variables

No variables are available for $wsShipTrack.

Methods

$wsShipTrack.getTracking()

Loads tracking information from a shipping service provider for a specific tracking number. The returned data depends directly on the respective provider, so when integrating, refer to the corresponding interface of the provider (e.g. DHL API). Signature
$wsShipTrack.getTracking(id, trackingId)
Return value
map - A map with the result of the tracking request.
Example of the structure returned on success:
{
  "success": true,
  "lastErrorText": "",
  "lastErrorCode": 0,
  "data": <Object>
}
The value under data is delivered directly by the provider (e.g. DHL) and therefore depends on the respective interface. If no tracking information could be loaded, data is not present and lastErrorText and lastErrorCode contain the error details from the provider. Parameters
NameTypeRequiredDescription
idstringyesID of the shipping service provider (e.g. dhl). Configured under checkout.shipTrack.
trackingIdstringyesTracking number of the shipping service provider (e.g. the DHL tracking number).
Example that attempts to load tracking information.
{{ var $tracking = $wsShipTrack.getTracking('dhl', '1234567890') }}
{{ if $tracking.success }}
    // Tracking data loaded.
{{ else }}
    // No tracking data found.
{{ /if }}

$wsShipTrack.zipCodeConfirmed()

Returns whether the zip code for a specific order has already been confirmed. This check is used before displaying shipment tracking to ensure that the user is indeed the original customer. Signature
$wsShipTrack.zipCodeConfirmed(orderId)
Return value
bool - true if the zip code for the specified order has already been confirmed, otherwise false.
Parameters
NameTypeRequiredDescription
orderIdstringyesID of the order for which the zip code confirmation is to be checked.
Example that checks whether the zip code has been confirmed.
{{ if $wsShipTrack.zipCodeConfirmed($myOrderId) }}
    // Zip code confirmed.
{{ else }}
    // Zip code not confirmed.
{{ /if }}

Examples

Shipment tracking with zip code check

This example first checks whether the zip code has been confirmed and then displays a corresponding message if tracking data is available.
{{ if $wsShipTrack.zipCodeConfirmed($myOrderId) }}
    <p>Delivery to confirmed zip code.</p>
    {{ var $tracking = $wsShipTrack.getTracking('dhl', $myTrackingId) }}
    {{ if $tracking.success }}
        <p>Tracking information available.</p>
    {{ else }}
        <p>Tracking could not be loaded: {{= $tracking.lastErrorText }}</p>
    {{ /if }}
{{ else }}
    <p>Please confirm your zip code to use shipment tracking.</p>
{{ /if }}