Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 03-13-2005 10:38:03

Blitzen
Member
From: USA
Registered: 01-01-2005
Posts: 936

Email Templates

To streamline his e-business, my client needed several email templates that he can edit before sending to the customer. Here is our solution.

The template is selected from the email form page. If the email form is accessed from the Manage/Edit Invoice page (below the Billing Email link), then the customer's email address will be automatically completed on the email form.

You will notice that I had to give the form a name for this to work. Other form elements were cleverly named by the Click Cart Pro programmers. You can add more templates by adding Javascript functions and links for each email template design. In the script, remember to include the preceeding "\" whenever you need a Javascript reserved character such as a quote mark.

I now would like to know how to send the customer information (order number, cart contents, etc.) from the View/Edit Invoices to the email form. Any advice will be greatly appreciated.

Email Template Mod Follows.

data/elements/adm_mail_contact.txt

Code:

<p>Complete the information below to send a contact message.<br>All fields are required.
<script language="javascript" type="text/javascript">
<!--
function orderShipped() {
document.emailForm.subject.value="Order Shipped from MyStore.com";
document.emailForm.message.value="Dear Customer,\n\nWe thought that you would like to know that your order shipped. You may track it at http://www.UPS.com with the tracking number\n\n\n\nBest Regards,\nwww.MyStore.com";
}
function discontinued() {
document.emailForm.subject.value="Discontinued Color - MyStore.com";
document.emailForm.message.value="Dear Customer,\n\nThe color of an item that you ordered from MyStore.com has been discontinued.\nTo select a substitute color, please visit www.MyStore.com to select a different color.\n\nA credit for the amount of [ENTER CREDIT HERE] will be applied when you checkout with the Coupon Code, \"XPLGT\". We apologize for this inconvenience.\n\nBest Regards,\nwww.MyStore.com";
}
//-->
</script>
<a name="a"></a>
<p><b>Select a template from the list below.</b></p>
<p><a href="#a" onClick="orderShipped();">Order Shipped</a></p>
<p><a href="#a" onClick="discontinued();">Discontinued Item</a></p>

<form method="POST" action="(CGIVAR)common_url_form(/CGIVAR)" name="emailForm">
(CGIVAR)common_hidden_fields(/CGIVAR)
<input type="HIDDEN" name="pg" value="contact_proc">
<table width="100%" border="0" cols="2" cellpadding="1" cellspacing="3" align="center">
<tr bgcolor="(CGIVAR)admin_pri_tablerow_color(/CGIVAR)">
<td valign="TOP"><p><font face="(CGIVAR)admin_small_font_face(/CGIVAR)" size="(CGIVAR)admin_small_font_size(/CGIVAR)" color="(CGIVAR)admin_small_font_color(/CGIVAR)"><b>From Email Address</font><br>
<input type="TEXT" name="from" value="(CGIVAR)site_owner_email_address(/CGIVAR)" size="50">
</td></tr>

<tr bgcolor="(CGIVAR)admin_alt_tablerow_color(/CGIVAR)">
<td valign="top" bgcolor="(CGIVAR)admin_pri_tablerow_color(/CGIVAR)"><font face="(CGIVAR)admin_small_font_face(/CGIVAR)" size="(CGIVAR)admin_small_font_size(/CGIVAR)" color="(CGIVAR)admin_small_font_color(/CGIVAR)">
<b>To Email Address </font></b><br>
<input type="text" name="to" value="(CGIVAR)fd_ref(/CGIVAR)" size="50">
</td>
</tr>

<tr bgcolor="(CGIVAR)admin_alt_tablerow_color(/CGIVAR)">
<td valign="TOP"><font face="(CGIVAR)admin_small_font_face(/CGIVAR)" size="(CGIVAR)admin_small_font_size(/CGIVAR)" color="(CGIVAR)admin_small_font_color(/CGIVAR)">
<b>Subject</b></font></b><br>
<input type="TEXT" name="subject" value="Your MyStore.com Order" size="50">
</td></tr>

