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
Placeholders in newsletter and transactional email (templates)
 
Unic
Jr. Member
 
Avatar
Total Posts:  18
Joined:  2008-01-08
Zürich, Switzerland
 

Does anyone have an idea or an overview of the placeholders available in email templates? I guess that it is a different set for newsletters and transactional emails. What I have found up to now (in the en_US locale templates):

Sales:
- order.getStoreGroupName(): Scope? Current value? Also available in other modules?
- order.getCustomerName()
- order.increment_id
- order.getBillingAddress().getName(): Name of the billing address
- order.getCreatedAtFormated(’long’): date of order creation?
- order.getBillingAddress().format(’html’): parameter for plain-text output?
- payment_html: content?
- order.getShippingAddress().format(’html’): parameter for plain-text output?
- order.shipping_address.format(’html’): difference between this and order.shipping_address.format(’html’)?
- order.getShippingDescription(): content?
- order.shipping_description: difference between this and order.getShippingDescription()?
- items_html: content?
- order.getEmailCustomerNote(): content?
- invoice.increment_id
- {{block type=’core/template’ area=’frontend’ template=’email/order/items_invoice.phtml’ invoice=$invoice order=$order}}: content?
- comment
- order.getStatusLabel()
- billing.getName(): content? difference between this and order.getBillingAddress().getName()?
- order.billing_address.format(’html’): difference between this and order.getBillingAddress().format(’html’)? parameter for plain-text output?
- {{block type=’core/template’ area=’frontend’ template=’email/order/items_shipment.phtml’ shipment=$shipment order=$order}}: content?
- {{block type=’core/template’ area=’frontend’ template=’email/order/shipment_track.phtml’ shipment=$shipment order=$order}}: content?
- shipment.increment_id
- creditmemo.increment_id

Newsletter:
- customer.name
- order.getStoreGroupName(): Not sure
- subscriber.getConfirmationLink()

Account-related:
- customer.name
- customer.email
- customer.password

Admin:
- user.name
- password: is there an equivalent to the customer like user.password?

Contact form:
- data.name
- data.email
- data.telephone
- data.comment

Whishlist:
- message
- items: plain-text or html-formatted?
- customer.name
- addAllLink: maybe link to add entire wishlist to cart?

Is anybody able to confirm and/or correct/complete/comment the list above? I guess the placeholders / variables / function calls are related to the objects available in a particular scope. Maybe an overview of all available objects could also be helpful.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Unic
Jr. Member
 
Avatar
Total Posts:  18
Joined:  2008-01-08
Zürich, Switzerland
 

After trying different placeholders in the newsletter templates, we can say that the following ones do not seem to work:

- {{var customer.name}}
- {{var customer.firstname}}
- {{var customer.lastname}}
- {{var subscriber.name}}
- {{var subscriber.firstname}}
- {{var subscriber.lastname}}

Does anyone know of a list with placeholders available?

Thanks, unic

 
Magento Community Magento Community
Magento Community
Magento Community
 
joolsr
Sr. Member
 
Total Posts:  99
Joined:  2008-01-16
 

Hi

I’m having problems where

- {{block type=’core/template’ area=’frontend’ template=’email/order/items_shipment.phtml’ shipment=$shipment order=$order}}:
- {{block type=’core/template’ area=’frontend’ template=’email/order/shipment_track.phtml’ shipment=$shipment order=$order}}:

do not bring up the text I would expect. The first one should bring up; the ordered product lines, SKU, Qty
The second line should bring up : the shipping carrier, and tracking number.

But for whatever reason, even though I have modified copies of these blocks of text in by own shop called ‘qpar’, the default ones are fetched.

Julian

 
Magento Community Magento Community
Magento Community
Magento Community
 
Janek
Jr. Member
 
Total Posts:  16
Joined:  2008-02-17
 

Are you sure about your qoute marks? they are something different than single quotes - check in plan text editor.... I think this is your problem?

DJ

 
Magento Community Magento Community
Magento Community
Magento Community
 
joolsr
Sr. Member
 
Total Posts:  99
Joined:  2008-01-16
 

thanks janek, I will take a look !

 
Magento Community Magento Community
Magento Community
Magento Community
 
joolsr
Sr. Member
 
Total Posts:  99
Joined:  2008-01-16
 

no, the single quotes are ok anyway. I think they must have got changed when adding to this forum ...

 
Magento Community Magento Community
Magento Community
Magento Community
 
Janek
Jr. Member
 
Total Posts:  16
Joined:  2008-02-17
 
Unic - 27 May 2008 11:20 PM

Does anyone have an idea or an overview of the placeholders available in email templates? I guess that it is a different set for newsletters and transactional emails. 

There is no closed, complete set. If you need - you can extend it.
{{var }} is tightly related to variables given in sendTransactional() function, and correspond to them
i.e.
order.getCustomerName() does not work in templates where “order” object is not set as variable for sendTransactional()

