Page 1 of 3

Trying to improve product notification email

Posted: Mon Apr 25, 2022 8:09 am
by 14Steve14
Is there a way to add a product image into the notifications email that is sent to the customers?

I am going through the notification emails and updating the text so that they work as a sales email, and have got to the product stock notification email that is standard in core, and was just wondering if there is a way to add in an image of the product that the notification is about. I can alter the text its just seeing. and hoping if an image can be added as it will make the email more interesting and may mean that customers will read them.

Any help appreciated.

Re: Trying to improve product notification email

Posted: Mon Apr 25, 2022 9:02 am
by ecartz
Right now, the newsletter (and a product notification is just a particular type of newsletter) supports static HTML content (at least it does when HTML emails are turned on). So if you want to add an image, you should be able to just type in a static image element. Something like

Code: Select all

<img src="https://phoenixcart.org/demo/images/sample/lime-1.jpg" alt="Lime" title="Lime" />
@burt has suggested making an info pages based version that would let people embed dynamic elements in the email content, but I don't believe that anyone has engaged him to actually do that. So for now, static HTML is state-of-the-art.

Re: Trying to improve product notification email

Posted: Mon Apr 25, 2022 9:11 am
by LeeFoster
ecartz wrote: Mon Apr 25, 2022 9:02 am @burt has suggested making an info pages based version that would let people embed dynamic elements in the email content, but I don't believe that anyone has engaged him to actually do that. So for now, static HTML is state-of-the-art.
This would be a really good idea, especially if you can build different 'templates' to use to send out for different reasons - Product update, latest specials etc. Even more so if it can be linked to something like Mailchimp.

Re: Trying to improve product notification email

Posted: Mon Apr 25, 2022 9:23 am
by 14Steve14
ecartz wrote: Mon Apr 25, 2022 9:02 am Right now, the newsletter (and a product notification is just a particular type of newsletter) supports static HTML content (at least it does when HTML emails are turned on). So if you want to add an image, you should be able to just type in a static image element. Something like

Code: Select all

<img src="https://phoenixcart.org/demo/images/sample/lime-1.jpg" alt="Lime" title="Lime" />
@burt has suggested making an info pages based version that would let people embed dynamic elements in the email content, but I don't believe that anyone has engaged him to actually do that. So for now, static HTML is state-of-the-art.
Thanks for the info. I did wonder whether it was possible to pull in the product image as the basic email pulls in the customers first and last name and the product title, but may be an image is not possible.

I will contact Gary @burt unless he sees this and replies, to see what he is thinking about and may be discuss this with him. Keep it simple first and let a developer take it on as a more advanced project if people want it.

Re: Trying to improve product notification email

Posted: Mon Apr 25, 2022 10:22 am
by burt
It's an idea I had for the info pages - I don't think I ever did anything with it.
As I'm still getting up to speed on the new stuff in Phoenix, it's not a project I have the time to take on.

@raiwa
@BrockleyJohn
@zipurman
@ozeworks

Maybe some of you guys have something ready baked for outgoing emails?


I did (July 2016 by the look of it) make a system of emailing that used Mandrill for outgoing emails, this was for a very early version of the CE (ie pre phoenix) so had lots of core code changes. See below for example code...which included the product images. Note that Mandrill is super complicated as you pass an array of data to Mandrill, Mandrill then uses that array of data in an email template and lovely looking email is sent to the client...

Mandrill is an excellent system, once it is up and running.

