I have a client that has increasingly been asking for more control over the emails sent through their ecommerce site. I originally hardcoded the email text in templates, but over a series of changes I now have admin-editable emails that can be customized for different user types and order emails can be changed based on the contents of the cart.
As I add on feature after feature, the original way I solved the problem is showing its limitations.
If I were the one customizing the emails, it would be fairly easy to solve all of these issues in a template because I have access to the “context” of the email and can write my own criteria:
<?php if ($user->isWineClubMember() && $cart->containsWine() && $cart->forPickup()): ?>
Insert text for a pickup order from a wine club member that contains wine
<?php endif; ?>
The challenge is giving some of that flexibility to the client, without creating an overly technical solution.
I’m wondering whether anyone else has been in a similar situation, and how they handled such detailed email customizations? Technical comments and user experience comments are welcome.
Could you not just have a series of boxes for each of the text pieces (e.g ‘text for pickup’, ‘text for delivery’, 'intro text etc) and then keep the conditionals in the php? They could then just edit snippets of the text (the only bit they care about) and not the email as a whole
Customize emails based on criteria…the only solution I see, is having a template with conditional tests like you demonstrated earlier.
Adding the conditionals in the template is really unavoidable, unless that is what your looking to accomplish somehow? The data made available to you as is, is enough? It’s just a matter of figuring out a way to make it easier for the client to tweak the email output based on that data?
So one client might want to show details to those subscribed to ‘general’ newsletter, another should see content only if they purchased products in the last 6 months?
I built a mailing/newsletter management application several years ago and when researchng competitors (CampaignMonitor, ChimpMail, phpList, etc) those programs would allow conditional statements inside the templates to customize the output based on variable criteria.
You appear to be using PHP templates so conditionals are a given. Alternatively, you can use placeholders (swapped out with str_replace) and inect those placeholders with simple variables (such as %%first_name%%) or mini-templates.
My advice, look into several of the top mailing list managers, email marketing solutions (as mentioned above) and see how they give their clients the absility to customize and tweak templates as required whilst still being user friendly.
My latest app lets my client create quotes for his products using a fairly complex HTML form. The php script converts the input from the form and info from databases into a text and an HTML message which can have inline images. To be able to handle it, I had to write an email class. This email class is about the fifth or seventh iteration of what started out as a simple text-only email function.
First it was one attachment, then multiple attachments, then html, then a proper bounce address, then inline images, and so it goes!