Magento 2 Extensions:Custom Carrier Trackers

From XTENTO Support Wiki
Jump to: navigation, search
This is a guide for Magento 2. For Magento 1 extensions and guides, please refer to Magento 1 Guides.

Custom carrier trackers noborder small.png



Add custom tracking methods to Magento and make tracking links in emails clickable for your customers. All using the Custom Carrier Trackers extension by XTENTO.

Out of the box, Magento only offers three tracking methods: UPS, USPS and FedEx. That's often not enough. In case you want to add custom tracking methods to Magento, because you're shipping using a custom carrier for example and want your customers to be able to track their orders shipped using these custom carriers, this extension is the way to go.

Interested in this Magento Extension?

Head over to our store to purchase this extension: Custom Carrier Trackers (Magento 2)

Got questions? Feel free to contact us! Contact Form

Setting up the extension

The configuration section of this extension is located at System > XTENTO Extensions > Custom Carrier Trackers and should be pretty much self-explanatory. Just make sure you set the module to Enabled and make sure that the trackers you want to use are set to Enabled as well.

Setting up a new tracking method

Setting up a new tracking method is easy. Just open the configuration section and set Enabled to Yes for one of the 30 ready-to-use trackers.

When setting up the tracking URL, some variables can be used which get replaced in the tracking URL sent to your customers.

These are the variables:

#TRACKINGNUMBER#This variable gets replaced with the tracking number associated.

#ZIP#This variable gets replaced with the receivers ("ship to") postcode.

#ORDERNUMBER#Order number belonging to the tracking number

#FIRSTNAME#(ship to) First name

#LASTNAME#(ship to) Last name

#COUNTRYCODE#(ship to) Country code in two letter format, e.g. "US"

#d#Shipment creation date - Day of month (e.g. 23)

#m#Shipment creation date - Month (e.g. 11)

#y#Shipment creation date - Year in two digit format

#Y#Shipment creation date - Year in four digit format

An example tracking URL for UPS would be:

Many more tracking URLs for international carriers from >10 different countries can be found in the "TRACKING_URLS.txt" file that comes with the extension.

Developer Information

Adding tracking numbers via the API

When adding a tracking number via the Magento API, you need to specify a "carrier_code". For the custom trackers of our module, the carrier codes are "tracker1" through "tracker30". This means, if you want to add a tracking number for the carrier "XYZ" and set that up under "Custom Tracker - 3" in the admin, you'd need to send "tracker3" to the API.

Some third party applications such as Linnworks always send the tracking number with the carrier code "custom" to Magento. This is a problem, as in order to assign a custom tracker with a tracking link, it would need to send tracker1 to the API for example. This is not a problem in our extension but rather the third party application; of course it needs to send the correct carrier code to Magento in order for Magento to recognize "which" tracker should be used for the tracking number.

A possible workaround for applications that always send "custom" to Magento may be as following:

1) Set up a custom module & plugin for \Magento\Sales\Model\Order\Shipment\TrackRepository, method "save".
2) In the "around" plugin manipulate $entity so that "carrier_code" is set to "tracker1", for example, or whatever custom carrier code you want to set.

Attention, make sure to add a check that the request is coming from the API and/or some other criteria, otherwise all tracking numbers added & saved in Magento would be set using "tracker1". A sample module that adds ability to map (see Helper/MapCarrier) can be found here.

Please note, again, this is not a problem in our extension and we cannot set up such a module for you nor customize Magento to fix this - either third party applications must send the correct carrier code OR you must set up a customization as described above.


The tracking link in the shipment email does not show up

Please make sure you have uploaded ALL extension files.

Please note that only NEW tracking numbers added using our *new* trackers will have links attached. This means, old shipments/tracking numbers, or shipments created using the default carriers built into Magento won't have links. If you want to set up links for UPS, USPS, DHL or FedEx, disable them using the "Disabled default carriers" option in the modules configuration and set them up as custom trackers with the links from the TRACKING_URLS.TXT file that comes with the extension.

The tracking number section does not show up in New Shipment emails

You are probably using Magento 2.3.3+ and are using outdated email templates. At Marketing > Email Templates, open your New Shipment template and look for:

{{block class='Magento\Framework\View\Element\Template' area='frontend' template='Magento_Sales::email/shipment/track.phtml' shipment=$shipment order=$order}}

Replace this with:

{{layout handle="sales_email_order_shipment_track" shipment=$shipment order=$order}}


{{layout handle="sales_email_order_shipment_track" shipment_id=$shipment_id order_id=$order_id}}

Tracking links opened in the Magento backend convert & to & amp;

This is a bug in Magento 2.3.5 that has been fixed in Magento 2.4.0.

Custom trackers don't show up when shipping an order

Please re-upload all extension files and re-install the extension to ensure all files of the extension are there. If the Tracker models are missing, they won't show up.

No tracking numbers in shipment email

Possibly a bug in Magento 2.3.4/2.3.5, fixed in Magento 2.4.0:

Personal tools
General Information
Magento 2 Guides
Magento 2 Extensions
Magento 1 Guides
Magento 1 Extensions
Magento Integration Suite
Product Feed Guides