Trying to improve product notification email

Open to all! Ask other shopowners for help.
User avatar
burt
Core Team
Posts: 4561
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 422 times

Re: Trying to improve product notification email

Post by burt »

Do bear in mind, that once you send out an email with images, you can never delete (or move) those images from your server...as the recipient might come back to the email in a month, year or 5 years and see a broken image placeholder rather than (eg) your logo/product image etc.
I am not here to build for you.
I am here to build with you. Let's help each other.


Join The Code Co-op to get access to your library in the Code Co-op Forum
heatherbell
Senior Contributor
Posts: 2540
Joined: Mon Oct 07, 2019 4:39 am
Phoenix Version:
Has thanked: 35 times
Been thanked: 243 times

Re: Trying to improve product notification email

Post by heatherbell »

ecartz wrote: Mon Apr 25, 2022 9:02 am supports static HTML content (at least it does when HTML emails are turned on).
We have had no issues with sending HTML emails with PHP 7.4.
We updated to PHP 8.0 and now emails are being received with additional code and are not displayed as expected e.g.

Code: Select all

--=_270f01f94224d71ab1595d294b82d3e5
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Reverted to PHP 7.4 and HTML emails are then received displaying as expected again.
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Trying to improve product notification email

Post by ecartz »

heatherbell wrote: Fri Jul 15, 2022 4:52 am We updated to PHP 8.0 and now emails are being received with additional code and are not displayed as expected
I'm guessing that this relates to https://stackoverflow.com/q/70502065/6660678

I.e. change your line endings to CRLF for PHP 8, even when using sendmail/Linux.
heatherbell
Senior Contributor
Posts: 2540
Joined: Mon Oct 07, 2019 4:39 am
Phoenix Version:
Has thanked: 35 times
Been thanked: 243 times

Re: Trying to improve product notification email

Post by heatherbell »

ecartz wrote: Fri Jul 15, 2022 6:19 am I'm guessing that this relates to https://stackoverflow.com/q/70502065/6660678
I.e. change your line endings to CRLF for PHP 8, even when using sendmail/Linux.
Yes, your guess is spot on! Many thanks. :)
Configuration > E-Mail Options > E-Mail Linefeeds, changed to CRLF and now HTML emails displayed as expected.
User avatar
Pierre_P
Contributor
Posts: 144
Joined: Fri Mar 12, 2021 5:06 am
Phoenix Version: v1.1.0.6
Has thanked: 21 times
Been thanked: 11 times

Re: Trying to improve product notification email

Post by Pierre_P »

One or two probably silly questions about the order update notification using info_pages

I did manage to convert update order and create account notifications to show correctly using info pages.
When getting to n_update_order.php im stuck.
I have created an info page in admin with slug store_checkout
In admin editing this info page i tried using {{ORDER_ID}} or '{{ORDER_ID}}' or [[ORDER_ID]] but this is not working at all.
Using %3$s or so for this array is obviously not the way

In n_update_order.php i have added many placeholders to name a couple:

Code: Select all

        $placeholders = [
            ['name' => 'CUSTOMER_NAME',        'content' => $order->customer['name']],
            ['name' => 'CUSTOMER_EMAIL',        'content' => $order->customer['email_address']],
            ['name' => 'ORDER_ID',                     'content' => $order->get_id()],
            
then for array $placeholders i have:

Code: Select all

$email_body = sprintf($pages['pages_text'], $order->customer['name'], $order->customer['email_address'], $placeholders);
Any suggestions on this? Thx.
User avatar
burt
Core Team
Posts: 4561
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 422 times

Re: Trying to improve product notification email

Post by burt »

You've made placeholders too complicated, always keep it simple;

$placeholders = [
'CUSTOMER_NAME' => 'Mickey',
'CUSTOMER_EMAIL' => 'Mouse',
'ORDER_ID' => '123',
];

Now you can do $placeholders['CUSTOMER_NAME'] to return that customers name.

eg; in the language file;

const BLAH_BLAH = 'Hi %1$s, we updated your order %2$s. %1$s if you need to get in touch, please email us on ...';

Then using the language define in some other file (the processing file, the one that sends email);

sprintf(BLAH_BLAH, $placeholders['CUSTOMER_NAME'], $placeholders['ORDER_ID']);

Would result in;
Hi Mickey, we updated your order 123. Mickey if you need to get in touch, please email us on ...
The %1$s %2$s %3$s etc mean NOTHING until you pass data into the language define/const. You could just as easily pass;

sprintf(BLAH_BLAH, $placeholders['ORDER_ID'], $placeholders['CUSTOMERS_NAME']);

which would result in;
Hi 123, we updated your order Mickey. 123 if you need to get in touch, please email us on ...
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Trying to improve product notification email

Post by ecartz »

heatherbell wrote: Fri Jul 15, 2022 6:28 am Configuration > E-Mail Options > E-Mail Linefeeds, changed to CRLF and now HTML emails displayed as expected.
@Omar_one Fix for email content not appearing in PHP 8.
User avatar
Pierre_P
Contributor
Posts: 144
Joined: Fri Mar 12, 2021 5:06 am
Phoenix Version: v1.1.0.6
Has thanked: 21 times
Been thanked: 11 times

Re: Trying to improve product notification email

Post by Pierre_P »

burt wrote: Thu Nov 09, 2023 11:00 am 'CUSTOMER_NAME' => 'Mickey',
'CUSTOMER_EMAIL' => 'Mouse',
'ORDER_ID' => '123',
Burt, using the sprintf for checkout it's a lengthy one.
Using info_pages i did manage to get create account and update order successfully, the checkout page is bit more frustrating for me getting al the html table tags to show correct format.
Altering the info page later i will have no idea what all the placeholders were for reference.

What i rather want to know is can we use for example like a short tag for CUSTOMER_NAME, then in info_pages to be {{CUSTOMERS_NAME}} instead of placeholders from sprintf ? - similar to canned comments (Magical Unicorns) ;)
Omar_one
Senior Contributor
Posts: 679
Joined: Fri Oct 25, 2019 5:06 pm
Phoenix Version: v1.0.8.16
Has thanked: 100 times
Been thanked: 56 times

Re: Trying to improve product notification email

Post by Omar_one »

ecartz wrote: Sat Nov 11, 2023 10:17 pm
heatherbell wrote: Fri Jul 15, 2022 6:28 am Configuration > E-Mail Options > E-Mail Linefeeds, changed to CRLF and now HTML emails displayed as expected.
@Omar_one Fix for email content not appearing in PHP 8.
thank you @ecartz
I have changed that ..this fix the Order Update email which send by admin, but not order confirmation email which the customers got after buying ,, still order info not shown there, but the product reviews links appearing the email ,
am not sure if the issue from core or from Purchase Without Account module as this module which effect on the "listen_orderMail" method on shop side


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply