Conditional keywords in eCommerce form email options not working


(Charlotte Westney) #1

Hello Matrixers,

 

I have an eCommerce form for sponsoring things in one of our National Parks, like you can sponsor a gate and have your initials and date on it.  The form takes details about what you are sponsoring, and then details about your payment. Then it sends you a lovely 'thank you' email.

 

But I need to change the contents of those emails slightly depending on what you sponsored, especially the internal emails that go to staff as they need to have different finance codes to put the money into different pots depending on what was sponsored.

 

So I tried some conditional keywords, as they are my favorite thing ever in Matrix.. but they're not working.

 

Here's a snippet of the email that I recieve in my inbox, where you can see that the normal %response_12345_q1% keywords have worked and are outputting the values submitted in the form (like name, amount and email) but that the conditional keywords aren't being processed at all.

 

 

Customer name: Mr Micky Mouse
Customer email: mickymouse@gmail.com
Amount: £250


%begin_response_696787_q6%

Message for memorial wall:
This is the long message text
%end_response_696787_q6%

 

 

 

Do conditional keywords work in email body areas like this?

If they don't, do you have any ideas for a smart workaround?

 

Thanks for your help,
Charlie

 


(Bart Banda) #2

Hey Charlie, what version of Matrix are you using?

 

I've heard of this not working before but thought it might have been fixed in recent versions.

 

Alternatively you could print a condition for printing a HTML comment around the stuff you don't want to show, for example:

%response_696787_q6^notempty:PRINT^empty:<!--%

Message for memorial wall:
This is the long message text

%response_696787_q6^notempty:PRINT^empty:–>%

Not as pretty I know.

 

The other work around might be to send the email based off a trigger action? 

 

If you give us the Matrix version we can check if it has been fixed in the latest versions, if not we'll get a bub report submitted. 


(Charlotte Westney) #3

Hi Bart,

 

Thanks for the reply. Version is 5.3.4 so quite recent. (Sorry, should have put version in original post!)

 

I'll try a trigger, and if that doesn't work then I'll try your workaround with the comment tags in. I've also got the Squiz UK support team looking at it, so if they find its a genuine error they can get a full bug report submitted.

 

Thanks for your help,

Charlie.

 

Update: Tried putting my original keywords into a trigger, but now none of the keywords work, eg %response_702101_q1% gets output as is into the body text. So I'd need to find a way to change all the keyword formats to work within a trigger that is based on asset created, with the triggering asset being an order. Order details I've always found incredibly difficult to get to if you can't use %response_ type keywords ... what would work?

Thanks! C.

 

 

 

Update 2:  I've just tried the workaround using the keyword modifiers. For simple bits it works fine, but the email body area is a WYSIWYG area, it allows me to switch it into code view but not to keep it all as raw html, so then the wysiwyg editor combined with the keywords messes up the formatting, and everytime I go in its added in extra <p>s etc, and it makes it unworkable to use in this way.

 

So I either need a fix to get proper conditional keywords working, or I need to know how to access all the form responses as keyword values of an order asset.

Thanks,

C.


(Peter McLeod) #4

Hi

 

Not sure if this would work for your scenario, and haven't used the ecommerce assets, so not sure if the form components work the same as elsewhere in matrix.

 

What if you add new metadata fields to your form asset to store the the html content you want output in the email. 

 

Then you could use something like:

%response_696787_q6^replace_keywords:notempty:{globals_asset_metadata_<FieldName>}%
Thanks
Peter

(Bart Banda) #5

Thanks Charlie, I'm guessing it's a bug that should be relatively easy to fix. So I'll get it on our radar to get fixed soon.

 

 

Update: Tried putting my original keywords into a trigger, but now none of the keywords work, eg %response_702101_q1% gets output as is into the body text. So I'd need to find a way to change all the keyword formats to work within a trigger that is based on asset created, with the triggering asset being an order. Order details I've always found incredibly difficult to get to if you can't use %response_ type keywords ... what would work?

 

 

The %response keywords won't work in a trigger as the asset in context is outside that of the form where those keywords are designed to work in.

 

Instead, try and use the %question_answer_X_qY% keyword or the %globals_post_X% keyword where X is the name of the form field. 

 

If you want to try and use other keyword modifier methods in the email format of the form, try also:

<div>%response_696787_q6^notempty:</div>
<p>Message for memorial wall:<p>
<p>This is the long message text</p>
<div>%</div>

Remember, you can have line breaks within your keyword modifier replacements. 


(Charlotte Westney) #6

Hi there,

 

I've just about managed to get it working, using the ^notempty modifier. It doesn't work perfectly though, yes you can put line breaks and html code within the modifier replacement - but in a WYSIWYG area most of that formatting gets screwed up*. And that's a huge disadvantage with the email options formatting areas - the HTML email area can't be forced to be raw html.  For any kind of decently formatted email body you really need to have control of your code, and even more so when using keyword modifiers. So...

 

Feature request:  Allow email option areas to be raw html format!

 

*technical term for when your tags end up looking like tangled spagetti.

 

Thanks both for your suggestions.

Charlie.


(Anthony Ponomarenko) #7

Hi Charlie,

 

We have identified your initial issue of the Condition Keywords not working in the Email Bodycopy as a Feature Request.

 

You can track the progress of it on Squizmap

 

Anthony


Keyword modifiers within email recipient options