Magento Extensions:Custom Carrier Trackers

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

Custom carrier trackers noborder small.png
Buy-now.png

Contents

Overview

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

Got questions? Feel free to contact us! Contact Form

Setting up the extension

The configuration section of this extension is located at System > Configuration > 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 ten 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: http://wwwapps.ups.com/WebTracking/track?HTMLVersion=5.0&loc=en_US&Requester=UPSHome&WBPM_lid=homepage%2Fct1.html_pnl_trk&trackNums=#TRACKINGNUMBER#&track.x=Track


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 & rewrite for Mage_Sales_Model_Order_Shipment_Api, method "addTrack".
2) In the rewritten "addTrack" function, manipulate $carrier so that "carrier_code" is set to "tracker1", for example, or whatever custom carrier code you want to set.

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.

Changing the carrier code

Attention: This is information for developers only. You don't need this to set up normal custom trackers. You won't ever see the below mentioned "internal tracker codes" if you're not a developer, and won't need this.

In certain environments it may be required to change the internally used tracker codes. They are tracker1 through tracker10 out of the box.

Let's say we want to replace tracker code "tracker10" with "royalmail" so "royalmail" can be used as the internal tracker code.

Search for all occurrences of tracker10 and replace with royalmail in the modules ZIP file.

In the class Xtento_CustomTrackers_Model_System_Config_Source_Shipping_Carriers, adjust this line:

if ($carrierConfig->isTrackingAvailable() && !preg_match('/tracker/', $carrierCode)) {

And add something that matches your new carrierCode as well:

if ($carrierConfig->isTrackingAvailable() && !preg_match('/tracker/', $carrierCode) && !preg_match('/royalmail/', $carrierCode)) {

Make sure to refresh/flush the Magento cache afterwards.

Troubleshooting

The tracking link in the shipment email does not show up

Please make sure you have uploaded ALL extension files. The file track.phtml needs be saved into the following directory (and might replace the existing track.phtml file!): app/design/frontend/YOUR_THEME_HERE/YOUR_THEME_HERE/template/email/order/shipment/

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.

No tracking numbers are shown at all in the shipment email

You or a developer probably removed the tracking number part from the email template. Make sure you have this piece of code in the "Transactional Email" used for shipments: {{block type='core/template' area='frontend' template='email/order/shipment/track.phtml' shipment=$shipment order=$order}}

DHL_Intraship Extension: Add clickable tracking link

Establishing compatibility with the DHL Intraship extension (developed by NetResearch) is easy.

First of all, go to System > XTENTO > Custom Carrier Trackers and set up the tracker for DHL. For example for "Custom Tracker 1" set "Enabled" to "Yes" and in the "Tracking Link" field enter:

http://nolp.dhl.de/nextt-online-public/set_identcodes.do?lang=de&idc=#TRACKINGNUMBER#

Remember which tracker you used (1, 2, or 15, for example). Now, open the file app/code/community/Dhl/Intraship/Model/Shipment.php and look for:

$track->setCarrierCode('intraship')

Replace "intraship" with "tracker1" if you used the first tracker in our module, or "tracker12" if you used the 12th tracker. So for example, if you used the first tracker in our module:

$track->setCarrierCode('tracker1')

Now, save the file. For any tracking numbers generated by the Intraship extension AFTER you made this change, a clickable tracking link will be sent to the customer.

Uncaught Error: Call to a member function getCode() on boolean in app/code/community/Webshopapps/Productmatrix/Model/Carrier/Productmatrix.php:661

Open file: app/code/community/Webshopapps/Productmatrix/Model/Carrier/Productmatrix.php Look for: if ($preUrl!='none') { Replace with: if ($preUrl!=) { Save file.

Personal tools
Namespaces
Variants
Actions
General Information
Magento 2 Guides
Magento 2 Extensions
Magento 1 Guides
Magento 1 Extensions
Magento Integration Suite
Product Feed Guides
Toolbox