I am working on an auto emailer script called by a cron job which runs through past orders and sends an invitation to comment on the purchase.
I have a dual language shop and so the emails have to be in the correct language.
I have an extra field for the order record which records the order language so it’s not a problem to retrieve the orders per language.
The problem is forcing zen_mail to use the correct language defines for the email template.
ie. the cron job would call something like emailer.php?lang=en or emailer.php?lang=es,
the script will pull out the english or spanish orders and use zen_mail to send them.
I can use specific (en or es) defines to put the correct language text in the body of the emails but once it goes through zen_mail it uses whatever language it feels like (it seems) to add in the template block email footer text/copyright/anti-spam etc.
In the script I have set the session variables to the relevant language values to try get zen_mail to cooperate but it doesn’t work.
$_SESSION['language'] = $language;
$_SESSION['languages_id'] = $lang_id;
$_SESSION['languages_code'] = $lang_code;
If I use this locally, the footer-text language used in the email is whatever I have chosen in the shop front but since this is being run from a cron
lynx --dump blah/blah/emailer.php?lang=en
I am guessing it is making its language decision on the browser language?
In any case I seem to regularly come across this issue of trying to force a session language so I would appreciate some insight into this issue or some general guidance on how to control it within Zen Cart as I evidently don’t understand it clearly enough,
Thanks
Steve
ps preview/editing of post not working for me in Chrome or FFox, text field always empty on preview.


Reply With Quote

