Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 1 of 2
Transactional Email Variables? 
 
CreedFeed
Member
 
Total Posts:  74
Joined:  2007-08-31
Milwaukee, WI
 

I am looking to print out my store name in transactional emails. I noticed that on the order related emails the variable used is:

{{var order.getStoreGroupName()}}

I assume this will not work in, for example, the Forgot Password email since there is no order to get the store group name from. Is it possible to print out the store name based on the configuration variables set in other transactional emails? How do we access configuration variables in these transactional emails? I’m confused!!

Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
sherrie
Moderator
 
Avatar
Total Posts:  1655
Joined:  2007-12-14
Waterloo, ON
 

This would be nice to know ... you’re right in that the above does not work in an email not involving an order.

 
Magento Community Magento Community
Magento Community
Magento Community
 
jshirkey
Jr. Member
 
Total Posts:  12
Joined:  2008-06-20
Charlottesville, VA
 
CreedFeed - 22 July 2008 10:47 AM

I am looking to print out my store name in transactional emails. I noticed that on the order related emails the variable used is:

{{var order.getStoreGroupName()}}

I assume this will not work in, for example, the Forgot Password email since there is no order to get the store group name from. Is it possible to print out the store name based on the configuration variables set in other transactional emails? How do we access configuration variables in these transactional emails? I’m confused!!

Thanks!

The Magento customer model happens to have a store property in it.  Therefore, in the non order related emails (new account, wishlist, etc) you can path to the store name through the customer variable:

{{var customer.store.name}}

For more advanced customizations (referencing data that is not available through the existing template variables), you would have to subclass the Magento model that handles the sending of the email specific to the email template you want to customize.  For example, for new order emails, you would subclass Mage_Customer_Model_Customer, override the sendNewAccountEmail() function, and pass your extra data into the $vars=array() argument of the sendTransactional() function of Mage_Core_Model_Email_Template object that gets fetched.  From there, you would be able to refer to that variable within your transactional email template.

Mage::getModel('core/email_template')
            ->
setDesignConfig(array('area'=>'frontend''store'=>$storeId))
            ->
sendTransactional(
                
Mage::getStoreConfig($types[$type]),
                
Mage::getStoreConfig(self::XML_PATH_REGISTER_EMAIL_IDENTITY),
                
$this->getEmail(),
                
$this->getName(),
                array(
'customer' => $this'back_url' => $backUrl'my_custom_variable' => $some_instantiated_object));

{{var my_custom_variable.name_of_property}}

Hope that helps!

 
Magento Community Magento Community
Magento Community
Magento Community
 
maijar
Member
 
Total Posts:  49
Joined:  2008-06-15
 

Do you know if there’s existing variable for website name? Instead of store name I would like to use that. Should I do it by myself?

 
Magento Community Magento Community
Magento Community
Magento Community
 
jshirkey
Jr. Member
 
Total Posts:  12
Joined:  2008-06-20
Charlottesville, VA
 
maijar - 07 September 2008 11:40 PM

Do you know if there’s existing variable for website name? Instead of store name I would like to use that. Should I do it by myself?

try

{{var customer.store.website.name}}
 
Magento Community Magento Community
Magento Community
Magento Community
 
maijar
Member
 
Total Posts:  49
Joined:  2008-06-15
 

Thank you jshirkey, I will try that one!

I tried to make new method getWebsiteName() to Order.php, and call it in email template like this: {{var customer.getWebsiteName()}} and it works, almost.
I have now two websites and seems it very randomly generates the title.

 
Magento Community Magento Community
Magento Community
Magento Community
 
maijar
Member
 
Total Posts:  49
Joined:  2008-06-15
 

jshirkey, are you sure that will work or was that just suggestion?
It wasn’t succesfull this time for me. Again, wrong website name or empty. I have no clue where it gets that other site name if I make order from site x :O

 
Magento Community Magento Community
Magento Community
Magento Community
 
maijar
Member
 
Total Posts:  49
Joined:  2008-06-15
 

I found some typos smile now my own method works well though it’s not very dynamic and need modifying if there’s new sites or name changes. Also, I’m not sure if it works in every situation. It’s like this (in Order.php):

public function getWebsiteName()
    
{
        $site 
$this->getStoreName(0); // 0 - website name, 1 - store group name, 2 - store name (this row is picked from getStoreGroupName())
        
               // Translate site name
        
if ($site == "Site Name")
        
{
            $site 
__("Site Name");
        

        
else if ($site "Site2 Name")
        
{
            $site 
__("Site2 Name");
        

        
        
return $site;
    
}
 
Magento Community Magento Community
Magento Community
Magento Community
 
mayerwin
Sr. Member
 
Avatar
Total Posts:  182
Joined:  2008-01-15
France
 

All these variables values should be stored in the locale database. It would be much simpler and would easily allow customization.

 
Magento Community Magento Community
Magento Community
Magento Community
 
pumba
Jr. Member
 
Total Posts:  28
Joined:  2008-05-14
 
jshirkey - 11 September 2008 08:38 AM

maijar - 07 September 2008 11:40 PM
Do you know if there’s existing variable for website name? Instead of store name I would like to use that. Should I do it by myself?

try

{{var customer.store.website.name}}

I’d love to use website name instead of store name, but that code snippet does not work :(

 
Magento Community Magento Community
Magento Community
Magento Community
 
aaroncampbell
Jr. Member
 
Total Posts:  30
Joined:  2007-12-07
 

Where can I see a list of available variables for order, etc?

This doesn’t seem to have anything, and the download is broke: http://www.magentocommerce.com/wiki/doc/list_of_variables_for_mail_template

 
Magento Community Magento Community
Magento Community
Magento Community
 
majacore
Member
 
Avatar
Total Posts:  53
Joined:  2008-12-29
 

yeah i am also looking for a list, but i guess it just comes from whats in the db ?

 
Magento Community Magento Community
Magento Community
Magento Community
 
salbertson
Jr. Member
 
Total Posts:  27
Joined:  2008-05-04
 

Does anyone know how to show the customer’s email address in the order transactional email? I just cannot find the placeholder variable for it. Thanks in advance.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Paulus
Guru
 
Total Posts:  335
Joined:  2008-07-21
 
salbertson - 01 May 2009 08:44 AM

Does anyone know how to show the customer’s email address in the order transactional email? I just cannot find the placeholder variable for it. Thanks in advance.

{{var customer.email}}

Just guessing, but it makes sense;-)

 
Magento Community Magento Community
Magento Community
Magento Community
 
merchantguru
Sr. Member
 
Avatar
Total Posts:  133
Joined:  2008-10-05
San Francisco
 

To show the store web address, you can use: {{store url=""}}

 
Magento Community Magento Community
Magento Community
Magento Community
 
mbartens@gmail.com
Jr. Member
 
Total Posts:  14
Joined:  2009-02-26
 
Paulus - 11 May 2009 11:52 AM

salbertson - 01 May 2009 08:44 AM
Does anyone know how to show the customer’s email address in the order transactional email? I just cannot find the placeholder variable for it. Thanks in advance.

{{var customer.email}}

Just guessing, but it makes sense;-)

That does make sense but it doesn’t work.  Has anyone else been able to get this to work?

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 2