<tr bgcolor="(CGIVAR)admin_pri_tablerow_color(/CGIVAR)">
<td valign="TOP"><font face="(CGIVAR)admin_small_font_face(/CGIVAR)" size="(CGIVAR)admin_small_font_size(/CGIVAR)" color="(CGIVAR)admin_small_font_color(/CGIVAR)">
<b>Plain Text Message </font></b><br>
<textarea cols="60" name="message" rows="15" wrap="SOFT">
Dear Customer, 
We thought that you would like to know the status of your order.

Best Regards,
www.MyStore.com</textarea>
</td></tr>
(CGIGET TYPE="SUB" VALUE="adm_mail_html_field" PARAMS="C")
</table>
<br>
<input type="IMAGE" src="(CGIVAR)images_path(/CGIVAR)/admin/admin_submit_submit.gif" width="(CGIVAR)admin_button_image_width(/CGIVAR)" height="(CGIVAR)admin_button_image_height(/CGIVAR)" border="0" value="submit"><a href="(CGIVAR)common_url(/CGIVAR)&pg=cancel"><img src="(CGIVAR)images_path(/CGIVAR)/admin/admin_submit_cancel.gif" width="(CGIVAR)admin_button_image_width(/CGIVAR)" height="(CGIVAR)admin_button_image_height(/CGIVAR)" border="0"></a></form>

Offline

 

#2 03-24-2005 11:09:45

Blitzen
Member
From: USA
Registered: 01-01-2005
Posts: 936

Re: Email Templates



To further streamline managing his Click Cart Pro 5.1 (tiki) emails, my client required email templates that he can edit. One solution is above but is not personalized with respect to the order.

You can either extensively modify the Click Cart Pro 5.1 (tiki) Perl code or use the Javascript solution, below.

We use Javascript to send the <form> data from the "Edit Invoice" page to the "Email Form" page. I have not yet figured out how to send the cart contents from the Edit Invoice page to the Email Form page. Any and all solutions are welcome.

On the Email Form page, Javascript is also used to create the email templates. Here is how we did this.

(1) Add the NAME parameter to the <form> tag located on the Edit Invoice page.

Look for

Code:

<FORM METHOD="POST" ACTION="(CGIVAR)common_url_form(/CGIVAR)">

and replace it with

Code:

<FORM METHOD="POST" ACTION="(CGIVAR)common_url_form(/CGIVAR)" NAME="ccpForm">

(2) Rename the URL (on the Edit Invoice page) that links to the Form Page to include the form data values.
In this file, the follwing Javascript will add the <form> element "values" to the URL so that the Form Email page can read them. You can include whatever form elements from the Edit Invoice page that you need. The order of the parameter values is important when reading these from the Email Form page. Here, we want to send the elements "Billing First Name", "Billing Last Name", and a customfield that we renamed as "UPS Tracking Number".
Replace

