I am getting an error after editing one of our email templates. Any thoughts? I had copied the code that we are using below and the error we are getting as well.
Some error has occurred while parsing email template. Please fix the email template 'In Customization Stage' before trying to send email. Error details:
Foreach directives must be the only items on the line (comments or contents are not allowed)
<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>
<p style="text-align: center"><img width="150" height="150" border="0" alt="" src="/Assets/XLOGO.jpg" /></p>
<table class="Email">
<tbody>
<tr>
<td class="Email" colspan="2">
<p><strong>Hello $order.BillToFirstName, </strong></p>
<p>We wanted to let you know that your order is now in the Customization Stage. For more information on personalization and customization, and when you should receive your order, click here.<br />
</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>
<p style="text-align: center"><em><strong><br />
Stay Connected With Multiplex Sports USA!</strong></em><a target="_blank" href="http://www.facebook.com/pages/Epsom-NH/ ... 44261"><br />
<img border="0" width="100" height="100" alt="" src="/Assets/facebook(2).jpg" /></a> <a target="_blank" href="http://www.twitter.com/mpxsports"><img border="0" width="100" height="100" alt="" src="/Assets/twitter_email.jpg" /></a></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.OrderNumber</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("ulc")</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?OrderNumber=$order.OrderNumber&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>
#set ($shipNo = 1)
<p>#foreach($shipment in $order.Shipments)
#beforeall
</p>
<table class="Email">
<tbody>
<tr>
<th class="Email">Shipment Information</th>
</tr>
</tbody>
</table>
#each
<table class="Email">
<tbody>
<tr>
<td class="Email" colspan="4" 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%">
<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>
#foreach($orderItem in $order.Items.FilterByShipmentAndSort($shipment.OrderShipmentId))
<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>
#each
<tr class="Email">
<td class="Email" style="text-align: center">
#if (($orderItem.OrderItemType == "Product"))
$orderItem.Sku
#elseif (($orderItem.OrderItemType == "Discount"))
DISCOUNT
#elseif (($orderItem.OrderItemType == "Coupon"))
COUPON
#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 class="Email" style="text-align: center">$orderItem.Quantity</td>
<td class="Email" style="text-align: right">$orderItem.ExtendedPrice.ToString("ulc")</td>
</tr>
#end
<tr class="Email">
<td colspan="4"> </td>
</tr>
</tbody>
</table>
#end
<!-- Output Non-Shipping Items -->
#foreach($orderItem in $order.Items.FilterByShipmentAndSort())
<p>#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>
#each
<tr>
<td class="Email" style="text-align: center">$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 class="Email" style="text-align: right">$orderItem.Price.ToString("ulc")</td>
<td class="Email" style="text-align: center">$orderItem.Quantity</td>
<td class="Email" style="text-align: right">$orderItem.ExtendedPrice.ToString("ulc")</td>
</tr>
#end
</tbody>
</table>
#end
<table class="Email">
<tbody>
<tr>
<th class="Email">Order Totals</th>
</tr>
</tbody>
</table>
<table class="Email">
<tbody>
<tr>
<td width="40%" style="text-align: right; background: #cccccc"><strong>Subtotal:</strong></td>
<td class="Email" width="15%" style="text-align: right">$order.Items.TotalPriceById(0).ToString("ulc")</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 width="40%" style="text-align: right; background: #cccccc"><strong>Tax:</strong></td>
<td class="Email" width="15%" style="text-align: right">$order.Items.TotalPriceById(3).ToString("ulc")</td>
</tr>
<tr>
<td width="40%" style="text-align: right; background: #cccccc"><strong>Shipping and Handling:</strong></td>
<td class="Email" width="15%" style="text-align: right">$order.Items.TotalPriceById(1, 2).ToString("ulc")</td>
</tr>
<tr>
<td width="40%" style="text-align: right; background: #cccccc"><strong>Discounts:</strong></td>
<td class="Email" width="15%" style="text-align: right">$order.Items.TotalPriceById(4).ToString("ulc")</td>
</tr>
<tr>
<td width="40%" style="text-align: right; background: #cccccc"><strong>Coupons:</strong></td>
<td class="Email" width="15%" style="text-align: right">$order.Items.TotalPriceById(5).ToString("ulc")</td>
</tr>
<tr>
<td width="30%" style="text-align: right; background: #cccccc"><strong>Total:</strong></td>
<td class="Email" width="15%" style="text-align: right">$order.Items.TotalPriceById().ToString("ulc")</td>
</tr>
</tbody>
</table>
<p> </p>
Foreach Error on email template. Help!
-
- Ensign (ENS)
- Posts: 14
- Joined: Sun Feb 01, 2009 7:05 pm
Re: Foreach Error on email template. Help!
It could be due to editing the template in FCK editor. Its a known issue that if you edit your Email template in FCK editor and save it back it corrupts NVelocity scritps. You should better first restore the default Email template and then add your changes into Email template directly via content text area having code instead of using FCK editor.
- hassonmike
- Lieutenant (LT)
- Posts: 76
- Joined: Tue Apr 19, 2011 2:13 pm
- Contact:
Re: Foreach Error on email template. Help!
This same thing has happened to me, 3 of my email templates have become corrupt. I have copied in known good backups of the email templates, but am still getting the same error...
AbleCommerce 7.0.3
AbleCommerce 7.0.3