BrianPhilipson Posted September 25, 2010 Share Posted September 25, 2010 Hi,I'm adding a bit of functionality to email my Manufacturer automatically when an order is received for one of his products. I've added his email address to the "other" section and in PaymentModule.php am loading an array with the manufacturers ID from the product: if (!array_key_exists($product['id_manufacturer'], $ClManuArray)) $ClManuArray[] = $product['id_manufacturer']; I now want to use the ID to read the address table so that I can get the email address in the 'other' field. I know how to do this using regular PHP I.e. Select from Address where id_manufacturer = $ClManuArray[0] etc. but can't get my head around doing it in Prestashop. AdminManufacturers.php seems to do it: $addresses = $manufacturer->getAddresses(intval($cookie->id_lang)); But I'm not sure if that will work in PaymentModule.php.Many thanks,Brian. Link to comment Share on other sites More sharing options...
MrBaseball34 Posted September 27, 2010 Share Posted September 27, 2010 I think it will work if you do something like this. It has not been tested, BTW... ;-)During the iteration of the products, around line(154) foreach ($products AS $key => $product) Try something this: // this loads the manuafacturer from the product $manufacturer = new Manufacturer($product->id_manufacturer, intval($cookie->id_lang)); // load this manufacturer's addresses $addresses = $manufacturer->getAddresses(intval($cookie->id_lang)); // Builds a list of recipients from the addresses foreach($addresses as $key => $address) { $manuf_email .= ", ".$address->other; } // remove the comma at the beginning of the string // May not want to do this because you will be adding these // to your recipients below // $manuf_email = substr($manuf_email, 2); unset($addresses); unset($manufacturer); Then you can change this line (around 360) to add the manuf recipients: Mail::Send(intval($order->id_lang), 'order_conf', 'Order confirmation', $data, $customer->email.$manuf_email, // here we are appending to the the recipients $customer->firstname.' '.$customer->lastname, NULL, NULL, $fileAttachment); Personally, I'd send the manufacturer a separate email but you can do it any way you want. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now