Proposed structure for new email templating system #5499
Replies: 22 comments 53 replies
-
It is encouraging to see some new enthusiasm and effort, albeit misguided in my opinion. Where is the demand for the email template system to be rewritten? Will the description of an up-to-date method tempt potential users to try Zen Cart? Who looks at their email system once their shop is set up and working? Does Zen Cart have more serious problems? I guess you have read this #4805 |
Beta Was this translation helpful? Give feedback.
-
I think anyone who tries to make a contribution however small, should be applauded and encouraged. Not everyone agrees with that. But contributors are not even in double figures and getting less, if that's possible. But, with no roadmap to focus development efforts nor any attempt being made to arrest the overall decline or market share, is your time well-spent? It's not all awful at all. But is making such a big effort to improve an already-great product the best use of your input, if fewer and fewer people are thinking of using it?
I've been constructive for 12 years and as I am not a developer I have no profit to make from the product. In my current economic situation I can't justify the time it takes me to compose these posts to reinforce what I've already said, nor to justify my efforts to contribute. |
Beta Was this translation helpful? Give feedback.
-
A thought on the proposed solution, that it seems silly to repeat the general structure of an email template for each language, e.g. every single english, spanish etc. template has to contain the entire HTML structure. This raises a high likelihood of error, by corrupting the HTML in one template and not noticing it, or making a change in one and not propagating it to the others. So, this is very inefficient, it makes more sense to have a single template defining the structure. What I'm coming around to is actually something a lot more like the current system with its language strings like EMAIL_GREETING, and having made that decision, we have at least two optional directions to go in. I still like both, but the use of a templating system isn't absolutely necessary to achieve the requirements from #2695. The sticking points with the requirements was that the contents aren't easily editable, both that the email template file like
I like the way the old system has a single template with a placeholder like EMAIL_GREETING, and it's up to the language files to define that content. Imagine with a Smarty (or similar, I'm going to stick with Smarty until someone proposes an alternative that makes sense) template that's designed to be language agnostic, unlike the one I proposed at the top. This solution has split into two directions:
What I'm trying to achieve here is:
For example, an email template that is language agnostic:
Associated defines brought in from the current language files lang.email.php:
Any file that's editable by the user should be considered fluid and subject to change. Currently I manage all email templates and Has there been an effort in the past to extend the Define Pages admin edit page to edit more than just that? Any other feedback? @scottcwilson you say you've had similar requests from clients, how far down each of these paths would you be willing to entertain? Let's presume that developer resources are infinite at this point and just talk about what we would want. |
Beta Was this translation helpful? Give feedback.
-
Have you considered Twig instead of Smarty? I'm attaching the email templates (Twig based) that OpenCart uses for your consideration |
Beta Was this translation helpful? Give feedback.
-
Blade is another option too. I don't have a strong preference, just wanted to be sure you have considered a few options. |
Beta Was this translation helpful? Give feedback.
-
One small tweak to your original post - please don't use Your original design would be much easier for non-technical storeowners to tweak their emails. Is your vision of text email that we'd simply do a |
Beta Was this translation helpful? Give feedback.
-
The goals I'd like to accomplish in this work are:
|
Beta Was this translation helpful? Give feedback.
-
Translating email templates is just another task for language translators. This is a nice step forward.
They do. https://docs.zen-cart.com/user/email/html_email_templates/ |
Beta Was this translation helpful? Give feedback.
-
We're going to have to use more precise language moving forward to prevent confusion. The new email templates will contain translated strings.
|
Beta Was this translation helpful? Give feedback.
-
Bear in mind too that you could hypothetically provide an editor for language strings (for email only). Look at (for example) |
Beta Was this translation helpful? Give feedback.
-
I'm hoping you (somehow) can bake in the functionality of Preview Email too. |
Beta Was this translation helpful? Give feedback.
-
I have pushed work so far to https://github.com/neekfenwick/zencart/tree/discussion-5499 .. initial work in Feb/March went pretty well but I was discouraged by the small amount of interest expressed here so stopped work for a while. It is very much a Work In Progress so please be kind, treat this as a curiosity rather than any kind of formal review, but comments on the broad approach are welcome. I'll need to iterate quite a bit as I focus on more than the 2 emails I've done so far. Some notes:
Some changes to note:
Example data model:
Additionally, put data required by the template:
This model is then processed by the Blade engine as it expands the template. |
Beta Was this translation helpful? Give feedback.
-
In moving the construction of the order confirmation email ('checkout') I ran into this beauty: zencart/includes/classes/order.php Lines 1225 to 1243 in f10838c Can anyone say if I'm moving all text/html construction out of functions like |
Beta Was this translation helpful? Give feedback.
-
Minor point: Text version of 'checkout' order confirmation email was missed 'Shipping method'. I've added it. I'm also adding a common header to the text versions of emails that wasn't there before, the way text bodies were built was a bit Wild West, for example |
Beta Was this translation helpful? Give feedback.
-
FYI my dev branch is at https://github.com/neekfenwick/zencart/tree/discussion-5499 - I'm maintaining a local .md file to track progress, I'll put it here and Edit it as I go, if that helps track where I'm at.
|
Beta Was this translation helpful? Give feedback.
-
Wanted to point out the Describing the bug: The coupon stuff seems well handled, Some dev context: My new system under development does not rely on
The new system:
|
Beta Was this translation helpful? Give feedback.
-
To note another old bit of cruft I ran into: Gift Vouchers, 'Send Gift Voucher' feature,
This is only true if I do see the sense in such a warning, given that this one On top of this, the
This isn't true, that advisory is only ever sent in the So, I'll fix the |
Beta Was this translation helpful? Give feedback.
-
Lots of great progress here. I will spend some more time looking at this next week. Thanks! |
Beta Was this translation helpful? Give feedback.
-
By the way I ran into the PHPUnit tests in |
Beta Was this translation helpful? Give feedback.
-
Am I right in thinking the Until now I had presumed all emails should look 'pretty', and so even passing a plain string as the mail body should use the 'default' template and put a header/footer on it. Now I look at the old behaviour, passing a plain string specifically omitted the HTML portion and just sends a non-MIME plain text email with that string, so I've introduced a regression. I think I've seen store owners comment on the forum they like this behaviour, to just get a simple text admin email without any faff. I'll look at reverting some of my work to make this old behaviour the norm with the new template system. |
Beta Was this translation helpful? Give feedback.
-
I've got the admin page for editing email templates working to a good degree and am hitting some nitty gritty details that need sorting out. When editing an email template on the admin page, we want to present a set of editable strings that are used to build the email. I'd like some advice on how to handle the fact that the PHP files containing the strings are often not directly related to the email being edited. Taking a meaty example, the Some possible solutions:
What do you guys with a longer view of the project think? Has it been irksome for some time that the lang strings sometimes come from rather hard to deduce places, and is there a plan fomenting anywhere to reorganise them, in which case now would be a great time to do it? Side note: email generation actually generally depends on two data sources, 1/ the lang strings mentioned above and 2/ raw data specific to the task e.g. |
Beta Was this translation helpful? Give feedback.
-
This work has sat on a branch for a long time and I feel it needs a serious push to reach PR status and get some serious attention from core devs or it might miss a major ZC release and become too difficult to release. I'm planning to cut back on the scope of my work on this to remove the editing of lang strings. It's just too thorny, and I haven't had clear answers to a couple of questions about refactoring lang string files, it's simpler to leave it out here and add as a new feature later on. One thing I do need to finalise here is the file structure for email templates. Old templates are of the form |
Beta Was this translation helpful? Give feedback.
-
This discussion arose on #2695
It occurred to me that instead of strings for the emails being in language defines, like a made up example:
The difference in language would instead be in each email template, and you'd need a template per supported language, e.g.
Is this an acceptable direction? Any other suggestions for how to structure it?
On the subject of data, I'm a fan of putting conditional logic, loops etc in my Smarty templates, so having a order details and a list of products would be by something like:
and in the template, have Smarty functions like
if
andforeach
, instead of writing PHP code that acts on configuration and logic before settings strings that go into the template:This is standard templating technique and very different to how Zen Cart currently builds its email content, we'd be moving a lot of PHP logic into the Smarty template. Any feedback on this general approach?
Beta Was this translation helpful? Give feedback.
All reactions