Just a quick add-on to this great mod: my client wanted the vendor emails to be sent at *checkout* time, not when they were processed in admin... I've hacked together this code which seems to do the trick, after installing via the instructions add the code below to checkout_process.php after the "send emails to other people" block.
This also fixes the attributes query as they were not coming through correctly in on my system. Remember to backup, etc ;)
//vendors email begin
// Get the delivery address
$delivery_address_query = tep_db_query("select distinct delivery_company, delivery_name, delivery_street_address, delivery_city, delivery_state, delivery_postcode from " . TABLE_ORDERS . " where orders_id='" . $insert_id ."'");
$delivery_address_list = tep_db_fetch_array($delivery_address_query);
//find out what shipping methods the customer chose
$shipping_method_query = tep_db_query("select title from " . TABLE_ORDERS_TOTAL . " where orders_id='" . $insert_id . "' and class = 'ot_shipping'");
$shipping_method = tep_db_fetch_array($shipping_method_query);
$vendors_email_query = tep_db_query("select distinct o.orders_id, v.vendors_id, v.vendors_name, v.vendors_email, v.vendors_contact, v.vendor_add_info, v.vendor_street, v.vendor_city, v.vendor_state, v.vendors_zipcode, v.vendor_country, v.account_number, o.products_id, o.orders_products_id FROM " . TABLE_VENDORS . " v, " . TABLE_ORDERS_PRODUCTS . " o, " . TABLE_PRODUCTS . " p where p.vendors_id=v.vendors_id and o.products_id=p.products_id and o.orders_id='" . $insert_id . "' and v.vendors_send_email=1 GROUP BY vendors_id");
while ($vendors_email_list= tep_db_fetch_array($vendors_email_query)) {
$order_number='" . $insert_id . "';
$the_email=$vendors_email_list['vendors_email'];
$the_name=$vendors_email_list['vendors_name'];
$the_contact=$vendors_email_list['vendors_contact'];
$email= $the_contact . ' <br>' . $the_name . '<br>' . $the_email . '<br>' .
$vendors_email_list['vendor_street'] .'<br>' .
$vendors_email_list['vendor_city'] .', ' .
$vendors_email_list['vendor_state'] .' ' .
$vendors_email_list['vendors_zipcode'] . ' ' . $vendors_email_list['vendor_country'] . '<br>' . "\n" . EMAIL_SEPARATOR . "\n" . 'Special Comments or Instructions: ' . $vendors_email_list['vendor_add_info'] .'' . "\n" . EMAIL_SEPARATOR . "\n" . 'From: ' . STORE_OWNER . "\n" . STORE_NAME_ADDRESS . "\n" . 'Accnt #: ' . $vendors_email_list['account_number'] . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_ORDER_NUMBER . ' ' . $insert_id . "\n" . EMAIL_SEPARATOR . "\n" . '<br>';
// Get all the products to be included in the email
$vendors_email_products_query = tep_db_query("select distinct o.orders_id, o.orders_products_id, v.vendors_id, p.vendors_prod_comments, o.products_name, p.vendors_prod_id, o.products_model, o.products_id, o.products_quantity, p.vendors_product_price, o.orders_products_id FROM " . TABLE_VENDORS . " v, " . TABLE_ORDERS_PRODUCTS . " o, " . TABLE_PRODUCTS . " p where p.vendors_id=v.vendors_id and v.vendors_id='" . $vendors_email_list['vendors_id'] . "' and o.products_id=p.products_id and o.orders_id='" . $insert_id . "' order by o.products_name");
$email = $email . '<table width="75%" border=1 cellspacing="0" cellpadding="3">
<tr><td>Qty:</td><td>Product Name:</td><td>Item Code/Number:</td><td>Product Model:</td><td>Per Unit Price:</td><td>Item Comments: </td></tr>';
while ($vendors_email_products= tep_db_fetch_array($vendors_email_products_query)) {
$product_attribs ='';
$vendors_email_products_attrib_query = tep_db_query("SELECT products_options, products_options_values FROM " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " WHERE 1 AND orders_products_id = '" . $vendors_email_products['orders_products_id'] . "'");
while ($vendors_email_products_attribs = tep_db_fetch_array($vendors_email_products_attrib_query)) {
$product_attribs .= $vendors_email_products_attribs['products_options'] . ': ' . $vendors_email_products_attribs['products_options_values'] . '<br>';
}
$email = $email . '<tr><td> ' . $vendors_email_products['products_quantity'] .
'</td><td> ' . $vendors_email_products['products_name'] . '<br>' . $product_attribs .
'</td><td> ' . $vendors_email_products['vendors_prod_id'] .
'</td><td> ' . $vendors_email_products['products_model'] .
'</td><td> ' . $vendors_email_products['vendors_product_price'] . '</td><td>' .
$vendors_email_products['vendors_prod_comments'] . '</td></tr>';
}
$email = $email . '</table><br>';
//send the email
tep_mail($the_name, $the_email, EMAIL_TEXT_ORDER_NUMBER . ' ' . $insert_id , $email . '<br>', STORE_NAME, STORE_OWNER_EMAIL_ADDRESS) ;
}
//vendors_email end
You also need to add
define('TABLE_VENDORS', 'vendors');
to catalog/includes/database_tables.php
Many thanks to blucollarguy for this great mod :D