Help with Email Template

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
butterscotch
Lieutenant (LT)
Lieutenant (LT)
Posts: 80
Joined: Fri Sep 19, 2008 11:39 am

Help with Email Template

Post by butterscotch » Tue Jun 28, 2011 5:16 pm

Hello,

This template used to work in our old version of ablecommerce, we're updating to 7.0.6 - this is the error message I get when I tried to test the email:

Some error has occurred while parsing email contents using nVelocity. Please fix the email Store Name Confirmation - Order Number $order.OrderId' before trying to send email. Error details:
Encountered "=" at line 258, column 46. Was expecting one of: ... "-" ... "+" ... "*" ... "/" ... "%" ... "&&" ... "||" ... "<" ... "<=" ... ">" ... ">=" ... "==" ... "!=" ...
Thank you!

Code: Select all

   
<html>
  <head>
    <style type="text/css">
    table.email {
      width: 550px;
      margin: 0;
      padding: 5px;
      border: 1px solid #5F54B9;
    }

    table.email td,
    table.email th {
      font: 12px arial, verdana, sans-serif;
      text-decoration: none;
    }

    table.email td {
      color: #000;
      background-color: #FFF;
      padding: 3px;
      text-align: left;
    }

    table.email th {
      color: #FFF;
      background-color: #49176D;
      font-weight: bold;
      padding: 5px;
      text-align: center;
    }
    </style>
  </head>
<body>
  <table class="email">
  <tr>
  <td colspan="2" class="email">
  <p><strong>Thank you for your order $order.BillToFirstName $order.BillToLastName !</strong></p>
  <p>If you would like to check the status of 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>
  </table>
  <table class="email">
  <tr>
  <th class="email">Order Summary</th>
  </tr>
  </table>
  <table class="email">
  <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><h2>$order.OrderId</h2></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>
    </table>
  <table class="email">
  <tr valign="top">
  <td class="email" width="50%"><strong>Billing Address:</strong>
  <div style="padding-left:30px;">
  $order.FormatAddress(true)
  <br/>Phone: $order.BillToPhone
  #if ($order.BillToCompany.Length > 0)
  <br/>Company: $order.BillToCompany
  #end
  </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>

  </table> 

 
  #set ($shipNo = 1)	
  #foreach($shipment in $order.Shipments)
  #beforeall
  <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>
  </td>
  </tr>
  <tr>
  <td class="email" colspan="4" style="text-align: center;">
  <table width="100%">
  <tr>
  <td class="email" valign="top">
  <strong>Ship To:</strong>
  <div style="padding-left:30px;">
  $shipment.FormatToAddress(true)
  <br/> Phone: $shipment.ShipToPhone
  #if ($shipment.ShipToCompany.Length > 0)
  <br/>Company: $shipment.ShipToCompany
  #end

  #if ($shipment.ShipMessage.Length > 0)
  <br/><strong>Ship Message:</strong> $shipment.ShipMessage
  #end
 

  </div>
  </td>
  <td class="email" valign="top">
  <strong>Shipment Method:</strong>
  <div style="padding-left:30px;">
  $shipment.ShipMethodName</div>
  <div style="padding-left:30px;"></div>
  </td>
  </tr>
      <tr>
          <td colspan="3" valign="top">
            <img src="${store.StoreUrl}/BarCode/${shipment.OrderId}-${shipNo}.bmp" alt="Bar Code" />
          </td>
      </tr>
  </table>	
  </td>
  </tr>
  #set ($shipNo = $shipNo + 1)	
  #set ($giftDisplayed = 0)
  #foreach($orderItem in $order.Items.FilterByShipmentAndSort($shipment.OrderShipmentId))
  #beforeall  
  <tr>
  <td style="background:#cccccc; color:#00000; text-align: center;"><strong>SKU</strong></td>
  <td style="background:#cccccc; color:#00000; text-align: center;"><strong>Description</strong></td>
  <td style="background:#cccccc; color:#00000; text-align: center;"><strong>Quantity</strong></td>
  <td style="background:#cccccc; color:#00000; text-align: center;"><strong>Price</strong></td>
  </tr>
  #each
  #if (($orderItem.OrderItemType == "Product") || ($orderItem.OrderItemType == "Discount") || ($orderItem.OrderItemType == "GiftWrap") || ($orderItem.OrderItemType == "Coupon"))
  <tr class="email">
  <td class="email" style="text-align: center;">
    #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.LineMessage.Length > 0)
  ($orderItem.LineMessage)
  #end
  #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("C")</td>
  </tr>#end    #if ($orderItem.GiftMessage.Length > 0 && $giftDisplayed ==0))    <strong>Gift Message</strong>: $orderItem.GiftMessage    #set ($giftDisplayed = 1)    #end    #end 
  <tr class="email"><td colspan="4"> #if ($orderItem.GiftMessage.Length > 0 && $giftDisplayed ==0)
  <strong>Gift Message</strong>: $orderItem.GiftMessage
  #set ($giftDisplayed = 1)
  #end</td>
  </tr>
  </table>		
  #end	
  <!-- Output Non-Shipping Items -->
  #foreach($orderItem in $order.Items.FilterByShipmentAndSort())
  #beforeall
  <table class="email">
  <tr>
  <th class="email">Non-Shipping Items</th>
  </tr>
  </table>		
