Ship Station Packing Ref field include in email

  • Posts: 86
  • Thank you received: 5
  • Hikashop Business
1 week 22 hours ago #372096

Hi, I have the ShipStation plugin and it passes through the tracking link to a field called: Package Ref (See attached)

I want to include this in my SHIPPING email that goes to the customer. How can I include this in my email code, I can see that it is a custom field so not sure what the variable name is.

I need to include it so my customers can see the tracking code.

Thx

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 85712
  • Thank you received: 14048
  • MODERATOR
1 week 8 hours ago #372101

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.

Please Log in or Create an account to join the conversation.

Time to create page: 0.355 seconds
Powered by Kunena Forum