I'm trying to compose the body of an email using PHP evaluation within a rule. The rule is triggered when a new content is saved. Part of the email body is composed using HEREDOC and that works fine. This is the code I'm having trouble with:
// Provide download link.
if ($node->field_software_product_sku === "Some Product Name")
echo "<a href=\"http://www.mywebsite.com/Some Product Name/some.exe\">Trial Version Download Link</a><br />";
The above code comes directly after the ending of the HEREDOC, but, before the closing '?>'. I anticipate that in the future, I will need to add more clauses to the 'if' statement, so, it's important that I get this to work.
I've tried several different incantations for coding the 'if'. I've tried using the token name enclosed in single quotes. And, I've tried using “==” instead of “===”. The only thing that seems to work consistently is commenting out the 'if'. Then, the “Trial Download Link” text does appear in the email. Unfortunately, the rule is to be used for multiple “skus”, so, I need to use the 'if'.
I'm hoping I've made a subtle mistake, or, overlooked something.
Can someone point me in the right direction?
Is there a way to debug the code to see why the 'if' may be failing?