<table class="email">
  <tr>
  <td style="background:#cccccc; color:#00000; text-align: center;"><strong>SKU</strong></td>
  <td style="background:#cccccc; color:#00000; text-align: center;"><strong>Name</strong></td>
  <td style="background:#cccccc; color:#00000; text-align: center;"><strong>Price</strong></td>
  <td style="background:#cccccc; color:#00000; text-align: center;"><strong>Quantity</strong></td>
  <td style="background:#cccccc; color:#00000; text-align: center;"><strong>Total</strong></td>
  </tr>
  #each
  #if (($orderItem.OrderItemType == "Product"))
  <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("C")</td>
  <td class="email" style="text-align: center;">$orderItem.Quantity</td>
  <td class="email" style="text-align: right;">$orderItem.ExtendedPrice.ToString("C")</td>
  </tr>
  #end
  #afterall
  </table>		
  #end 
  <table class="email">
  <tr>
  <th class="email" colspan="3">Order Totals</th>
  </tr>
  <tr>
  <td width="40%" style="background:#cccccc; color:#00000; text-align: right;">
  <strong>Subtotal:</strong>
  </td>
  <td width="15%" class="email" style="text-align: right;">
  $order.Items.TotalPriceById(0).ToString("C") 
  </td>
  <td width="55%" rowspan="8"><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="background:#cccccc; color:#00000; text-align: right;">
  <strong>Tax:</strong>
  </td>
  <td width="15%" class="email" style="text-align: right;">
  $order.Items.TotalPriceById(3).ToString("C")
  </td>
  </tr>
    
    #if($order.Items.TotalPriceById(1, 2, 6) = "0")
    
    #else
  <tr>
  <td width="40%" style="background:#cccccc; color:#00000; text-align: right;">
  <strong>Shipping and Handling:</strong>
  </td>
  <td width="15%" class="email" style="text-align: right;">
  $order.Items.TotalPriceById(1, 2, 6).ToString("C")
  </td>
  </tr>
  #end
  
  #if($order.Items.TotalPriceById(5) = "0")
  
  #else
  <tr>
  <td width="40%" style="background:#cccccc; color:#00000; text-align: right;">
  <strong>Coupons:</strong>
  </td>
  <td width="15%" class="email" style="text-align: right;">
  $order.Items.TotalPriceById(5).ToString("C")
  </td>
 