Code: Select all

  $mandrill_order = new order($insert_id);
  
  for ($i=0, $n=sizeof($mandrill_order->products); $i<$n; $i++) {
    $mandrill_ordered_attributes = null;
    
    // get the products image...not stored as part of order
    $products_image_query = tep_db_query("select products_image from products where products_id = " . (int)$mandrill_order->products[$i]['id']);
    $products_image = tep_db_fetch_array($products_image_query);
    
    if ( (isset($mandrill_order->products[$i]['attributes'])) && (sizeof($mandrill_order->products[$i]['attributes']) > 0) ) {
      for ($j=0, $n2=sizeof($mandrill_order->products[$i]['attributes']); $j<$n2; $j++) {
        $mandrill_ordered_attributes .= '<br><small>- ' . $mandrill_order->products[$i]['attributes'][$j]['option'] . ': ' . $mandrill_order->products[$i]['attributes'][$j]['value'] . '</small>';
      }
    }
    $mandrill_product_content[] = ['PRODUCT_ID'    => (int)$mandrill_order->products[$i]['id'],
                                   'PRODUCT_IMAGE' => tep_href_link(DIR_WS_IMAGES . $products_image['products_image'], '', 'NONSSL', false, false),
                                   'PRODUCT_QTY'   => $mandrill_order->products[$i]['qty'],
                                   'PRODUCT_NAME'  => $mandrill_order->products[$i]['name'] . $mandrill_ordered_attributes,
                                   'PRODUCT_MODEL' => $mandrill_order->products[$i]['model'],
                                   'PRODUCT_PRICE' => $currencies->display_price($mandrill_order->products[$i]['price'], $mandrill_order->products[$i]['tax'], 1),
                                   'FINAL_PRICE'   => $currencies->display_price($mandrill_order->products[$i]['final_price'], $mandrill_order->products[$i]['tax'], $mandrill_order->products[$i]['qty'])];
  }
  
  $order_totals_query = tep_db_query("select class, text from orders_total where orders_id = " . (int)$insert_id . " order by sort_order");
  while ($order_totals = tep_db_fetch_array($order_totals_query)) {
     $mandrill[$order_totals['class']] = strip_tags($order_totals['text']);
  }
  
  $mergable_vars = [
                    ['name' => 'CUSTOMER_NAME',         'content' => $mandrill_order->customer['name']],
                    ['name' => 'CUSTOMER_FNAME',        'content' => $customer_first_name],
                    ['name' => 'CUSTOMER_EMAIL',        'content' => $mandrill_order->customer['email_address']],
                    ['name' => 'ORDER_ID',              'content' => (int)$insert_id],
                    ['name' => 'ORDER_SHIPTO',          'content' => tep_address_label($customer_id, $sendto, 0, '', ', ')],
                    ['name' => 'ORDER_BILLTO',          'content' => tep_address_label($customer_id, $billto, 0, '', ', ')],
                    ['name' => 'ORDER_STATUS_NAME',     'content' => $mandrill_order->info['orders_status_name']],
                    ['name' => 'ORDER_PAYMENT_METHOD',  'content' => $mandrill_order->info['payment_method']],
                    ['name' => 'ORDER_SHIPPING_METHOD', 'content' => $mandrill_order->info['shipping_method']],
                    ['name' => 'ORDER_COMMENTS',        'content' => tep_db_output($comments)],
                    ['name' => 'ORDER_ACCOUNT_URL',     'content' => tep_href_link('account_history_info.php', 'order_id=' . (int)$insert_id, 'SSL', false, false)],
                    ['name' => 'ORDER_PRODUCTS',        'content' => $mandrill_product_content],
                    ['name' => 'ORDER_SUBTOTAL',        'content' => $mandrill['ot_subtotal']], 
                    ['name' => 'ORDER_SHIPPING',        'content' => $mandrill['ot_shipping']],
                    ['name' => 'ORDER_TOTAL',           'content' => $mandrill['ot_total']],
                    ['name' => 'ORDER_DATE',            'content' => tep_date_long($mandrill_order->info['date_purchased'])]
                   ];
                
  mandrill_mail($mandrill_order->customer['name'], $mandrill_order->customer['email_address'], EMAIL_TEXT_SUBJECT, 'checkoutsale', $mergable_vars, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, $email_order);
  
With this (simplistic example) Template (aka Slug) at the Mandrill end:

Code: Select all

<h1>Hey {{CUSTOMER_FNAME}}, thanks for purchasing from {{SHOP_NAME}}!</h1>

<p>Here is a summary of your Order #{{ORDER_ID}}:</p>

