Page 1 of 1

Shipping Notification ERROR! Someone help!

Posted: Fri Dec 19, 2008 11:03 am
by chalvorsen
What are we missing here?

Today our shipping notifications has started going out stating this ....

Foreach directives must be the only items on the line (comments or contents are not allowed)

This is our layout below. Any thoughts? Please help quickly if you can .... time is money! :D

<p><style type="text/css">
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></p>
<table class="Email">
<tbody>
<tr>
<td class="Email" colspan="2">
<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. If you chose to pickup your items at one of our stores, this email is to let you know your items are ready for pickup. Please check the store location hours or get directions by clicking <a href="http://www.mpxsports.com/locations.html">here</a>.<br />
&nbsp;</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 href="${store.StoreUrl}Members/MyAccount.aspx">My Account</a> page.</p>
<p>Thank you for shopping with us.<br />
$store.Name</p>
</td>
</tr>
</tbody>
</table>
<table class="Email">
<tbody>
<tr>
<th class="Email">Order Summary</th>
</tr>
</tbody>
</table>
<table class="Email">
<tbody>
<tr>
<td class="Email">
<div align="right"><strong>Email Address:</strong></div>
</td>
<td class="Email">${order.BillToEmail}</td>
</tr>
<tr>
<td class="Email" width="140">
<div align="right"><strong>Order Number:</strong></div>
</td>
<td class="Email" width="500">
<p>$order.OrderId</p>
</td>
</tr>
<tr>
<td class="Email">
<div align="right"><strong>Ordered on:</strong></div>
</td>
<td class="Email">$order.OrderDate.ToString("G")</td>
</tr>
<tr>
<td class="Email">
<div align="right"><strong>Ordered by:</strong></div>
</td>
<td class="Email">$order.BillToFirstName $order.BillToLastName</td>
</tr>
<tr>
<td>
<div align="right"><strong>Order Total:</strong></div>
</td>
<td>$order.Items.TotalPriceById().ToString("C")</td>
</tr>
<tr>
<td class="Email">
<div align="right"><strong>Order Status:</strong></div>
</td>
<td class="Email"><a href="${store.StoreUrl}Members/MyOrder.aspx?OrderId=$order.OrderId">View Online</a></td>
</tr>
</tbody>
</table>
<table class="Email">
<tbody>
<tr valign="top">
<td class="Email" width="50%"><strong>Billing Address:</strong>
<div style="padding-left: 30px">$order.FormatAddress(true)</div>
</td>
<td class="Email" width="50%"><strong>Payment Method:</strong>
<div style="padding-left: 30px">#foreach($payment in $payments) $payment.PaymentMethodName<br />
$payment.ReferenceNumber<br />
#end</div>
</td>
</tr>
</tbody>
</table>
<p>#set ($shipNo = 1) #foreach($shipment in $order.Shipments) #beforeall</p>
<table class="Email">
<tbody>
<tr>
<th class="Email">Shipment Information</th>
</tr>
</tbody>
</table>
<p>#each</p>
<table class="Email">
<tbody>
<tr>
<td style="text-align: center" class="Email" colspan="4"><strong><u>Shipment $shipNo of $order.Shipments.Count</u></strong> #set ($shipNo = $shipNo + 1)</td>
</tr>
<tr>
<td style="text-align: center" class="Email" colspan="4">
<table width="100%">
<tbody>
<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>
</tbody>
</table>
</td>
</tr>
<tr>
<td style="text-align: center; background: #cccccc"><strong>SKU</strong></td>
<td style="text-align: center; background: #cccccc"><strong>Description</strong></td>
<td style="text-align: center; background: #cccccc"><strong>Quantity</strong></td>
<td style="text-align: center; background: #cccccc"><strong>Price</strong></td>
</tr>
<tr class="Email">
<td style="text-align: center" class="Email">#if (($orderItem.OrderItemType == "Product")) $orderItem.Sku #elseif (($orderItem.OrderItemType == "Discount")) DISCOUNT #elseif (($orderItem.OrderItemType == "GiftWrap")) GIFTWRAP #end</td>
<td class="Email">$orderItem.Name #if ($orderItem.VariantName.Length > 0) ($orderItem.VariantName) #end #foreach($orderItemInput in $orderItem.Inputs) #if (!$orderItemInput.IsMerchantField) <br />
<b>$orderItemInput.Name:</b> $orderItemInput.InputValue #end #end #if ($orderItem.WrapStyle) <br />
Gift-Wrap: $orderItem.WrapStyle.Name #end</td>
<td style="text-align: center" class="Email">$orderItem.Quantity</td>
<td style="text-align: right" class="Email">$orderItem.ExtendedPrice.ToString("C")</td>
</tr>
<tr class="Email">
<td colspan="4">&nbsp;</td>
</tr>
</tbody>
</table>
<p>#end</p>
<!-- Output Non-Shipping Items -->
<p>#foreach($orderItem in $order.Items.FilterByShipmentAndSort()) #beforeall</p>
<table class="Email">
<tbody>
<tr>
<th class="Email">Non-Shipping Items</th>
</tr>
</tbody>
</table>
<table class="Email">
<tbody>
<tr>
<td style="text-align: center; background: #cccccc"><strong>SKU</strong></td>
<td style="text-align: center; background: #cccccc"><strong>Name</strong></td>
<td style="text-align: center; background: #cccccc"><strong>Price</strong></td>
<td style="text-align: center; background: #cccccc"><strong>Quantity</strong></td>
<td style="text-align: center; background: #cccccc"><strong>Total</strong></td>
</tr>
<tr>
<td style="text-align: center" class="Email">$orderItem.Sku</td>
<td class="Email">$orderItem.Name #if ($orderItem.VariantName.Length > 0) ($orderItem.VariantName) #end #foreach($orderItemInput in $orderItem.Inputs) #if (!$orderItemInput.IsMerchantField) <br />
<b>$orderItemInput.Name:</b> $orderItemInput.InputValue #end #end</td>
<td style="text-align: right" class="Email">$orderItem.Price.ToString("C")</td>
<td style="text-align: center" class="Email">$orderItem.Quantity</td>
<td style="text-align: right" class="Email">$orderItem.ExtendedPrice.ToString("C")</td>
</tr>
</tbody>
</table>
<p>#end</p>
<table class="Email">
<tbody>
<tr>
<th class="Email">Order Totals</th>
</tr>
</tbody>
</table>
<table class="Email">
<tbody>
<tr>
<td style="text-align: right; background: #cccccc" width="40%"><strong>Subtotal:</strong></td>
<td style="text-align: right" class="Email" width="15%">$order.Items.TotalPriceById(0).ToString("C")</td>
<td rowspan="5" width="55%">
<p align="center"><strong>Thanks again for shopping with us!</strong></p>
<p align="center"><a href="${store.StoreUrl}"><strong>$store.Name</strong></a></p>
</td>
</tr>
<tr>
<td style="text-align: right; background: #cccccc" width="40%"><strong>Tax:</strong></td>
<td style="text-align: right" class="Email" width="15%">$order.Items.TotalPriceById(3).ToString("C")</td>
</tr>
<tr>
<td style="text-align: right; background: #cccccc" width="40%"><strong>Shipping and Handling:</strong></td>
<td style="text-align: right" class="Email" width="15%">$order.Items.TotalPriceById(1, 2).ToString("C")</td>
</tr>
<tr>
<td style="text-align: right; background: #cccccc" width="40%"><strong>Discounts:</strong></td>
<td style="text-align: right" class="Email" width="15%">$order.Items.TotalPriceById(4).ToString("C")</td>
</tr>
<tr>
<td style="text-align: right; background: #cccccc" width="30%"><strong>Total:</strong></td>
<td style="text-align: right" class="Email" width="15%">$order.Items.TotalPriceById().ToString("C")</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>.</p>