<div style="display: none;">$order.Items.TotalPriceById(4, 5).ToString("C")</div> 


  </tr>	
  #end
  
  #if($order.Items.TotalPriceById(4) = "0")
  
  #else
  <tr>
  
  <td width="40%" style="background:#cccccc; color:#00000; text-align: right;">
  <strong>Discounts:</strong>
  </td>
  <td width="15%" class="email" style="text-align: right;">
  $order.Items.TotalPriceById(4).ToString("C")
  </td>
 

<div style="display: none;">$order.Items.TotalPriceById(4, 5).ToString("C") </div>


  </tr>	
  
  #end
  <tr>
  <td width="30%" style="background:#cccccc; color:#00000; text-align: right;">
  <strong>Total:</strong>
  </td>
  <td width="15%" class="email" style="text-align: right;">
  $order.Items.TotalPriceById().ToString("C")
  </td>
  </tr>
  </table>
  </body>
</html>[code]   

User avatar
s_ismail
Commander (CMDR)
Commander (CMDR)
Posts: 162
Joined: Mon Nov 09, 2009 12:20 am
Contact:

Re: Help with Email Template

Post by s_ismail » Wed Jun 29, 2011 5:23 am

I guess something is missing in your template.
Use this one

Code: Select all

<html>
<head>
<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>
</head>
<body>
<table class="Email">
<tr>
<td colspan="2" class="Email">
<p><strong>Thank you for your order $order.BillToFirstName $order.BillToLastName !</strong></p>
<p>If you would like to check the status of 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>
</table>
<table class="Email">
<tr>
<th class="Email">Order Summary</th>
</tr>
</table>
<table class="Email">
<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>
</table>
<table class="Email">
<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>
</table>  
#set ($shipNo = 1)	
#foreach($shipment in $order.Shipments)
#beforeall
<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>
<div style="padding-left:30px;"></div>
</td>
</tr>
</table>	
</td>
</tr>
#foreach($orderItem in $order.Items.FilterByShipmentAndSort($shipment.OrderShipmentId))
#beforeall  
<tr>
<td style="background:#cccccc; color:#00000; text-align: center;"><strong>SKU</strong></td>
<td style="background:#cccccc; color:#00000; text-align: center;"><strong>Description</strong></td>
<td style="background:#cccccc; color:#00000; text-align: center;"><strong>Quantity</strong></td>
<td style="background:#cccccc; color:#00000; text-align: center;"><strong>Price</strong></td>
</tr>
#each
#if ((($orderItem.OrderItemType == "Product") || ($orderItem.OrderItemType == "Discount") || ($orderItem.OrderItemType == "Coupon") || ($orderItem.OrderItemType == "GiftWrap")) && !$orderItem.IsHidden)
<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
#if ($orderItem.GiftMessage.Length > 0)
<br>
Gift Message: $orderItem.GiftMessage
#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
#end
<tr class="Email"><td colspan="4">&nbsp;</td>
</tr>
</table>		
#end	
<!-- Output Non-Shipping Items -->
#foreach($orderItem in $order.Items.FilterByShipmentAndSort())
#beforeall
<table class="Email">
<tr>
<th class="Email">Non-Shipping Items</th>
</tr>
</table>		
<table class="Email">
<tr>
<td style="background:#cccccc; color:#00000; text-align: center;"><strong>SKU</strong></td>
<td style="background:#cccccc; color:#00000; text-align: center;"><strong>Name</strong></td>
<td style="background:#cccccc; color:#00000; text-align: center;"><strong>Price</strong></td>
<td style="background:#cccccc; color:#00000; text-align: center;"><strong>Quantity</strong></td>
<td style="background:#cccccc; color:#00000; text-align: center;"><strong>Total</strong></td>
</tr>
#each
#if ((($orderItem.OrderItemType == "Product") || ($orderItem.OrderItemType == "Coupon") || ($orderItem.OrderItemType == "Discount")) && !$orderItem.IsHidden)
<tr>
<td class="Email" style="text-align: center;">
#if (($orderItem.OrderItemType == "Product"))
$orderItem.Sku
#elseif (($orderItem.OrderItemType == "Discount"))
DISCOUNT
#elseif (($orderItem.OrderItemType == "Coupon"))
COUPON
#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
</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
#afterall
</table>		
#end 
#foreach ($gc in $order.GiftCertificates)
#beforeall
<table class="Email">
<tr>
<th class="Email" >Gift Certificates</th>
</tr>
</table>
<table class="Email">
<tr>
<td style="background:#cccccc; color:#00000; text-align: center;"  ><strong>Name</strong></td>
<td style="background:#cccccc; color:#00000; text-align: center;" ><strong>Status</strong></td>				
</tr>
#each
<tr class="Email">
<td class="Email" style="text-align: left;"  >
<a href="${store.StoreUrl}Members/MyGiftCertificate.aspx?GiftCertificateId=$gc.GiftCertificateId">$gc.Name</a>
</td>
<td class="Email" style="text-align: left;" >
#if($gc.Transactions.Count > 0)
#set ($lastIndex = $gc.Transactions.Count - 1)
#set ($transaction = $gc.Transactions.get_item(${lastIndex}))
$transaction.Description.ToString()
#end
</td>
</tr>
#afterall
</table>
#end
<table class="Email">
<tr>
<th class="Email">Order Totals</th>
</tr>
</table>
<table class="Email">
<tr>
<td width="40%" style="background:#cccccc; color:#00000; text-align: right;">
<strong>Subtotal:</strong>
</td>
<td width="15%" class="Email" style="text-align: right;">
$order.Items.TotalPriceById(0).ToString("ulc")
</td>
<td width="55%" rowspan="5"><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="background:#cccccc; color:#00000; text-align: right;">
<strong>Tax:</strong>
</td>
<td width="15%" class="Email" style="text-align: right;">
$order.Items.TotalPriceById(3).ToString("ulc")
</td>
</tr>
<tr>
<td width="40%" style="background:#cccccc; color:#00000; text-align: right;">
<strong>Shipping and Handling:</strong>
</td>
<td width="15%" class="Email" style="text-align: right;">
$order.Items.TotalPriceById(1, 2).ToString("ulc")
</td>
</tr>
<tr>
<td width="40%" style="background:#cccccc; color:#00000; text-align: right;">
<strong>Discounts:</strong>
</td>
<td width="15%" class="Email" style="text-align: right;">
$order.Items.TotalPriceById(4).ToString("ulc")
</td>
</tr>	
<tr>
<td width="40%" style="background:#cccccc; color:#00000; text-align: right;">
<strong>Coupons:</strong>
</td>
<td width="15%" class="Email" style="text-align: right;">
$order.Items.TotalPriceById(5).ToString("ulc")
</td>
</tr>
<tr>
<td width="30%" style="background:#cccccc; color:#00000; text-align: right;">
<strong>Total:</strong>
</td>
<td width="15%" class="Email" style="text-align: right;">
$order.Items.TotalPriceById().ToString("ulc")
</td>
</tr>
</table>
<p>&nbsp;</p>
</body>
</html>



butterscotch
Lieutenant (LT)
Lieutenant (LT)
Posts: 80
Joined: Fri Sep 19, 2008 11:39 am

Re: Help with Email Template

Post by butterscotch » Wed Jun 29, 2011 11:41 am

Thank you! Your template worked!

Someone in-house figured that there were a lot of instances of "==" missing!!

Example- Incorrect
#if($order.Items.TotalPriceById(1, 2, 6) = "0")

Example Correct
The correct version should go #if($order.Items.TotalPriceById(1, 2, 6) == "0")

User avatar
s_ismail
Commander (CMDR)
Commander (CMDR)
Posts: 162
Joined: Mon Nov 09, 2009 12:20 am
Contact:

Re: Help with Email Template

Post by s_ismail » Thu Jun 30, 2011 9:00 am

Yes i have seen there were syntax errors. To fix them you must have nVelocity knowledge. AbleCommerce also provides help to understand nVelocity, Check it out
http://wiki.ablecommerce.com/index.php/NVelocity

Post Reply