Email Placeholder Options

4 posts by 2 authors in: Forums > CMS Builder
Last Post: September 4, 2015   (RSS)

By Perchpole - August 27, 2015

Hello, All -

I've been putting together a couple of new email templates and an annoying issue has emerged...

Is it possible to (somehow) make a placeholder conditional? At the moment, if a value does not exist the placeholder leaves a blank line in the email. This is a bit of an annoyance!

:0/

Perch

By Perchpole - September 4, 2015

Hi, Dave -

The issue is more to do with rendering addresses than anything else. The placeholders look like this:

#order.shipping_first_name# #order.shipping_last_name#
#order.shipping_address_line_1#
#order.shipping_address_line_2#
#order.shipping_city#
#order.shipping_province#
#order.shipping_postal_code#
#order.shipping_country#

The problem is: #order.shipping_address_line_2#.

Only a small number of people will enter data into this field. As a result, the email will often render the address like this:

Joe Bloggs
29 Ponsenby Drive

Royston Vasey
Smithersdale
NN1 1GP
England

It leaves an ugly gap. My client uses some sort of accounting software and needs to copy and paste each address into a template. The gap in the address is causing him a lot of grief!

I just wondered if there was a way of skipping the field if no data is provided.

:0/

Perch

By Dave - September 4, 2015

Hi Perch, 

No, there's no way to skip it.  Probably what I'd do in the code is something like this: 

$placeholders['shipping_address_lines'] = implode("\n", array($placeholders['shipping_address_line_1'], $placeholders['shipping_address_line_2'])); 

And then replace this:

#order.shipping_address_line_1#
#order.shipping_address_line_2#

With this: 

#order.shipping_address_lines#

Let me know if that works for you.

Dave Edis - Senior Developer
interactivetools.com