Code:

} elsif ($display_type eq "TEXTBOX-MAILTO") {

print <<ENDOFTEXT;
<INPUT TYPE="TEXT" NAME="$field_name" VALUE="$value" SIZE="25" MAXLENGTH="$maxlength">
ENDOFTEXT

if ($value ne "") {

print <<ENDOFTEXT;

<FONT FACE="$admin_small_font_face" SIZE="$admin_small_font_size" COLOR="$admin_small_font_color"><BR><BR><A 

HREF="$common_url&pg=contact&ref=$value">$html_mailto_string</A></FONT>

ENDOFTEXT

} ######### End of if statement.

with

Code:

} elsif ($display_type eq "TEXTBOX-MAILTO") {

print <<ENDOFTEXT;
<INPUT TYPE="TEXT" NAME="$field_name" VALUE="$value" SIZE="25" MAXLENGTH="$maxlength">
ENDOFTEXT

if ($value ne "") {


#####################################################
# March 2005 Blitzen added the Javascript to send the form element values to the Email Form
# BFName = BF = Billing first name
# LFName = LF = Billing last name
# UTracking = UT = UPS Tracking Number reassigned to Custom Field 1
# You can add any form element "value" to send to the Email Form.
# This will open the Email Form in a new window in case you need
#   to refer back to the invoice page while editing the email.
#####################################################

print <<ENDOFTEXT;
<script language="javascript" type="text/javascript">
<!--
function emailCustomer(linkParam) {
// Rewrite the URL to include the form elements that you
// need to send to the Email Form.
ordNum = document.ccpForm.tracking_id.value;
BFName = document.ccpForm.tracking_firstname.value;
BLName = document.ccpForm.tracking_lastname.value;
UTracking = document.ccpForm.tracking_customone.value;
linkToParam=linkParam + "&ON=" + ordNum + "&FN=" + BFName + "&LN=" + BLName + "&UT=" + UTracking;
catwindow = window.open(linkToParam,'catWin');
} 
//-->
</script>
<FONT FACE="$admin_small_font_face" SIZE="$admin_small_font_size" COLOR="$admin_small_font_color"><BR><BR>
<A href="javascript:emailCustomer('$common_url&pg=contact&ref=$value')">$html_mailto_string</A></FONT>
ENDOFTEXT

###End of Blitzen Edit

} ######### End of if statement.

(3) On the Email Form page, capture the form object values sent in the URL and insert the form values into the email form as follows.
Javascript reads the values from the URL. Below is our entire data/element/adm_mail_contact.txt file. Of course, you can edit it as needed.

Code:

<!--adm_mail_contact.txt-->
<p>Complete the information below to send a contact message.<br>All fields are required.
<script language="javascript" type="text/javascript">
<!--
function getoNum() {
theURL = parent.document.URL;
n = parent.document.URL.indexOf("ON=");
if (n < 0) {return("nogo");}
else {
l = parent.document.URL.indexOf("FN=");
ORDNum = parent.document.URL.substring(n+3,l-1);
return(ORDNum);
}}

function getName() {
theURL = parent.document.URL;
n = parent.document.URL.indexOf("FN=");
if (n < 0) {return("nogo");}
else {
l = parent.document.URL.indexOf("LN=");
FName = parent.document.URL.substring(n+3,l-1);
n2 = parent.document.URL.indexOf("LN=");
l2 = parent.document.URL.indexOf("UT=");
LName = parent.document.URL.substring(n2+3,l2-1);
FLName=FName+" "+LName;
return(FLName);
}}

function getUPSTrackNum() {
theURL = parent.document.URL;
n = parent.document.URL.indexOf("UT=");
if (n < 0) {return("nogo");}
else {
l = parent.document.URL.length;
UPSTrackNum = parent.document.URL.substring(n+3,l+1);
return(UPSTrackNum);
}}

function orderShipped() {
if (getoNum() == "nogo") {alert("Template cannot be created. Please enter this form from Edit Invoice page.");}
else {
document.emailForm.subject.value="Order # " + getoNum() + " Shipped from MyCompany.com";
document.emailForm.message.value="Dear "+getName()+",\n\nWe thought that you would like to know that your order shipped. You may track it at http://www.UPS.com with the tracking number\n" + getUPSTrackNum() + "\n\n\nBest Regards,\nwww.MyCompany.com";
}}

function stockOut() {
if (getoNum() == "nogo") {alert("Template cannot be created. Please enter this form from Edit Invoice page.");}
else {
document.emailForm.subject.value="Stockout Order #" + getoNum() + " - MyCompany.com";
document.emailForm.message.value="Dear "+getName()+",\n\n\nWe sincerely apologize for this inconvenience.\n\nRegards,\n\nMyCompany.com";
}}
//-->
</script>

<p><b>Select a template from the list below.</b></p>
<p><a href="javascript:orderShipped();">Order Shipped</a></p>
<p><a href="javascript:stockOut();">Stockout</a></p>

<form method="POST" action="(CGIVAR)common_url_form(/CGIVAR)" name="emailForm">
(CGIVAR)common_hidden_fields(/CGIVAR)
<input type="HIDDEN" name="pg" value="contact_proc">
<table width="100%" border="0" cols="2" cellpadding="1" cellspacing="3" align="center">
<tr bgcolor="(CGIVAR)admin_pri_tablerow_color(/CGIVAR)">
<td valign="TOP"><p><font face="(CGIVAR)admin_small_font_face(/CGIVAR)" size="(CGIVAR)admin_small_font_size(/CGIVAR)" color="(CGIVAR)admin_small_font_color(/CGIVAR)"><b>From Email Address</font><br>
<input type="TEXT" name="from" value="(CGIVAR)site_owner_email_address(/CGIVAR)" size="50">
</td></tr>

<tr bgcolor="(CGIVAR)admin_alt_tablerow_color(/CGIVAR)">
<td valign="top" bgcolor="(CGIVAR)admin_pri_tablerow_color(/CGIVAR)"><font face="(CGIVAR)admin_small_font_face(/CGIVAR)" size="(CGIVAR)admin_small_font_size(/CGIVAR)" color="(CGIVAR)admin_small_font_color(/CGIVAR)">
<b>To Email Address </font></b><br>
<input type="text" name="to" value="(CGIVAR)fd_ref(/CGIVAR)" size="50">
</td>
</tr>

<tr bgcolor="(CGIVAR)admin_alt_tablerow_color(/CGIVAR)">
<td valign="TOP"><font face="(CGIVAR)admin_small_font_face(/CGIVAR)" size="(CGIVAR)admin_small_font_size(/CGIVAR)" color="(CGIVAR)admin_small_font_color(/CGIVAR)">
<b>Subject</b></font></b><br>
<input type="TEXT" name="subject" value="" size="50">
</td></tr>

<tr bgcolor="(CGIVAR)admin_pri_tablerow_color(/CGIVAR)">
<td valign="TOP"><font face="(CGIVAR)admin_small_font_face(/CGIVAR)" size="(CGIVAR)admin_small_font_size(/CGIVAR)" color="(CGIVAR)admin_small_font_color(/CGIVAR)">
<b>Plain Text Message </font></b><br>
<textarea cols="60" name="message" rows="15" wrap="SOFT">
Dear Customer:

We thought that you would like to know the status of your order.


Best Regards,
www.MyCompany.com</textarea>
</td>
</tr>
(CGIGET TYPE="SUB" VALUE="adm_mail_html_field" PARAMS="C")
</table>
<br>
<input type="IMAGE" src="(CGIVAR)images_path(/CGIVAR)/admin/admin_submit_submit.gif" width="(CGIVAR)admin_button_image_width(/CGIVAR)" height="(CGIVAR)admin_button_image_height(/CGIVAR)" border="0" value="submit"><a href="(CGIVAR)common_url(/CGIVAR)&pg=cancel"><img src="(CGIVAR)images_path(/CGIVAR)/admin/admin_submit_cancel.gif" width="(CGIVAR)admin_button_image_width(/CGIVAR)" height="(CGIVAR)admin_button_image_height(/CGIVAR)" border="0"></a></form>

That's it! Now, if we can just send the order item list to this.....

Offline

 

#3 04-26-2008 18:00:11

celdirect
Member
From: UK
Registered: 04-01-2005
Posts: 782

Re: Email Templates

Hi,

Just found this and added it - it works great!

Offline

 

#4 04-27-2008 19:20:51

celdirect
Member
From: UK
Registered: 04-01-2005
Posts: 782

Re: Email Templates

HI,

Can you send CC or at other email address to 'send email form' in ccp admin (even if its in putted by hand?)  Also can you send an attachment?

Offline

 

Board footer