Hello,
"Package Ref" is not actually a HikaShop custom field. It is a label that the ShipStation plugin itself adds. The carrier, service and tracking number that ShipStation sends back are stored in the order's shipping parameters, not in a custom field, which is why you could not find a variable name for it.
The good news is that you usually do not need to touch the email code at all. The ShipStation plugin already injects the carrier, service and tracking number into the order notification email automatically, right after the list of products. It does this through a display hook that the status notification email triggers. So as long as:
- the "Notify the customer" option is enabled in the ShipStation plugin configuration, and
- the email being sent is the order status notification email (the one sent when the order moves to shipped),
the tracking number should already appear in that email under the products, with no edit needed. If it is not showing, it is usually because the email template was customised and the products listing section (which carries that hook) was removed, or because the email you are looking at is not the status notification one.
If you specifically want to print it yourself at a chosen spot in a customised email template, you can read it directly from the order object. In the email template the order is available as $data->cart, so you can add something like this:
<?php
if(!empty($data->cart->order_shipping_params->shipstation)) {
foreach($data->cart->order_shipping_params->shipstation as $package) {
echo 'Tracking: ' . $package['track_number']
. ' (' . $package['carrier'] . ' / ' . $package['service'] . ')<br/>';
}
}
?>
One timing point to keep in mind: ShipStation only sends the tracking number back to HikaShop once the order is marked as shipped on their side. So the email that can contain the tracking number is the one triggered by that status change, not the order confirmation email sent at checkout time.