4

i've been debugging this for hours now. And I am just dumbstruck what it could be. We use a customvar in an email template. I will try to explain as good as possible.

USECASE 1: If I place {{customVar code=SOCIALBUTTONS}} @ the bottom of the email then the variable contained in the customVar {{config path='web/unsecure/base_url'}} the results is: variable not parsed for its value. (you can read the variable declaration: {{config path='web/unsecure/base_url'}})

USECASE 2: If I place the {{customVar code=SOCIALBUTTONS}} somewhere in my email template a second time - higher up: both variables have my domain for {{config path='web/unsecure/base_url'}}: storename.com

USECASE 3: If I place the {{customVar code=SOCIALBUTTONS}} higher in my email template only once - the variables have my domain for {{config path='web/unsecure/base_url'}}: storename.com

My question is: how can this be? I have been searching through the code looking for a mistake ... I just dont get it

<div style="font:1em/1.4em arial,verdana,sans-serif; margin:1px;border:1px solid DarkSlateGray;color:DarkSlateGray">
<div style="background:white;padding:2px 6px;color:DarkSlateGray;text-align:right; font-size:0.8em;-webkit-text-size-adjust:none;">
<a style="color:sienna;text-decoration:none" href="{{config path="web/unsecure/base_url"}}">website</a> | 
<a style="color:sienna;text-decoration:none" href="{{config path="web/unsecure/base_url"}}contact">contact</a> | 
<a style="color:sienna;text-decoration:none" href="{{config path="web/unsecure/base_url"}}veelgesteldevragen">faq</a> | 
<a style="color:sienna;text-decoration:none" href="{{config path="web/unsecure/base_url"}}algemene-voorwaarden">voorwaarden</a></div>
<div style="padding:4px 6px;font:1.6em 'Arial Black',arial,sans-serif;color: white;background:SteelBlue;">{{config path="general/store_information/name"}}</div>

<!-- INTRODUCTIE TEKST -->
<div style="background:white;padding:4px 6px;color:DarkSlateGray">
<p><span style="font-size:1.6em;color:sienna;">Hi {{htmlescape var=$billing.getFirstname()}}!</span></p>
<p>Vandaag wordt je bestelling verzonden met PostNL. De meeste verzendingen arriveren de volgende werkdag met uitzondering van een klein percentage dat een werkdag later volgt. Voor verzending op vrijdag, zaterdag of zondag arriveert het pakketje vaak maandag en heel soms dinsdag.</p></div>

{{customVar code=NEWSLETTER}}

<!-- GEGEVENS VAN BESTELLING -->
<div style="padding:4px 6px;font:1em 'Arial Black',arial,sans-serif;color: white;background:SteelBlue;">Bestelling #{{var order.increment_id}}</div>
{{depend comment}}<div style="background:white;padding:4px 6px;color:DarkSlateGray"><p>Opmerking bij bestelling: {{var comment}}<br />{{/depend}}
{{depend order.getEmailCustomerNote()}}<br />Notitie bij bestelling: {{var order.getEmailCustomerNote()}}</p></div>{{/depend}}

<table style="width:99%; margin: 4px 0"><thead><tr style="font:1em 'Arial Black',arial,sans-serif;color: SteelBlue;">
<th style="text-align:left;white-space:nowrap;padding-left:6px; width: 50%">Verzending</th>
<th style="text-align:left;white-space:nowrap; width: 50%">Betaling</th>
</tr></thead>
<tbody><tr>
<td style="padding-left:6px;background:white;vertical-align: top;"><p>{{var order.getShippingDescription()}}</p>{{var order.getShippingAddress().format('html')}}</td>
<td style="background:white;vertical-align: top;">{{var payment_html}}{{var order.billing_address.format('html')}}</td>
</tr></tbody></table>

<div style="padding:4px 6px;font:1em 'Arial Black',arial,sans-serif;color: white;background:SteelBlue;">Bestelgegevens</div>
<div style="background:white;padding:4px 4px;color:DarkSlateGray">{{layout handle='sales_email_order_items' order=$order}}{{var items_html}}</div>

<div style="padding:4px 6px;font:1em 'Arial Black',arial,sans-serif;color: white;background:SteelBlue;">Bedankt namens ons</div>
<div style="background:white;padding:4px 6px;color:DarkSlateGray">
<p>Bedankt voor je order bij <a target="_blank" href="{{config path='web/unsecure/base_url'}}" style="color:sienna">{{config path='general/store_information/name'}}</a>.</p>
<p>En heb je nog een vraag of opmerking? Antwoord dan op dit bericht. Of neem een kijkje bij de <a target="_blank" href="{{config path='web/unsecure/base_url'}}veelgesteldevragen" style="color:sienna">veelgestelde vragen</a> op onze website.</p></div>

{{customVar code=SOCIALBUTTONS}}

<!-- CLOSING DIV -->
</div>

Thanks in advance

  • you are spreading the same issue, across multiple questions. This makes the information you supply fragmented. Try and keep it all contained in one question. – ProxiBlue Aug 8 '13 at 15:55
  • 2
    Funny. Other comment I got was to ask in separate questions. – snh_nl Aug 8 '13 at 17:50
  • LOL, now that is funny :) – ProxiBlue Aug 8 '13 at 22:06
  • Could any of the content of your different variables have some pre-defined characters? {{, }}? Also, is this template in a .phtml file? An entry in the backend? If the content is "social buttons", I'm wondering if there is some Javascript snippet included in there that is messing up the short code parser. – pspahn Aug 22 '13 at 13:27
  • SOCIALBUTTONS contains {{config path='web/unsecure/base_url'}}? if yes the parser needs to run twice: first run SOCIALBUTTONS to {{config path='web/unsecure/base_url'}}, next run to replace it to storename.com. You are probably better off using a custom block. – Kristof at Fooman Aug 22 '13 at 16:08
3

In your template you could use a custom block like this

{{block type='fooman_example/email' config_var='SOCIALBUTTONS'}}

and then in your block based on Mage_Core_Model_Email_Template_Filter

<?php
class Fooman_Example_Block_Email extends Mage_Core_Block_Template
{

    protected function _toHtml()
    {
        $customVarValue = '';
        $variable = Mage::getModel('core/variable')
            ->setStoreId(Mage::app()->getStore()->getStoreId())
            ->loadByCode($this->getConfigVar());
        if ($value = $variable->getValue(Mage_Core_Model_Variable::TYPE_HTML)) {
            $customVarValue = $value;
        }
        return $customVarValue;
    }
}
| improve this answer | |
  • Thanks Kristof. I also found out that this works fine: {{block type="cms/block" block_id="social_buttons_email"}} nevert realized that also would work in transactional emails. But logical. Yes. – snh_nl Aug 29 '13 at 17:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.