5 replies [Last post]
Guest
Guest's picture
Was this information Helpful?

I'm creating a custom notification e-mail sent to the customer and need to include the number of items ordered, the list price and the model number.

The text field accepts order and global tokens, but [model] and [list_price] are product tokens so can't be used. Number of items is not tokenised at all. Yet all 3 are used in the standard customer e-mail!

Any ideas?

texas-bronius@drupal.org's picture
Offline
Joined: 01/19/2010
Juice: 170
List of tokens that can be used in customer.itpl.php

I was looking for this and thought it might help answer your question. A list of tokens for the customer notification templates are under /admin/store/help/tokens

-Bronius

Watchkeeper's picture
Offline
Joined: 01/19/2009
Juice: 10
Re: List of tokens that can be used in customer.itpl.php

Yes, I've seen the token list but as I said, two of the tokens I need can't be used in this particular text area, and the third parameter does not have a token at all.

I have now solved the problem by creating a new template based on the built-in one.

gscerb's picture
Offline
Joined: 05/06/2008
Juice: 29
other tokens?

I am also looking to add other product information: product descriptions and a few custom fields. Can you share how you solved your problem with the templates.
thanks

zhangty's picture
Offline
Joined: 01/27/2010
Juice: 41
Cannot use Product Tokens

I am also unable to use any of the Product Tokens.

I understand there are templates located in ubercart\uc_order\templates folder. However, I do not understand how to set up a new template based on an existing one to solve the problem.

Can someone please explain?

Also, would there be a work around to allow the use of the Product Tokens without creating a new template?

Watchkeeper's picture
Offline
Joined: 01/19/2009
Juice: 10
Customised template

You are right - the templates are held in ubercart\uc_order\templates\

There are two of them; one for the admins (admin.itpl.php) and the other which is sent to the customer (customer.itpl.php). We needed to modify the customer notification so I made a copy of customer.itpl.php and saved it into the templates folder with a new name (5L2F.itpl.php). Ubercart picked up this new template and I was able to choose it from the configuration screen (Store Administration -> Configuration -> Notification settings -> Checkout notifications -> Customer checkout notification; there's a drop-down box for the Invoice template).

Then it's just a case of customising the new template until it looks like what you want. First, remove the comments at the beginning of the file between the php tags:

<?php
// $Id: customer.itpl.php,v 1.4.2.5 2009/09/23 19:14:42 rszrama Exp $

/**
* This file is the default customer invoice template for Ubercart.
*/

?>

After that your on your own. In our case we dropped a lot of the fancy PHP stuff and just used HTML. We set up a table to lay out the invoice nicely and used the following wording and tokens:

Thanks for your order, [order-first-name].
Purchasing Information:
E-mail Address: [order-email]
Billing Address: [order-billing-address]
Billing Phone: [order-billing-phone]
Shipping Address: [order-shipping-address]
Order Grand Total: [order-total]
Payment Method: [order-payment-method]
Order Summary:
Order Number: [order-id]
Your comments: [order-comments]

Then we have a section which details the order, and it's the standard php from the original template:

                    <tr>
                      <td colspan="2">
                        <br /><br /><b><?php echo t('Products on order:'); ?>&nbsp;</b>

                        <table width="100%" style="font-family: verdana, arial, helvetica; font-size: small;">

                          <?php if (is_array($order->products)) {
                            foreach (
$order->products as $product) { ?>

                            <tr>
                              <td valign="top" nowrap="nowrap">
                                <?php echo $product->qty; ?> x
                              </td>
                              <td width="98%">
                                <?php echo $product->title .' - '. uc_currency_format($product->price * $product->qty); ?>
                                <?php if ($product->qty > 1) {
                                  echo
t('(!price each)', array('!price' => uc_currency_format($product->price)));
                                }
?>

                                <br />
                                <?php if (is_array($product->data['attributes']) && count($product->data['attributes']) > 0) {?>
                                <?php foreach ($product->data['attributes'] as $key => $value) {
                                  echo
'<li>'. $key .': '. $value .'</li>';
                                }
?>

                                <?php } ?>
                                <br />
                              </td>
                            </tr>

Lastly:

<tr>
                <td colspan="2">
                  <hr noshade="noshade" size="1" /><br />
  <p>Please note: This e-mail message is an automated notification. Please do not reply to this message.</p>
  <p>Thanks again for shopping with us.</p>
                  <p><b><a href="http://5loaves2fishes.net">5 Loaves &amp; 2 Fishes</a></b><br /></p>
                </td>
              </tr>

As I said, all this text and tokens was laid out in tables using standard HTML, and a snippet of it looks like this:

                <td nowrap="nowrap">
                   <br><span style="font-size: large;">5 Loaves &amp; 2 Fishes</span><br>(address here)<br />('phone number here)
                </td>
              </tr>
            </table>
          </td>
        </tr>
       
        <tr valign="top">
          <td>
                  <br /><hr noshade="noshade" size="1" /><br />
                  <p><b>Thanks for your order, [order-first-name].</b></p><br />

            <table cellpadding="4" cellspacing="0" border="0" width="100%" style="font-family: verdana, arial, helvetica; font-size: small;">
              <tr>
                <td colspan="2" bgcolor="#009966">
                  <b>Purchasing Information:</b>
              </td>
              </tr>
              <tr>
              <td nowrap="nowrap">
                 <br /><b>E-mail Address:</b><br />  [order-email]
                  </td>
                  <td width="98%">
                 
                  </td>
   </tr>
              <tr>
                <td colspan="2">

                  <table width="100%" cellspacing="0" cellpadding="0" style="font-family: verdana, arial, helvetica; font-size: small;">
                    <tr>
                      <td valign="top" width="50%">
                        <b>Billing Address:</b><br />  [order-billing-address]<br />
                        <br />
                        <b>Billing Phone:</b><br /> [order-billing-phone]<br /><br />
<b>Shipping Address:</b><br />  [order-shipping-address]<br />
                        <br /><br />
                      </td>
                    </tr>
                  </table>

Hope that gives you an idea of how to go about it.

A word of warning. Save your new template on your home PC somewhere safe. When you upgrade Ubercart to a newer version you will lose your template, so you'll have to FTP it up to the directory and go through the configuration procedure again.