Tracking numbers and tracking

Article Version

5.0.0 or newer

Table of contents

Introduction

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:


https://gls-group.eu/DE/de/paketverfolgung?match=

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: https://gls-group.eu/DE/de/paketverfolgung?match={$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:


https://gls-group.eu/DE/de/paketverfolgung?match={$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 $sDispatch.name = GLS}
Tracking code for package {$ct+1}: https://gls-group.eu/DE/de/paketverfolgung?match={$Tracking[$ct]}
{/if}
{/for}

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 $sDispatch.name == DHL}
Tracking Code: https://nolp.dhl.de/nextt-online-public/de/search?piececode={$sOrder.trackingcode}
{else if $sDispatch.name == GLS}
Tracking Code: https://gls-group.eu/DE/de/paketverfolgung?match={$sOrder.trackingcode}
{else}
No tracking possible
{/if}

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)