// Get all the manufacturers emails to be sent to // Must have an email address and have manufacturers_send_email set to 1 $manufacturers_email_query = tep_db_query("select distinct m.manufacturers_email, m.manufacturers_name FROM manufacturers m, orders_products o, products p where p.manufacturers_id=m.manufacturers_id and p.products_id=o.products_id and o.orders_id='" . $oID . "' and m.manufacturers_send_email=1 ORDER BY m.manufacturers_id"); while ($manufacturers_email_list= tep_db_fetch_array($manufacturers_email_query)) { $the_email=$manufacturers_email_list['manufacturers_email']; $the_name=$manufacturers_email_list['manufacturers_name']; $email_message = '
To: ' . $the_name . ' - ' . $the_email . ' From: ' . STORE_NAME . '



Please deliver to:
' . $delivery_address_list['customers_company'] .'
' . $delivery_address_list['customers_name'] .'
' . $delivery_address_list['customers_street_address'] .'
' . $delivery_address_list['customers_postcode'] . ' ' . $delivery_address_list['customers_city'] . '
' ; // Get all the products for a manufacture to be included in the email $manufacturers_email_products_query = tep_db_query("select o.orders_id, m.manufacturers_id, m.manufacturers_name, m.manufacturers_email, o.products_name, o.products_model, o.products_id, o.products_price, o.products_quantity, o.orders_products_id FROM manufacturers m, orders_products o, products p where p.manufacturers_id=m.manufacturers_id and o.products_id=p.products_id and o.orders_id='" . $oID . "' and m.manufacturers_email='" . $the_email . "' order by o.products_name"); $email_message = $email_message . '' ; while ($manufacturers_email_products= tep_db_fetch_array($manufacturers_email_products_query)) { $email_message = $email_message . ''; $current_products_id=$manufacturers_email_products['orders_products_id']; $manufacturers_email_products_attributes_query = tep_db_query("select distinct opa.products_options_values from orders_products_attributes opa, orders o where opa.orders_id='" . $oID . "' and opa.orders_products_id='" .$current_products_id . "'"); while ($manufacturers_email_products_attributes= tep_db_fetch_array($manufacturers_email_products_attributes_query)) { $email_message = $email_message . ''; } $email_message = $email_message . '
'; } $email_message = $email_message . '
Qty:Productname:Productmodel:Price:
' . $manufacturers_email_products['products_quantity'] . '' . $manufacturers_email_products['products_name'] . '' . $manufacturers_email_products['products_model'] . '' . $manufacturers_email_products['products_price'] . '
 '. $manufacturers_email_products_attributes['products_options_values'] .'



'; //send the email