Tracking numbers and tracking


5.0.0 or newer

Table of contents


This tutorial explains how to insert a tracking link into an email template for your customers. This allows keeping track of their order's delivery status at any time.

First thing you need is the tracking number of your logistics partner. In this example, we'll explain how to find a GLS tracking number. But However the steps here can be applied to virtually any logistics partner.

On the GLS group website, you can see a box titled Track & Trace. Enter a valid package number.

After entering a valid package number, note the composition of the URL:

In this case, the tracking URL reads as follows:

The package number 1234567890 will be replaced by a variable later.

Inserting tracking numbers into email template

In the backend, go to Configuration/Email templates and select your template from the left column.

Below you can see the tracking link and the necessary variable:

Text emails:

Track & Trace:{$sOrder.trackingcode}

Now go to Customers/Orders and set the Current order status to the status that corresponds with the email template you've just edited. The tracking link entered in Step 2 will appear automatically.

Providing tracking URLs in the frontend

Now go to Configuration/Shipping costs and enter the tracking URL from step 1. Here you don't have to use HTML or JavaScript, because the link will be built from the template. Just enter the URL from the logistics partner with the variable for the tracking number, all else is accomplished by the template.

The following is an example of the tracking URL:{$offerPosition.trackingcode}

As the tracking URL has already been provided in the shopping costs, it is therefore automatically available in your customer account, in the tab orders (1) and the order details (2). This is only available for customers that have registered for a customer account.

Customize the email template for multiple tracking numbers

For large orders it is common to split it up into more than one package. That way you will end up with a bunch of different tracking numbers for only one order. In our example, we assume that you include these, sperated with a comma in the order details.

In this case the example above wouldn't work because you can only transfer one tracking number per link. It is therefore necessary to generate several tracking links for this kind of dispatch. For example, you can extend the email template with the following content:

{assign var='Tracking' value=', '|explode:{$sOrder.trackingcode}}
{for $ct=0 to {$sOrder.trackingcode|replace:",":"."|count_sentences}}
{if $ = GLS}
Tracking code for package {$ct+1}:{$Tracking[$ct]}

The content of the email could look like this:

You can also use the HTML template and add a list element for better representation.

Customize the email template for various logistic companies

If you want to dispatch the order via different logistics companies, but still include the appropriate tracking links, an adaptation of the email template is necessary. The following example shows how it is done using the example of two major logistics companies, DHL and GLS:

{if $ == DHL}
Tracking Code:{$sOrder.trackingcode}
{else if $ == GLS}
Tracking Code:{$sOrder.trackingcode}
No tracking possible

If the shipping type "DHL" is chosen, the corresponding DHL link will be used. The GLS link gets applied to "GLS", when using another shipping type the text "No tracking possible" is displayed (conceivable, for example, for standard postal mailing)