<table width="100%" cellspacing="0" cellpadding="0">
    <tr>
        <th>&nbsp;</th>
        <th>ID</th>
        <th>Model</th>
        <th>Quantity</th>
        <th>Name</th>
        <th>Price</th>
        <th>Final Price</th>
    </tr>
    {{#each ORDER_PRODUCTS}}
    <tr>
        <td><img src="{{PRODUCT_IMAGE}}" alt="{{PRODUCT_NAME}}"/></td>
        <td>{{PRODUCT_ID}}</td>
        <td>{{PRODUCT_MODEL}}</td>
        <td>{{PRODUCT_QTY}}</td>
        <td>{{{PRODUCT_NAME}}}</td>
        <td>{{PRODUCT_PRICE}}</td>
        <td>{{FINAL_PRICE}}</td>
    </tr>
    {{/each}}    
    <tr>
        <td colspan="7"><hr></td>
    </tr>    
    <tr>
        <td colspan="6" align="right">Sub Total: </td>
        <td>{{ORDER_SUBTOTAL}}</td>
    </tr>  
    <tr>
        <td colspan="6" align="right">Shipping: </td>
        <td>{{ORDER_SHIPPING}}</td>
    </tr>
    <tr>
        <td colspan="6" align="right">Total: </td>
        <td>{{ORDER_TOTAL}}</td>
    </tr> 
</table>

<hr>

<table width="100%" cellspacing="0" cellpadding="0">
    <tr>
        <td><b>Shipping To:</b></td>
        <td>{{ORDER_SHIPTO}}</td>        
    </tr>
    <tr>
        <td><b>Billing To:</b></td>
        <td>{{ORDER_BILLTO}}</td>
    </tr>
    <tr>
        <td><b>Order Status:</b></td>
        <td>{{ORDER_STATUS_NAME}}</td>        
    </tr>
    <tr>
        <td><b>Order Comments:</b></td>
        <td>{{ORDER_COMMENTS}}</td>        
    </tr>
    <tr>
        <td><b>Payment Method:</b></td>
        <td>{{ORDER_PAYMENT_METHOD}}</td>        
    </tr>
    <tr>
        <td><b>Shipping Method:</b></td>
        <td>{{ORDER_SHIPPING_METHOD}}</td>        
    </tr>
</table>    


<p>You can see a more detailed Order Summary at <a href="{{ORDER_ACCOUNT_URL}}">Your Account</a>.

<p>Thank You</p>

<hr>

<p><strong>Sent by {{SHOP_NAME}}.</strong> This email address was given to us by one of our customers. If you did not signup to be a member, please send an email to <a href="mailto:{{SHOP_EMAIL}}">{{SHOP_EMAIL}}</a></p>

Re: Trying to improve product notification email

Posted: Mon Apr 25, 2022 10:24 am
by burt
Above post is the "you just made an order" email that goes out when the buyer has just finished checkout. Which is obviously not the notification email, but may give you @14Steve14 Steve or the Cert Dev's some ideas maybe.

Obv bear in mind that this was made in a very early CE version (July 2016 would have been only 6 months or so into the CE journey), so the codebase would now be substantially different (more complicated, but easier to make changes without core code having to be changed)

Re: Trying to improve product notification email

Posted: Mon Apr 25, 2022 10:30 am
by raiwa
This adds product images to the order confirmation mail (with notification module hook):
https://phoenixcart.org/forum/app.php/ ... ce_orders/

EDIT: Sorry, I mixed it up. The above one overrides the notification module,
PWA modifies the order confirmation and order update mail content with hook:
app.php/addons/free_addon/purchase_without_account/

Re: Trying to improve product notification email

Posted: Wed Apr 27, 2022 5:05 pm
by 14Steve14
Been adjusting the email text that is sent and so far two customers have come back and bought the products and emailed me to say thanks. The email is nothing special and has yet to have a product image added, but it does sort of show that the emails do some good.

Now just to work my way through all the other emails to make them just as effective, and to make sure that they include all the legal rubbish that is now required in emails.

Thanks for the suggestions also. Some food for thought for later.

Re: Trying to improve product notification email

Posted: Wed May 04, 2022 7:40 am
by burt
Would really like to see what you end up with Steve (ie the email that someone would receive from you) after you are completed with your changes. Maybe we can incorporate your ideas into the core code..

Re: Trying to improve product notification email

Posted: Tue May 24, 2022 6:29 am
by Pierre_P
Hello @14Steve14 @Dan Cole

I'm on the same road to html mails as my older Phoenix are still using Uhtmls

There was an old discussion on this that Dan started on html emails at https://forums.oscommerce.com/topic/496 ... nt-1817019
Dan did manage to get html emails working using the Pages addon on a earlier version of Phoenix.

For me this is a bit vague but will also give it a try!