overbags Posted April 17 Share Posted April 17 (edited) hello everyone I have an old module decommissioned by the developer that sends the cart to the email indicated in the sending form I would need to receive the same email to another email address I've been trying to figure out how to do it all day but without success I think I understood that the code that sends the email is this if (!count($this->errors)) { if (@Mail::Send( (int)$currentCart->id_lang, 'shopping_cart', Mail::l('Carrello condiviso', (int)$currentCart->id_lang), $templateVars, $email, $name, $this->context->customer->email, $this->context->shop->name, $file_attachement, null, $this->module->getLocalPath() . 'mails/' )) { $ids = $this->getIdCartRules($currentCart); // Add log when send mail to guest success! if (!Db::getInstance()->insert('ets_savemycart', [ 'id_cart' => (int)$currentCart->id, 'token' => $token, 'cart_rules' => implode(',',$ids), ] )) { $this->errors[] = $this->module->l('Adding log failed.', 'submit'); } die(json_encode([ 'ok' => 1, 'msg' => $this->module->l('Mail sent successfully.', 'submit') ])); } else $this->errors[] = $this->module->l('Sending mail failed.', 'submit'); } I tried adding $email = $email .', [email protected]'; but it doesn't work Edited April 17 by overbags solved (see edit history) Link to comment Share on other sites More sharing options...
ComGrafPL Posted April 17 Share Posted April 17 38 minutes ago, overbags said: hello everyone I have an old module decommissioned by the developer that sends the cart to the email indicated in the sending form I would need to receive the same email to another email address I've been trying to figure out how to do it all day but without success I think I understood that the code that sends the email is this if (!count($this->errors)) { if (@Mail::Send( (int)$currentCart->id_lang, 'shopping_cart', Mail::l('Carrello condiviso', (int)$currentCart->id_lang), $templateVars, $email, $name, $this->context->customer->email, $this->context->shop->name, $file_attachement, null, $this->module->getLocalPath() . 'mails/' )) { $ids = $this->getIdCartRules($currentCart); // Add log when send mail to guest success! if (!Db::getInstance()->insert('ets_savemycart', [ 'id_cart' => (int)$currentCart->id, 'token' => $token, 'cart_rules' => implode(',',$ids), ] )) { $this->errors[] = $this->module->l('Adding log failed.', 'submit'); } die(json_encode([ 'ok' => 1, 'msg' => $this->module->l('Mail sent successfully.', 'submit') ])); } else $this->errors[] = $this->module->l('Sending mail failed.', 'submit'); } I tried adding $email = $email .', [email protected]'; but it doesn't work What about: if (!count($this->errors)) { $mailSent = Mail::Send( (int)$currentCart->id_lang, 'shopping_cart', Mail::l('Carrello condiviso', (int)$currentCart->id_lang), $templateVars, $email, // original recipient $name, $this->context->customer->email, $this->context->shop->name, $file_attachement, null, $this->module->getLocalPath() . 'mails/' ); // Send a copy to another address $copySent = Mail::Send( (int)$currentCart->id_lang, 'shopping_cart', Mail::l('Carrello condiviso', (int)$currentCart->id_lang), $templateVars, '[email protected]', // second recipient 'Backup Recipient', $this->context->customer->email, $this->context->shop->name, $file_attachement, null, $this->module->getLocalPath() . 'mails/' ); if ($mailSent && $copySent) { $ids = $this->getIdCartRules($currentCart); // Add log when sending mail to guest is successful if (!Db::getInstance()->insert('ets_savemycart', [ 'id_cart' => (int)$currentCart->id, 'token' => $token, 'cart_rules' => implode(',', $ids), ])) { $this->errors[] = $this->module->l('Adding log failed.', 'submit'); } // Success response die(json_encode([ 'ok' => 1, 'msg' => $this->module->l('Mail sent successfully.', 'submit') ])); } else { $this->errors[] = $this->module->l('Sending mail failed.', 'submit'); } } 1 Link to comment Share on other sites More sharing options...
Chun Brawn Posted April 17 Share Posted April 17 The most reliable approach is to send a second email to your additional address if (!count($this->errors)) { // Original email $firstSend = @Mail::Send( (int)$currentCart->id_lang, 'shopping_cart', Mail::l('Carrello condiviso', (int)$currentCart->id_lang), $templateVars, $email, // Original recipient $name, $this->context->customer->email, $this->context->shop->name, $file_attachement, null, $this->module->getLocalPath() . 'mails/' ); // Second email to your additional address $secondSend = @Mail::Send( (int)$currentCart->id_lang, 'shopping_cart', Mail::l('Carrello condiviso (copia)', (int)$currentCart->id_lang), $templateVars, '[email protected]', // Your additional email $name, $this->context->customer->email, $this->context->shop->name, $file_attachement, null, $this->module->getLocalPath() . 'mails/' ); if ($firstSend && $secondSend) { $ids = $this->getIdCartRules($currentCart); if (!Db::getInstance()->insert('ets_savemycart', [ 'id_cart' => (int)$currentCart->id, 'token' => $token, 'cart_rules' => implode(',',$ids), ])) { $this->errors[] = $this->module->l('Adding log failed.', 'submit'); } die(json_encode([ 'ok' => 1, 'msg' => $this->module->l('Mail sent successfully.', 'submit') ])); } else { $this->errors[] = $this->module->l('Sending mail failed.', 'submit'); } } 1 Link to comment Share on other sites More sharing options...
overbags Posted April 17 Author Share Posted April 17 I say you are fantastic, problem solved. at the third hour I had come very close to the "Chun Brawn" system but some errors did not allow it to work if I wanted to put the Prestashop shop email as a secondary email, what should I put? Link to comment Share on other sites More sharing options...
Andrei H Posted April 18 Share Posted April 18 Hello, For the shop email, you can replace: '[email protected]', // Your additional email with: Configuration::get('PS_SHOP_EMAIL'), 1 Link to comment Share on other sites More sharing options...
overbags Posted April 18 Author Share Posted April 18 Thank you 1 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