Custom email templates
Custom email templates
I must be missing something very simple here.
Due to the highly custom nature of our products, we often send order acknowledgements to our customers. These emails spell out the order along with payment and warranty terms and conditions. Sales reps will send these out after reviewing the order contents.
I've been building the email templates and I'm stumped on two items. The email needs to include the sales reps name and I've trying to include this as:
Best regards,<br>
$user.Name<br>
$store.Name<br>
nVelocity is not converting $user.name to the name. I've tried $user.FirstName and $user.UserName with the same results. What I get in the email is the text '$user.name' Shouldn't this work anywhere in the store? Or have I botched the syntax somehow?
Additionally, we would like to include custom text based on the shipping method selected that includes average shipping times and potential customs verbiage. I'm guessing we'll need to create a scriptlet and call that from the email template?
Thanks so much.
Due to the highly custom nature of our products, we often send order acknowledgements to our customers. These emails spell out the order along with payment and warranty terms and conditions. Sales reps will send these out after reviewing the order contents.
I've been building the email templates and I'm stumped on two items. The email needs to include the sales reps name and I've trying to include this as:
Best regards,<br>
$user.Name<br>
$store.Name<br>
nVelocity is not converting $user.name to the name. I've tried $user.FirstName and $user.UserName with the same results. What I get in the email is the text '$user.name' Shouldn't this work anywhere in the store? Or have I botched the syntax somehow?
Additionally, we would like to include custom text based on the shipping method selected that includes average shipping times and potential customs verbiage. I'm guessing we'll need to create a scriptlet and call that from the email template?
Thanks so much.
Re: Custom email templates
Try $Order.user.nameWylieE wrote:$user.Name<br>
$store.Name<br>
nVelocity is not converting $user.name to the name. I've tried $user.FirstName and $user.UserName with the same results. What I get in the email is the text '$user.name' Shouldn't this work anywhere in the store? Or have I botched the syntax somehow?
Scriptlets cannot be called from email templates. However you can do some customer IF-THEN commands in the email templates via nVelocity. Look at some of the templates and you'll see how the syntax is done.Additionally, we would like to include custom text based on the shipping method selected that includes average shipping times and potential customs verbiage. I'm guessing we'll need to create a scriptlet and call that from the email template?
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com
Re: Custom email templates
You can get the user name from user or order object as below.
The above code will show store user name which will be the Email address of the user. if you want to show full name the composition of first and last name then it will be as below
Code: Select all
$user.UserName
or
$order.User.UserName
Code: Select all
$user.PrimaryAddress.FirstName $user.PrimaryAddress.LastName
or
$order.User.PrimaryAddress.FirstName $order.User.PrimaryAddress.LastName
Re: Custom email templates
Excellent. $order.User.UserName worked just fine.
Have a great day folks!
Have a great day folks!
Re: Custom email templates
OK, now I'm really starting to scratch my head. I'm working on the shipping text. I've taken a copy of the Customer Order Notification and added this to the top:
<html>
<p><b>Order Acknowledgement<br>
(Confirmation Request)</b></p>
<p>Dear $order.BillToFirstName,</p>
<p>Thank you very much for your order, # $order.OrderId. To better assure accuracy and your satisfaction, we would like your confirmation before we start production. Please carefully review the details of your order below and respond with your confirmation or with any changes you might require. This is your last opportunity to make changes freely. We will await your confirmation before we go to production. <br>
Please note that custom work is not refundable, but it is fully covered by our warranty.
</p>
<p><i>Payment Terms:</i> After we have received your confirmation we will charge your credit card for the Order Total shown below then we will begin production. Please verify that you have the funds available on your credit card before you confirm the order.</p>
<p><i>Ship Method: </i> $shipment.ShipMethodName</p>
<p><i>Estimated production time:</i> Eight to ten weeks from receipt of your confirmation.</p>
<p>Please let me know if you have any questions or further needs. I will be glad to help. <br>
I look forward to your reply.</p>
<p>Best regards,<br>
$order.user.PrimaryAddress.FirstName $order.user.PrimaryAddress.LastName <br>
$store.Name</p>
The order notification template uses the $shipment.ShipMethodName field. I just copied the field and added it to the new text but it doesn't resolve. It works properly in the order notification code chunk, but not in the text I've added. I've also tried it as ${shipment.ShipMethodName} and it doesn't work either. I've also tried $shipment.ShipMethodID with no results. I'm guessing I'm missing something simple????? But I can't find it, argh! What do I need to change?
<html>
<p><b>Order Acknowledgement<br>
(Confirmation Request)</b></p>
<p>Dear $order.BillToFirstName,</p>
<p>Thank you very much for your order, # $order.OrderId. To better assure accuracy and your satisfaction, we would like your confirmation before we start production. Please carefully review the details of your order below and respond with your confirmation or with any changes you might require. This is your last opportunity to make changes freely. We will await your confirmation before we go to production. <br>
Please note that custom work is not refundable, but it is fully covered by our warranty.
</p>
<p><i>Payment Terms:</i> After we have received your confirmation we will charge your credit card for the Order Total shown below then we will begin production. Please verify that you have the funds available on your credit card before you confirm the order.</p>
<p><i>Ship Method: </i> $shipment.ShipMethodName</p>
<p><i>Estimated production time:</i> Eight to ten weeks from receipt of your confirmation.</p>
<p>Please let me know if you have any questions or further needs. I will be glad to help. <br>
I look forward to your reply.</p>
<p>Best regards,<br>
$order.user.PrimaryAddress.FirstName $order.user.PrimaryAddress.LastName <br>
$store.Name</p>
The order notification template uses the $shipment.ShipMethodName field. I just copied the field and added it to the new text but it doesn't resolve. It works properly in the order notification code chunk, but not in the text I've added. I've also tried it as ${shipment.ShipMethodName} and it doesn't work either. I've also tried $shipment.ShipMethodID with no results. I'm guessing I'm missing something simple????? But I can't find it, argh! What do I need to change?
Re: Custom email templates
That's because there is no $shipment available in your custom template. In the Order notification the $shipment is extracted by looping through the available shipments for that order. In order to make it work in your custom Email template try the following code
Code: Select all
#foreach($shipment in $order.Shipments)
p><i>Ship Method: </i> $shipment.ShipMethodName</p>
#end
Re: Custom email templates
Ah, that helps. Thank you very much.
I've been trying to nest an If/elseif/end statement inside the #foreach loop and nVelocity doesn't seem to like that.
Example:
#foreach($shipment in $order.Shipments)
<p><i>Ship Method: </i>
#{If} ($shipment.ShipMethodName =="UPS Ground")
After we ship your order UPS will email you with the tracking number.
#{end}</p>
#end
I'm getting a error when attempting to send the email: Encountered "#end\r\n" at line 17, column 1. This only happens when I add the if/then code. I'm guessing the #foreach statement is grabbing the first #end statement and leaving the #if unterminated. I've dug through several of the templates and have yet to find an example of nested statements like this.
Edit: Encapsulating the if/end in brackets eliminates the error, but then the code is not interpreted.
I've been trying to nest an If/elseif/end statement inside the #foreach loop and nVelocity doesn't seem to like that.
Example:
#foreach($shipment in $order.Shipments)
<p><i>Ship Method: </i>
#{If} ($shipment.ShipMethodName =="UPS Ground")
After we ship your order UPS will email you with the tracking number.
#{end}</p>
#end
I'm getting a error when attempting to send the email: Encountered "#end\r\n" at line 17, column 1. This only happens when I add the if/then code. I'm guessing the #foreach statement is grabbing the first #end statement and leaving the #if unterminated. I've dug through several of the templates and have yet to find an example of nested statements like this.
Edit: Encapsulating the if/end in brackets eliminates the error, but then the code is not interpreted.
Last edited by WylieE on Wed Nov 05, 2008 6:08 pm, edited 1 time in total.
Re: Custom email templates
On a related note, I'm also working on an order summary for our sales staff. They would like to see the payments including credit card amount and authorization number.
The Customer Order Notification template includes payment method and I copied that block. However, I've noticed nothing is being returned from the Customer Order Notification.
#foreach($payment in $payments)
$payment.PaymentMethodName<br />
$payment.ReferenceNumber<br />
#end
I've tried several orders that have payments and none of them are displaying the payment method or reference number. Can anyone confirm this email template is working for them? This is turning in to one of those days when nothing works right....
The Customer Order Notification template includes payment method and I copied that block. However, I've noticed nothing is being returned from the Customer Order Notification.
#foreach($payment in $payments)
$payment.PaymentMethodName<br />
$payment.ReferenceNumber<br />
#end
I've tried several orders that have payments and none of them are displaying the payment method or reference number. Can anyone confirm this email template is working for them? This is turning in to one of those days when nothing works right....
Re: Custom email templates
Try the following codeAh, that helps. Thank you very much.
I've been trying to nest an If/elseif/end statement inside the #foreach loop and nVelocity doesn't seem to like that.
Example:
#foreach($shipment in $order.Shipments)
<p><i>Ship Method: </i>
#{If} ($shipment.ShipMethodName =="UPS Ground")
After we ship your order UPS will email you with the tracking number.
#{end}</p>
#end
I'm getting a error when attempting to send the email: Encountered "#end\r\n" at line 17, column 1. This only happens when I add the if/then code. I'm guessing the #foreach statement is grabbing the first #end statement and leaving the #if unterminated. I've dug through several of the templates and have yet to find an example of nested statements like this.
Edit: Encapsulating the if/end in brackets eliminates the error, but then the code is not interpreted.
Code: Select all
#foreach($shipment in $order.Shipments)
<p>
<i>Ship Method: </i>
#if($shipment.ShipMethodName == "Your Shipping Method Name")
Your Custom Message Here
#end
</p>
#end
Re: Custom email templates
Make sure that $payments is available in the template or you can just try the following code by extracting the $payment from $order.Payments as belowOn a related note, I'm also working on an order summary for our sales staff. They would like to see the payments including credit card amount and authorization number.
The Customer Order Notification template includes payment method and I copied that block. However, I've noticed nothing is being returned from the Customer Order Notification.
#foreach($payment in $payments)
$payment.PaymentMethodName<br />
$payment.ReferenceNumber<br />
#end
I've tried several orders that have payments and none of them are displaying the payment method or reference number. Can anyone confirm this email template is working for them? This is turning in to one of those days when nothing works right....
Code: Select all
#foreach($payment in $order.Payments)
$payment.PaymentMethodName<br />
$payment.ReferenceNumber<br />
#end
Re: Custom email templates
I think I might be getting a clue here... I also need to show the payment authorization number, which is in the transactions table. Do I need to nest another #foreach inside the one above in order to retrieve the auth# in the transactions table?mazhar wrote:Make sure that $payments is available in the template or you can just try the following code by extracting the $payment from $order.Payments as belowOn a related note, I'm also working on an order summary for our sales staff. They would like to see the payments including credit card amount and authorization number.
Code: Select all
#foreach($payment in $order.Payments) $payment.PaymentMethodName<br /> $payment.ReferenceNumber<br /> #end
Re: Custom email templates
Yes if the $transactions is not available then you can loop through the $payment.Transactions and extract $transaction.
Re: Custom email templates
Apologies for so many follow-up questions. I thought I was getting the hang of this.mazhar wrote:Yes if the $transactions is not available then you can loop through the $payment.Transactions and extract $transaction.
Code: Select all
#foreach($transactions in $payments.Transactions)
$transactions.AuthorizationNumber
#end
I've been through the AC wiki, the forums here and the Apache nVelocity site looking at code examples and docs. What I don't see is documentation on the field names. Are most users going through the .Net pages to find the fields?
Re: Custom email templates
You can access following variables with $transaction
Code: Select all
Amount
AuthorizationCode
AVSResultCode
CAVResultCode
CVVResultCode
Re: Custom email templates
NVelocity code just contains the object we pushed in the parameters. For example if the we talk about the order parameter that actually contains the CommerceBuilder.Orders.Order object. You can easily check that what this object will contain using the Visual Studio. For example if you want to know about the data contained by order object.I've been through the AC wiki, the forums here and the Apache nVelocity site looking at code examples and docs. What I don't see is documentation on the field names. Are most users going through the .Net pages to find the fields?
1)- Click the Object Browser from the View menu of Visual Studio.
2)- In the Object Browser left sidebar select the CommerceBuilder.Orders Namespace.
3)- Select the Order class in the sidebar and it will list all the information about class.
If some one is not using the Visual Studio then he can get the same information through API documentation available here.
ftp://ftp.ablecommerce.com/evals/Commer ... 7_Help.zip
- BryanWarmoth
- Lieutenant, Jr. Grade (LT JG)
- Posts: 44
- Joined: Fri May 23, 2008 11:24 am
- Location: Puyallup, Wa
- Contact:
Re: Custom email templates
Is it possible to send our own parameters to the email template as well? We have another object that we would like to send with the order object for the order confirmation email. If it is possible, where should i add the code to pass our own object to the email?
Re: Custom email templates
For this you have to send your Email manually as below
viewtopic.php?f=42&t=8571
You can place the code for this in the Load function of the RecieptPage.
viewtopic.php?f=42&t=8571
You can place the code for this in the Load function of the RecieptPage.
Re: Custom email templates
A most suitable place for this is the CheckedOut method of the ConLib/OnePageCheckout control.
- BryanWarmoth
- Lieutenant, Jr. Grade (LT JG)
- Posts: 44
- Joined: Fri May 23, 2008 11:24 am
- Location: Puyallup, Wa
- Contact:
Re: Custom email templates
Worked perfectly! Thanks!