Re: Shipping Notification ERROR! Someone help!

Posted: Fri Dec 19, 2008 11:57 am
by afm
I think this message is telling you to look for every "#foreach..." and make sure it is the only directive on the line. For example, change this

Code: Select all

#foreach($orderItemInput in $orderItem.Inputs) #if (!$orderItemInput.IsMerchantField)
to this

Code: Select all

#foreach($orderItemInput in $orderItem.Inputs)
#if (!$orderItemInput.IsMerchantField)
And this

Code: Select all

<p>#foreach($orderItem in $order.Items.FilterByShipmentAndSort()) #beforeall</p>
to this

Code: Select all

<p>
#foreach($orderItem in $order.Items.FilterByShipmentAndSort()) 
#beforeall
</p>

Re: Shipping Notification ERROR! Someone help!

Posted: Fri Dec 19, 2008 7:27 pm
by AbleMods
The problem is the editor. Someone edited your shipping notification email template and then saved it in source view. When that happens, the editor converts and reformats the template in such a way that it is rendered useless.

The first thing to fix is what AFM said: get the ForEach statements all on their own separate line. I think the IF statements have to be that way too.

The second is replace all the &gt with the ">" symbol. For some reason, the editor converts these symbols into url-safe equivalents and it shouldn't because it breaks the entire template. Basically look for anything that has that ampersand and see if it should be something like a ">" or "<" etc.

Honestly, it's *really* hard for me to clean it up once it's whacked out like that. I usually go to my local dev copy, copy the whole template from there and paste it back into my live template.

If you need the standard template again, I can copy/paste my default one here for you - just let me know. I feel your pain - this has happened to me many times.