Tracking numbers and tracking


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.

Find out the required tracking URL of your logistics partner. In this example we will explain how to find a tracking link for GLS. This example is transferable to almost all other logistics companies.

On the GLS Group website you will find a form (1) that allows you to enter a tracking ID/code. Enter a valid parcel number (2) here:

After you have entered a valid parcel number, you should see the track and trace information. 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.

Extend email template with tracking URL

Now switch to the email templates and select the desired template. In our case we have chosen the email template completely delivered (1).

Here we have stored with the tracking link and the required variable for the package number.

Link (example GLS) for text emails (2)

Track & Trace:{$sOrder.trackingcode}

As of Shopware 5.2 it is possible to also send the status emails in HTML format (3).

If you now change the status of the order to completely delivered under current order status (1) in the orders, the email template customized in step 2 will automatically appear with the corresponding tracking link (2).

Within the email templates, there are corresponding variables available for each individual template. You can find out which ones are available in detail for the e-mail template Completely delivered by clicking on the arrow of the variable information. Please note that the variables provided here cannot necessarily be used in other email templates.

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, separated 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='Paket' value=1}
{assign var='Tracking' value=','|explode:{$sOrder.trackingcode}}
{foreach $Tracking as $temp}
Link zu Paket {$Paket}: {$temp}
{assign var='Paket' value={$Paket+1}}

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)

Was this article helpful?