if you want to extend these variables - you must:
A. Look for function sendTransactional() in correspondig .php file, and modify that place to your needs
find and grep unix tools are useful for looking smile
or
B. use {{block .....}} and make template that meet your needs. (That method is not store view aware, and for emails send from adminpanel, it looks in default/default for templates :(

 
Magento Community Magento Community
Magento Community
Magento Community
 
Janek
Jr. Member
 
Total Posts:  16
Joined:  2008-02-17
 
joolsr - 29 May 2008 12:15 AM

Hi

But for whatever reason, even though I have modified copies of these blocks of text in by own shop called ‘qpar’, the default ones are fetched.

Julian

OK, I have reached similar problem too…
Transactional emails sent from adminpanel, seems do not fetch store package in {{block ....}}, and takes default/default. It should be taken from Order, Shipment, or Invoice, because adminpanel session has no knowledge of store view.

I digg it deeper… using order comment sending as example

code/core/Mage/Adminhtml/controllers/Sales/OrderController.php
line 188

if ($notify && $comment{
                    Mage
::getDesign()->setStore($order->getStoreId());
                    
Mage::getDesign()->setArea('frontend');
                
}
                $order
->sendOrderUpdateEmail($notify$comment);

so store is set to order’s store, before sendOrderUpdateEmail

So the problem must be somewhere else… maybe is something improperly set in function blockDirective()
in file
code/core/Mage/Core/Model/Email/Template/Filter.php
Could someone more skilled look at this…

 
Magento Community Magento Community
Magento Community
Magento Community
 
Janek
Jr. Member
 
Total Posts:  16
Joined:  2008-02-17
 

@ joolsr

I found it… I cant belive it, but I found it smile wow

There is lack of store’s package definition
store is set, area is set, but package is not set to store’s package. Is still adminhtml package ( = default)
So i tried this modification (on sales example). It works for me smile {{block }} gets templates from store’s package
Thi is not a only palce, these modifications need to be done on few other files

I think its worth put it on bugs report…

Indexcode/core/Mage/Adminhtml/controllers/Sales/OrderController.php
===================================================================
--- 
code/core/Mage/Adminhtml/controllers/Sales/OrderController.php    (revision 86)
+++ 
code/core/Mage/Adminhtml/controllers/Sales/OrderController.php    (working copy)
@@ -
185,13 +185,18 @@
                 
$order->addStatusToHistory($data['status']$data['comment']$notify);
                 
$comment trim(strip_tags($data['comment']));
 
-                if (
$notify && $comment{
+                $old_package null;
+                if (
$notify{
                     Mage
::getDesign()->setStore($order->getStoreId());
                     
Mage::getDesign()->setArea('frontend');
+                    
$old_package Mage::getDesign()->getPackageName();
+                    
$store_package Mage::getStoreConfig('design/package/name',$order->getStoreId());
+                    
Mage::getDesign()->setPackageName($store_package);
                 
}
                 $order
->sendOrderUpdateEmail($notify$comment);
                 
$order->save();
                 
Mage::getDesign()->setArea('adminhtml');
+                if (!
is_null($old_package)) { Mage::getDesign()->setPackageName($old_package); }
                 $response 
$this->getLayout()->createBlock('adminhtml/sales_order_view_history')->toHtml();
             
}
             
catch (Mage_Core_Exception $e{
 
Magento Community Magento Community
Magento Community
Magento Community
 
joolsr
Sr. Member
 
Total Posts:  99
Joined:  2008-01-16
 

great stuff grin

Did you get to file a bug? I don’t think I understand the code enough to adequately describe the problem, and your fix ...

 
Magento Community Magento Community
Magento Community
Magento Community
 
Janek
Jr. Member
 
Total Posts:  16
Joined:  2008-02-17
 

Yes, bug reported. In the meantime I will try to make complete patch.

DJ

 
Magento Community Magento Community
Magento Community
Magento Community
 
joolsr
Sr. Member
 
Total Posts:  99
Joined:  2008-01-16
 

what is the bug number ? It will help me track it ..

 
Magento Community Magento Community
Magento Community
Magento Community
 
Janek
Jr. Member
 
Total Posts:  16
Joined:  2008-02-17
 

@joolsr

I PM you a bug number

There is complete patch to fix discussed issue. It works for me, but maybe Magento Team resolve this in more elegant waay.

patched against 19870

File Attachments
patch.txt  (File Size: 9KB - Downloads: 685)
 
Magento Community Magento Community
Magento Community
Magento Community
 
finch8243
Sr. Member
 
Total Posts:  79
Joined:  2007-08-31
 

Janek—I don’t think this was fixed in 1.1.1, am I correct?  Whenever I send an email from the admin (selecting “notify customer"), the email arrives ok, but not all the variables switch to the store level.  Some do—{{skin url="images/logo_email.gif"}} for example—but {{store url=""}} and {{store url="customer/account/"}} do not (they link to the magento admin, not the store URL.

 
Magento Community Magento Community
Magento Community
Magento Community
 
capple_
Jr. Member
 
Total Posts:  17
Joined:  2008-04-02
 

Same problem as finch8243, it existed in 1.0.19870.1, and 1.1 beta.

Just upgraded to 1.1.1 stable, and issue still exist.

Here’s a bug report I filed: http://www.magentocommerce.com/bug-tracking/issue?issue=2475

 
Magento Community Magento Community
Magento Community
Magento Community
 
Aldo
Member
 
Total Posts:  47
Joined:  2008-02-18
 

Upgraded to 1.1.2; issue still exists.

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