Adding Tracking # to Order Shipped Template

For general questions and discussions specific to the AbleCommerce GOLD ASP.Net shopping cart software.
Post Reply
User avatar
xplosi0n1
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 30
Joined: Mon Nov 30, 2009 10:54 am
Location: Dayton, OH
Contact:

Adding Tracking # to Order Shipped Template

Post by xplosi0n1 » Tue Dec 29, 2015 11:23 am

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.
Thanks,
Mike

CheapBowlingBalls.com
3204 Woodman Drive
Kettering, OH 45420
937.559.1541
mikeh@cheapbowlingballs.com
www.cheapbowlingballs.com

jguengerich
Commodore (COMO)
Commodore (COMO)
Posts: 436
Joined: Tue May 07, 2013 1:59 pm

Re: Adding Tracking # to Order Shipped Template

Post by jguengerich » Wed Dec 30, 2015 5:39 am

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>
Jay

User avatar
Katie
AbleCommerce Admin
AbleCommerce Admin
Posts: 2651
Joined: Tue Dec 02, 2003 1:54 am
Contact:

Re: Adding Tracking # to Order Shipped Template

Post by Katie » Mon Jan 04, 2016 6:35 am

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>
Thank you for choosing AbleCommerce!

http://help.ablecommerce.com - product support
http://wiki.ablecommerce.com - developer support

User avatar
xplosi0n1
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 30
Joined: Mon Nov 30, 2009 10:54 am
Location: Dayton, OH
Contact:

Re: Adding Tracking # to Order Shipped Template

Post by xplosi0n1 » Tue Jan 05, 2016 7:09 am

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;
}
Thanks,
Mike

CheapBowlingBalls.com
3204 Woodman Drive
Kettering, OH 45420
937.559.1541
mikeh@cheapbowlingballs.com
www.cheapbowlingballs.com

jguengerich
Commodore (COMO)
Commodore (COMO)
Posts: 436
Joined: Tue May 07, 2013 1:59 pm

Re: Adding Tracking # to Order Shipped Template

Post by jguengerich » Tue Jan 05, 2016 9:28 am

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?
Jay

User avatar
xplosi0n1
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 30
Joined: Mon Nov 30, 2009 10:54 am
Location: Dayton, OH
Contact:

Re: Adding Tracking # to Order Shipped Template

Post by xplosi0n1 » Tue Jan 05, 2016 1:19 pm

I used the code Katie posted. I thought maybe it would cover USPS also.
Thanks,
Mike

CheapBowlingBalls.com
3204 Woodman Drive
Kettering, OH 45420
937.559.1541
mikeh@cheapbowlingballs.com
www.cheapbowlingballs.com

jguengerich
Commodore (COMO)
Commodore (COMO)
Posts: 436
Joined: Tue May 07, 2013 1:59 pm

Re: Adding Tracking # to Order Shipped Template

Post by jguengerich » Tue Jan 05, 2016 1:26 pm

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.
Jay

User avatar
Katie
AbleCommerce Admin
AbleCommerce Admin
Posts: 2651
Joined: Tue Dec 02, 2003 1:54 am
Contact:

Re: Adding Tracking # to Order Shipped Template

Post by Katie » Tue Jan 05, 2016 2:58 pm

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.
Thank you for choosing AbleCommerce!

http://help.ablecommerce.com - product support
http://wiki.ablecommerce.com - developer support

User avatar
xplosi0n1
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 30
Joined: Mon Nov 30, 2009 10:54 am
Location: Dayton, OH
Contact:

Re: Adding Tracking # to Order Shipped Template

Post by xplosi0n1 » Wed Jan 06, 2016 11:43 am

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.
Thanks,
Mike

CheapBowlingBalls.com
3204 Woodman Drive
Kettering, OH 45420
937.559.1541
mikeh@cheapbowlingballs.com
www.cheapbowlingballs.com

Post Reply