Page 1 of 1
Tracking numbers in shipment notifications
Posted: Thu Jan 24, 2008 4:49 pm
by AbleMods
I just noticed that tracking number information is not included in the default AC7 shipping notification email templates.
Has anyone successfully added this to their template who would be willing to share that knowledge?
Posted: Wed Jan 30, 2008 3:41 pm
by batmike
Joe,
I just found this is another post ... I have yet to try it out in my templates, but I'm going to add it in and try it out tomorrow.
If you get it in and find that it works (or not), let me know.
Mike
drollins wrote:OK I figured it out...
Code: Select all
#if($shipment.TrackingNumbers.Count > 0)
<tr>
<td>
<b>Tracking Number(s)</b>
</td>
<td>
#foreach($trackingNumber in $shipment.TrackingNumbers)
$trackingNumber.TrackingNumberData
#end
</td>
</tr>
#end
Posted: Thu Jan 31, 2008 7:10 am
by batmike
Alright ... I was able to test it out and after reshipping things to myself about six times, I got it to work. This is what I added in right below the shipment status ending div tag. That should do it for you
Mike
Code: Select all
#if($shipment.TrackingNumbers.Count > 0)
#foreach($trackingNumber in $shipment.TrackingNumbers)
<strong>Tracking Number:</strong>
<div>
$trackingNumber.TrackingNumberData
#end
#end
</div>
Posted: Thu Jan 31, 2008 9:17 am
by compunerdy
That works great. What about making the tracking number clickable? Can the link/address be based off what shipping method was used?
Posted: Thu Jan 31, 2008 10:26 am
by batmike
The link was my next step ... we actually only use UPS but I went ahead and figured out the link for Fedex just to get it to work. If you use any other shippers, just figure out what link you need and put it in. Also, make sure to change the "if $shipment.ShipMethodId == ?" to whatever Id numbers match your shippers in your database.
Mike
Code: Select all
#if($shipment.TrackingNumbers.Count > 0)
#if($shipment.ShipMethodId == 4)
#foreach($trackingNumber in $shipment.TrackingNumbers)
<strong>Tracking Number:</strong>
<div style="padding-left:30px;">
<a href="http://wwwapps.ups.com/WebTracking/processInputRequest?tracknum=${trackingNumber.TrackingNumberData}">$trackingNumber.TrackingNumberData</a>
#end
#elseif($shipment.ShipMethodId == 9)
#foreach($trackingNumber in $shipment.TrackingNumbers)
<strong>Tracking Number:</strong>
<div style="padding-left:30px;">
<a href="http://fedex.com/Tracking?action=track&tracknumber_list=${trackingNumber.TrackingNumberData}&cntry_code=us">$trackingNumber.TrackingNumberData</a>
#end
#end
#end
</div>
Posted: Thu Jan 31, 2008 10:42 am
by compunerdy
Can you define more than one method ID on a single line like this?
Code: Select all
#elseif($shipment.ShipMethodId == 11 or 15)
Or something similar?
Here is the line for USPS..
Code: Select all
<a href="http://trkcnfrm1.smi.usps.com/PTSInternetWeb/InterLabelInquiry.do?origTrackNum=${trackingNumber.TrackingNumberData}">$trackingNumber.TrackingNumberData</a>
Posted: Thu Jan 31, 2008 11:29 am
by batmike
Yeah, you could put
Code: Select all
#elseif($shipment.ShipMethodId == 11 || 15)
The || is OR, and you can also use && for and.
Thanks for the USPS, I needed that one
Mike
Posted: Thu Jan 31, 2008 11:52 am
by compunerdy
Ok..so here is my code using
UPS 11 or 15
USPS 3,5, or 6
Code: Select all
#if($shipment.TrackingNumbers.Count > 0)
#if($shipment.ShipMethodId == 11 || 15)
#foreach($trackingNumber in $shipment.TrackingNumbers)
<strong>Tracking Number:</strong>
<div style="padding-left:30px;">
<a href="http://wwwapps.ups.com/WebTracking/processInputRequest?tracknum=${trackingNumber.TrackingNumberData}">$trackingNumber.TrackingNumberData</a>
#end
#elseif($shipment.ShipMethodId == 3 || 5 || 6)
#foreach($trackingNumber in $shipment.TrackingNumbers)
<strong>Tracking Number:</strong>
<div style="padding-left:30px;">
<a href="http://trkcnfrm1.smi.usps.com/PTSInternetWeb/InterLabelInquiry.do?origTrackNum=${trackingNumber.TrackingNumberData}">$trackingNumber.TrackingNumberData</a>
#end
#end
#end
</div>
I Just tested this out and UPS seemed to work fine but a usps did not. Can you not use 2 OR statements like I did?
Method 3 works but method 5 didnt??
Posted: Thu Jan 31, 2008 12:38 pm
by batmike
Hmm ... I'm not really sure but my guess would be the same, that it doesn't like have multiple or conditions.
You could just make a third section and have the second be if ShipMethodId = 3 or 5 and the last section be if the ShipMethodId is 6. Not the most elegant solution, but it might work. (It's the best thing I could come up with for now

)
Give that a try, and see what happens.
Mike
Posted: Thu Jan 31, 2008 2:12 pm
by compunerdy
I had to list them all out otherwise it would only use the first option and ignore the OR ||
Code: Select all
#if($shipment.TrackingNumbers.Count > 0)
#if($shipment.ShipMethodId == 11)
#foreach($trackingNumber in $shipment.TrackingNumbers)
<strong>Tracking Number:</strong>
<div style="padding-left:30px;">
<a href="http://wwwapps.ups.com/WebTracking/processInputRequest?tracknum=${trackingNumber.TrackingNumberData}">$trackingNumber.TrackingNumberData</a>
#end
#elseif($shipment.ShipMethodId == 15)
#foreach($trackingNumber in $shipment.TrackingNumbers)
<strong>Tracking Number:</strong>
<div style="padding-left:30px;">
<a href="http://wwwapps.ups.com/WebTracking/processInputRequest?tracknum=${trackingNumber.TrackingNumberData}">$trackingNumber.TrackingNumberData</a>
#end
#elseif($shipment.ShipMethodId == 3)
#foreach($trackingNumber in $shipment.TrackingNumbers)
<strong>Tracking Number:</strong>
<div style="padding-left:30px;">
<a href="http://trkcnfrm1.smi.usps.com/PTSInternetWeb/InterLabelInquiry.do?origTrackNum=${trackingNumber.TrackingNumberData}">$trackingNumber.TrackingNumberData</a>
#end
#elseif($shipment.ShipMethodId == 5)
#foreach($trackingNumber in $shipment.TrackingNumbers)
<strong>Tracking Number:</strong>
<div style="padding-left:30px;">
<a href="http://trkcnfrm1.smi.usps.com/PTSInternetWeb/InterLabelInquiry.do?origTrackNum=${trackingNumber.TrackingNumberData}">$trackingNumber.TrackingNumberData</a>
#end
#elseif($shipment.ShipMethodId == 6)
#foreach($trackingNumber in $shipment.TrackingNumbers)
<strong>Tracking Number:</strong>
<div style="padding-left:30px;">
<a href="http://trkcnfrm1.smi.usps.com/PTSInternetWeb/InterLabelInquiry.do?origTrackNum=${trackingNumber.TrackingNumberData}">$trackingNumber.TrackingNumberData</a>
#end
#end
#end
</div>
Posted: Fri Feb 01, 2008 1:22 am
by sohaib
I think you are supposed to do it this way
Code: Select all
#if($shipment.ShipMethodId == 11 || $shipment.ShipMethodId==15)
Did you try this?
were in the email template do you put this code
Posted: Thu Feb 14, 2008 5:02 am
by cerami2
this is the email template for the order shipped
Can someone show me were i would enter the code
I use ups and usps
thanks Joe
<html>
<head>
<style>
TABLE.Email {
width: 640px;
padding: 5px;
margin: 0px;
border: 1px solid #5872CB;
}
TABLE.Email TH {
font-weight: bold;
font-size: 12px;
color: #ffffff;
font-family: Arial, Verdana, Sans-Serif;
font-style: strong;
background-color: #304FBA;
text-align: center;
text-decoration: none;
padding: 5px;
}
TABLE.Email TD {
font-weight: normal;
font-size: 12px;
color: #000000;
font-family: Arial, Verdana, Sans-Serif;
background-color: #ffffff;
text-align: left;
text-decoration: none;
padding: 3px;
}
</style>
</head>
<body>
<table>
<tr>
<td>
<p><strong>Hello $order.BillToFirstName, </strong></p>
<p> We thought you'd like to know that we shipped your items, and that
this
completes your order.</p>
<p>If you would like to view your order, manage addresses, update your email,
or customize many other options, please visit your personal
<a>My Account</a> page.</p>
<p>Thank you for shopping with us.<br>
$store.Name</p>
</td>
</tr>
</table>
<table>
<tr>
<th>Order Summary</th>
</tr>
</table>
<table>
<tr>
<td><div><strong>Email Address:</strong></div></td>
<td>${order.BillToEmail}</td>
</tr>
<tr>
<td><div><strong>Order Number:</strong> </div></td>
<td><p>$order.OrderId</p></td>
</tr>
<tr>
<td><div><strong>Ordered on:</strong></div></td>
<td>$order.OrderDate.ToString("G")</td>
</tr>
<tr>
<td><div><strong>Ordered by:</strong></div></td>
<td>$order.BillToFirstName $order.BillToLastName</td>
</tr>
<tr>
<td><div><strong>Order Total:</strong></div></td>
<td>$order.Items.TotalPriceById().ToString("C")</td>
</tr>
<tr>
<td><div><strong>Order Status:</strong></div></td>
<td><a>View Online</a></td>
</tr>
</table>
<table>
<tr>
<td><strong>Billing Address:</strong>
<div>
$order.FormatAddress(true)
</div>
</td>
<td>
<strong>Payment Method:</strong>
<div>
#foreach($payment in $payments)
$payment.PaymentMethodName<br>
$payment.ReferenceNumber<br>
#end
</div>
</td>
</tr>
</table>
#set ($shipNo = 1)
#foreach($shipment in $order.Shipments)
#beforeall
<table>
<tr>
<th>Shipment Information</th>
</tr>
</table>
#each
<table>
<tr>
<td>
<strong><u>Shipment $shipNo of $order.Shipments.Count</u></strong>
#set ($shipNo = $shipNo + 1)
</td>
</tr>
<tr>
<td>
<table>
<tr>
<td>
<strong>Ship From:</strong>
<div>
$shipment.FormatFromAddress(true)
</div>
</td>
<td>
<strong>Ship To:</strong>
<div>
$shipment.FormatToAddress(true)
#if ($shipment.ShipMessage.Length > 0)
<br><strong>Message:</strong>$shipment.ShipMessage
#end
</div>
</td>
<td>
<strong>Shipment Method:</strong>
<div>
$shipment.ShipMethodName</div>
<strong>Shipment Status:</strong>
<div>
#if ($shipment.IsShipped)
Shipped
#else
Waiting to ship
#end
</div>
</td>
</tr>
</table>
</td>
</tr>
#foreach($orderItem in $order.Items.FilterByShipmentAndSort($shipment.OrderShipmentId))
#beforeall
<tr>
<td><strong>SKU</strong></td>
<td><strong>Description</strong></td>
<td><strong>Quantity</strong></td>
<td><strong>Price</strong></td>
</tr>
#each
#if (($orderItem.OrderItemType == "Product") || ($orderItem.OrderItemType == "Discount") || ($orderItem.OrderItemType == "GiftWrap") )
<tr>
<td>
#if (($orderItem.OrderItemType == "Product"))
$orderItem.Sku
#elseif (($orderItem.OrderItemType == "Discount"))
DISCOUNT
#elseif (($orderItem.OrderItemType == "GiftWrap"))
GIFTWRAP
#end
</td>
<td>
$orderItem.Name
#if ($orderItem.VariantName.Length > 0)
($orderItem.VariantName)
#end
#if ($orderItem.WrapStyle)
<br>
Gift-Wrap: $orderItem.WrapStyle.Name
#end
</td>
<td>$orderItem.Quantity</td>
<td>$orderItem.ExtendedPrice.ToString("C")</td>
</tr>
#end
#end
<tr><td> </td>
</tr>
</table>
#end
<Output>
#foreach($orderItem in $order.Items.FilterByShipmentAndSort())
#beforeall
<table>
<tr>
<th>Non-Shipping Items</th>
</tr>
</table>
<table>
<tr>
<td><strong>SKU</strong></td>
<td><strong>Name</strong></td>
<td><strong>Price</strong></td>
<td><strong>Quantity</strong></td>
<td><strong>Total</strong></td>
</tr>
#each
#if (($orderItem.OrderItemType == "Product"))
<tr>
<td>$orderItem.Sku</td>
<td>
$orderItem.Name
#if ($orderItem.VariantName.Length > 0)
($orderItem.VariantName)
#end
</td>
<td>$orderItem.Price.ToString("C")</td>
<td>$orderItem.Quantity</td>
<td>$orderItem.ExtendedPrice.ToString("C")</td>
</tr>
#end
#afterall
</table>
#end
<table>
<tr>
<th>Order Totals</th>
</tr>
</table>
<table>
<tr>
<td>
<strong>Subtotal:</strong>
</td>
<td>
$order.Items.TotalPriceById(0).ToString("C")
</td>
<td><p><strong>Thanks again for shopping with us!</strong></p>
<p><a><strong>$store.Name</strong></a></p></td>
</tr>
<tr>
<td>
<strong>Tax:</strong>
</td>
<td>
$order.Items.TotalPriceById(3).ToString("C")
</td>
</tr>
<tr>
<td>
<strong>Shipping and Handling:</strong>
</td>
<td>
$order.Items.TotalPriceById(1, 2).ToString("C")
</td>
</tr>
<tr>
<td>
<strong>Discounts:</strong>
</td>
<td>
$order.Items.TotalPriceById(4).ToString("C")
</td>
</tr>
<tr>
<td>
<strong>Total:</strong>
</td>
<td>
$order.Items.TotalPriceById().ToString("C")
</td>
</tr>
</table>
<p> </p>
</body>
</html>
.
Posted: Thu Feb 14, 2008 6:19 am
by batmike
I made a note below where to put the code if you want it to show right below the Shipment Status in the template. If you wanted it somewhere else, you could move it around as you wanted. Otherwise, this will work great. It's about in the middle of the code below.
Mike
<html>
<head>
<style>
TABLE.Email {
width: 640px;
padding: 5px;
margin: 0px;
border: 1px solid #5872CB;
}
TABLE.Email TH {
font-weight: bold;
font-size: 12px;
color: #ffffff;
font-family: Arial, Verdana, Sans-Serif;
font-style: strong;
background-color: #304FBA;
text-align: center;
text-decoration: none;
padding: 5px;
}
TABLE.Email TD {
font-weight: normal;
font-size: 12px;
color: #000000;
font-family: Arial, Verdana, Sans-Serif;
background-color: #ffffff;
text-align: left;
text-decoration: none;
padding: 3px;
}
</style>
</head>
<body>
<table>
<tr>
<td>
<p><strong>Hello $order.BillToFirstName, </strong></p>
<p> We thought you'd like to know that we shipped your items, and that
this
completes your order.</p>
<p>If you would like to view your order, manage addresses, update your email,
or customize many other options, please visit your personal
<a>My Account</a> page.</p>
<p>Thank you for shopping with us.<br>
$store.Name</p>
</td>
</tr>
</table>
<table>
<tr>
<th>Order Summary</th>
</tr>
</table>
<table>
<tr>
<td><div><strong>Email Address:</strong></div></td>
<td>${order.BillToEmail}</td>
</tr>
<tr>
<td><div><strong>Order Number:</strong> </div></td>
<td><p>$order.OrderId</p></td>
</tr>
<tr>
<td><div><strong>Ordered on:</strong></div></td>
<td>$order.OrderDate.ToString("G")</td>
</tr>
<tr>
<td><div><strong>Ordered by:</strong></div></td>
<td>$order.BillToFirstName $order.BillToLastName</td>
</tr>
<tr>
<td><div><strong>Order Total:</strong></div></td>
<td>$order.Items.TotalPriceById().ToString("C")</td>
</tr>
<tr>
<td><div><strong>Order Status:</strong></div></td>
<td><a>View Online</a></td>
</tr>
</table>
<table>
<tr>
<td><strong>Billing Address:</strong>
<div>
$order.FormatAddress(true)
</div>
</td>
<td>
<strong>Payment Method:</strong>
<div>
#foreach($payment in $payments)
$payment.PaymentMethodName<br>
$payment.ReferenceNumber<br>
#end
</div>
</td>
</tr>
</table>
#set ($shipNo = 1)
#foreach($shipment in $order.Shipments)
#beforeall
<table>
<tr>
<th>Shipment Information</th>
</tr>
</table>
#each
<table>
<tr>
<td>
<strong>Shipment $shipNo of $order.Shipments.Count</strong>
#set ($shipNo = $shipNo + 1)
</td>
</tr>
<tr>
<td>
<table>
<tr>
<td>
<strong>Ship From:</strong>
<div>
$shipment.FormatFromAddress(true)
</div>
</td>
<td>
<strong>Ship To:</strong>
<div>
$shipment.FormatToAddress(true)
#if ($shipment.ShipMessage.Length > 0)
<br><strong>Message:</strong>$shipment.ShipMessage
#end
</div>
</td>
<td>
<strong>Shipment Method:</strong>
<div>
$shipment.ShipMethodName</div>
<strong>Shipment Status:</strong>
<div>
#if ($shipment.IsShipped)
Shipped
#else
Waiting to ship
#end
</div>
-----------------------------------> RIGHT HERE
</td>
</tr>
</table>
</td>
</tr>
#foreach($orderItem in $order.Items.FilterByShipmentAndSort($shipment.OrderShipmentId))
#beforeall
<tr>
<td><strong>SKU</strong></td>
<td><strong>Description</strong></td>
<td><strong>Quantity</strong></td>
<td><strong>Price</strong></td>
</tr>
#each
#if (($orderItem.OrderItemType == "Product") || ($orderItem.OrderItemType == "Discount") || ($orderItem.OrderItemType == "GiftWrap") )
<tr>
<td>
#if (($orderItem.OrderItemType == "Product"))
$orderItem.Sku
#elseif (($orderItem.OrderItemType == "Discount"))
DISCOUNT
#elseif (($orderItem.OrderItemType == "GiftWrap"))
GIFTWRAP
#end
</td>
<td>
$orderItem.Name
#if ($orderItem.VariantName.Length > 0)
($orderItem.VariantName)
#end
#if ($orderItem.WrapStyle)
<br>
Gift-Wrap: $orderItem.WrapStyle.Name
#end
</td>
<td>$orderItem.Quantity</td>
<td>$orderItem.ExtendedPrice.ToString("C")</td>
</tr>
#end
#end
<tr><td> </td>
</tr>
</table>
#end
<Output>
#foreach($orderItem in $order.Items.FilterByShipmentAndSort())
#beforeall
<table>
<tr>
<th>Non-Shipping Items</th>
</tr>
</table>
<table>
<tr>
<td><strong>SKU</strong></td>
<td><strong>Name</strong></td>
<td><strong>Price</strong></td>
<td><strong>Quantity</strong></td>
<td><strong>Total</strong></td>
</tr>
#each
#if (($orderItem.OrderItemType == "Product"))
<tr>
<td>$orderItem.Sku</td>
<td>
$orderItem.Name
#if ($orderItem.VariantName.Length > 0)
($orderItem.VariantName)
#end
</td>
<td>$orderItem.Price.ToString("C")</td>
<td>$orderItem.Quantity</td>
<td>$orderItem.ExtendedPrice.ToString("C")</td>
</tr>
#end
#afterall
</table>
#end
<table>
<tr>
<th>Order Totals</th>
</tr>
</table>
<table>
<tr>
<td>
<strong>Subtotal:</strong>
</td>
<td>
$order.Items.TotalPriceById(0).ToString("C")
</td>
<td><p><strong>Thanks again for shopping with us!</strong></p>
<p><a><strong>$store.Name</strong></a></p></td>
</tr>
<tr>
<td>
<strong>Tax:</strong>
</td>
<td>
$order.Items.TotalPriceById(3).ToString("C")
</td>
</tr>
<tr>
<td>
<strong>Shipping and Handling:</strong>
</td>
<td>
$order.Items.TotalPriceById(1, 2).ToString("C")
</td>
</tr>
<tr>
<td>
<strong>Discounts:</strong>
</td>
<td>
$order.Items.TotalPriceById(4).ToString("C")
</td>
</tr>
<tr>
<td>
<strong>Total:</strong>
</td>
<td>
$order.Items.TotalPriceById().ToString("C")
</td>
</tr>
</table>
<p> </p>
</body>
</html>
Re: Tracking numbers in shipment notifications
Posted: Mon Jul 20, 2009 4:39 pm
by saiho01
This is awesome, thanks for all showing us what AC7 is capable of. I am trying to implement this into our template as well. I made a some minor changes, and this is the code I am using:
Code: Select all
<p>Your product has shipped. Below is your tracking number, and you can click the number to follow your shipment:</p>
<BR>
#if($shipment.TrackingNumbers.Count > 0)
#if($shipment.ShipMethodId == 3 || $shipment.ShipMethodId==4 || $shipment.ShipMethodId==5)
#foreach($trackingNumber in $shipment.TrackingNumbers)
<strong>Tracking Number:</strong>
<div style="padding-left:30px;">
<a href="http://wwwapps.ups.com/WebTracking/processInputRequest?tracknum=${trackingNumber.TrackingNumberData}">$trackingNumber.TrackingNumberData</a>
#end
#elseif($shipment.ShipMethodId == 1 || $shipment.ShipMethodId==2 )
#foreach($trackingNumber in $shipment.TrackingNumbers)
<strong>Tracking Number:</strong>
<div style="padding-left:30px;">
<a href="http://trkcnfrm1.smi.usps.com/PTSInternetWeb/InterLabelInquiry.do?origTrackNum=${trackingNumber.TrackingNumberData}">$trackingNumber.TrackingNumberData</a> >$trackingNumber.TrackingNumberData</a>
#end
#end
#end
</div>
But somehow, the bold "Tracking Number:" and the hyperlinked tracking code is not showing up in the emails. Am I missing something here? Thank you in advance!
Re: Tracking numbers in shipment notifications
Posted: Tue Jul 21, 2009 4:38 am
by mazhar