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> </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>