Page 1 of 1
Adding Tracking # to Order Shipped Template
Posted: Tue Dec 29, 2015 11:23 am
by xplosi0n1
Hello,
I am using Gold R10 and recently noticed our Order Shipped template is not displaying the tracking # link so the customer can track their package.
Can someone please give me the code needed to correct this. I think our web developers deleted this feature by accident.
Here is my current code for just the shipping section of the template.
<table class="Email">
<tr>
<th class="Email">Shipment Information</th>
</tr>
</table>
#each
<table class="Email">
<tr>
<td colspan="4" class="Email" style="text-align: center;">
<strong><u>Shipment $shipNo of $order.Shipments.Count</u></strong>
#set ($shipNo = $shipNo + 1)
</td>
</tr>
<tr>
<td class="Email" colspan="4" style="text-align: center;">
<table width="100%">
<tr>
<td class="Email" valign="top">
<strong>Ship From:</strong>
<div style="padding-left:30px;">
$shipment.FormatFromAddress(true)
</div>
</td>
<td class="Email" valign="top">
<strong>Ship To:</strong>
<div style="padding-left:30px;">
$shipment.FormatToAddress(true)
#if ($shipment.ShipMessage.Length > 0)
<br/><strong>Message:</strong>$shipment.ShipMessage
#end
</div>
</td>
<td class="Email" valign="top">
<strong>Shipment Method:</strong>
<div style="padding-left:30px;">
$shipment.ShipMethodName</div>
<strong>Shipment Status:</strong>
<div style="padding-left:30px;">
#if ($shipment.IsShipped)
Shipped
#else
Waiting to ship
#end
</div>
</td>
</tr>
</table>
</td>
</tr>
Any help would be greatly appreciated.
Re: Adding Tracking # to Order Shipped Template
Posted: Wed Dec 30, 2015 5:39 am
by jguengerich
I don't think the tracking number was ever in the supplied template. This is the code I have added to show the tracking number link. I have shown a few existing lines before and after so you can see where to put it. I only use UPS and FedEx, and in my very brief testing this works. It is based on the GetTrackingUrl method in ConLib\Account\OrderShipments.aspx.cs. If you use other shippers, you may need to look at that method and modify the template more based on it.
Code: Select all
<div style="padding-left:30px;">
#if ($shipment.IsShipped)
Shipped<!-- MY MODS: code to add tracking numbers starts immediately after this comment (the </div> is part of added code!) --></div>
<strong>Tracking Information:</strong>
<div style="padding-left:30px;"> #foreach($trackingNumber in $shipment.TrackingNumbers)
<a href="${trackingNumber.ShipGateway.GetProviderInstance().GetTrackingSummary($trackingNumber).TrackingLink}">$trackingNumber.TrackingNumberData</a>
#end<!-- MY MODS end here -->
#else
Waiting to ship
#end
</div>
Re: Adding Tracking # to Order Shipped Template
Posted: Mon Jan 04, 2016 6:35 am
by Katie
Jay is correct. We added this to the last release of Gold R11.
I copied this from the stock "Order Shipped" email template -
Code: Select all
<td class="Email" valign="top">
<strong>Shipment Method:</strong>
<div style="padding-left:30px;">
$shipment.ShipMethodName</div>
#if( $shipment.TrackingNumbers.Count > 0 )
#set ($trackingUrl = $shipment.GetLastTrackingNumber().GetTrackingUrl())
<div style="padding-left:30px;">
#if($trackingUrl != "")
<a href="${trackingUrl}">$shipment.getlasttrackingnumber().trackingnumberdata</a>
#else
$shipment.getlasttrackingnumber().trackingnumberdata
#end
</div>
#end
<strong>Shipment Status:</strong>
<div style="padding-left:30px;">
#if ($shipment.IsShipped)
Shipped
#else
Waiting to ship
#end
</div>
</td>
Re: Adding Tracking # to Order Shipped Template
Posted: Tue Jan 05, 2016 7:09 am
by xplosi0n1
Thank you both for the help.
The tracking info is now showing up on our receipts as intended. But the link is corrupt. When you click on the tracking # from the Order shipped email received it bring me to: C:\Users\Mike\Desktop\${trackingUrl}.
Can someone look at our ConLib\Account\OrderShipments.aspx.cs to see what is missing. We use UPS, USPS and FedEx.
Thanks again for all the support.
protected string GetShipStatus(object dataItem)
{
OrderShipment shipment = (OrderShipment)dataItem;
if (shipment.IsShipped) return "Shipped";
if (this.Order.OrderStatus.IsValid) return "Waiting to Ship";
return "Cancelled";
}
protected bool HasTrackingNumbers(object dataItem)
{
OrderShipment shipment = (OrderShipment)dataItem;
return (shipment.TrackingNumbers.Count > 0);
}
protected string GetTrackingUrl(object dataItem)
{
TrackingNumber trackingNumber = (TrackingNumber)dataItem;
if (trackingNumber.ShipGateway != null)
{
IShippingProvider provider = trackingNumber.ShipGateway.GetProviderInstance();
TrackingSummary summary = provider.GetTrackingSummary(trackingNumber);
if (summary != null)
{
// TRACKING DETAILS FOUND
if (summary.TrackingResultType == TrackingResultType.InlineDetails)
{
//send to view tracking page
return string.Format("MyTrackingInfo.aspx?TrackingNumberId={0}", trackingNumber.Id.ToString());
}
else if (summary.TrackingResultType == TrackingResultType.ExternalLink)
{
return summary.TrackingLink;
}
}
}
return string.Empty;
}
Re: Adding Tracking # to Order Shipped Template
Posted: Tue Jan 05, 2016 9:28 am
by jguengerich
I only mentioned ConLib\Account\OrderShipments.aspx.cs because that's where I looked to figure out what code to put in the template. The template does not call the code in OrderShipments.aspx.cs. Most likely the problem is a typo in your template code. Did you use the code I posted or the code Katie posted?
Re: Adding Tracking # to Order Shipped Template
Posted: Tue Jan 05, 2016 1:19 pm
by xplosi0n1
I used the code Katie posted. I thought maybe it would cover USPS also.
Re: Adding Tracking # to Order Shipped Template
Posted: Tue Jan 05, 2016 1:26 pm
by jguengerich
Since that is code she got from R11, maybe there's something in there that isn't implemented in R10. I probably won't have time to try her code soon, so hopefully she or someone else can continue to help.
Re: Adding Tracking # to Order Shipped Template
Posted: Tue Jan 05, 2016 2:58 pm
by Katie
Mike,
Unfortunately, it does appear that some changes were made to the source code in order to accommodate the changes in the email templates. You might have to try Jay's solution instead, or you would need to upgrade to Gold R11.
Re: Adding Tracking # to Order Shipped Template
Posted: Wed Jan 06, 2016 11:43 am
by xplosi0n1
Jay,
I have decided to use your code since there were some updates with Able between R10 and R11.
It works perfectly for all my shipping methods.
I just wanted to thank you for your help, it will make our customers very happy and save us time answering tracking # emails.