Transactional emails if conditions discrepancy
-
16-10-2019 - |
Pergunta
Trying to set different text for registered and guest customers order confirmation email (using single template, not sure why Magento has two different settings for this?) I've come across that {{if order.getCustomerIsGuest()}}
always evaluates to true rendering {{else}}
useless
I worked it around by using {{if order.getCustomerGroupId()}}
but hoping someone can shed some light what can be culprit of this and to avoid other's pitfalls trying to implement this logic the same way as I originally did
Solução
I understand why your code doesn't work. See Varien_Filter_Template::ifDirective()
: It compares '0'
or '1'
to ''
, which will both return false
.
What I don't understand is why the same construct with customer_group_id
does work. The only thing I can think of is that customer_group_id
is filled with NULL
in sales_flat_order
table (which it isn't in my installation).
The only 2 simple solutions (implementation in < 1h) I can think of:
- Extend
Mage_Sales_Model_Order
and add a function calledgetCustomerIsGuest
that returnsfalse
ortrue
instead of'0'
or'1'
- Extend
Mage_Core_Model_Email_Template_Filter
and replace the functionifDirective
so it will treat'0'
asfalse