How to display Track & Trace code in emails?

This article is applicable for our all our dropshipping plugins for WooCommerce, such as vidaXL, BigBuy and Van der Meer. Check the variables for each dropshipping plugin.

Introduction #

It is possible to add the Track & Trace code to a customer email, so that they would get informed about their order and its shipment. Our plugin supports an easy to use option, without requiring coding skills and a more advance option for developers.

In this article we’re going to explain both options and how to use them. If you’re not a developer yourself, please stick to the first option.

Enable Track & Trace checkbox #

From version 2.1.0 we have added a checkbox to the plugin settings, wether or not to add the Track & Trace code in the emails send to customers with regards to orders. In other words, the Track & Trace code will be added in all related default WooCommerce email templates.

Without having to code yourself, you can easily enable this option via WordPress dashboard > WooCommerce > Settings > vidaXL tab > Settings mini-tab.

As long as the below action hook will be present in the email templates, everything will work perfectly fine with this setting only.


Shortcode #

Besides the checkbox for sending Track & Trace code in emails, we have also introduced using a shortcode to display the Track & Trace URL.

Example of the shortcode:

[vdl_track_and_trace label="Check Tracking: " order_id=500900]

Webshop owners who want to add the Track & Trace URL in WooCommerce customer emails, we recommend the following steps:

  1. Navigate to WordPress dashboard > WooCommerce > Settings > Emails
  2. Click Manage behind the order email you would like to add the Track & Trace to
  3. If you don’t have a local copy of the email template click the button Copy file to theme
  4. Click View template
  5. Select the place of the template where you want to insert the Track & Trace code and add the following code to it:
echo do_shortcode('[vdl_track_and_trace order_id=' . $order->get_id() . ']');

Examples of using the code with additional text in the template:

echo "Track & Trace information: " . do_shortcode('[vdl_track_and_trace order_id=' . $order->get_id() . ']');
echo "Track & Trace information: " . do_shortcode('[vdl_track_and_trace label="Tracking: " order_id=' . $order->get_id() . ']');

The shortcode supports the following attributes:

label the text printed in front of the tracking code URL
order_id the order to be used to pull the tracking code from

Plugin variables #

In the code examples above, we have used the variable for vidaXL which is vdl. However, if you are using the Van der Meer or BigBuy Dropshipping plugin, that variable will change. Below you will find the variable for each plugin. 

vidaXL vdl
Van der Meer vdm
BigBuy bgb