I want to send my order to my email, and also to my client's email.
I am sending an order placed on my website using this code:
function MYMODULE_form_submit($form, &$form_state) {
order_mail_send($form_state['values']);
}
This is the order_mail_send()
code:
function order_mail_send($form_values) {
$module = 'shop';
$key = 'key';
$to = $form_values['email'];
$language = language_default();
$params = array();
$from = NULL;
$send = FALSE;
$message = drupal_mail($module, $key, $to, $language, $params, $from, $send);
$message2 = drupal_mail($module, $key, $from, $language, $params, $from, $send);
$subject = 'Order Status';
$message['subject'] = $subject;
$message['body'] = array();
$message['body'][] = "<h3>Your order: ".$form_values['first']." ".$form_values['last']."</h3>";
// …
// Retrieve the responsible implementation for this message.
$system = drupal_mail_system($module, $key);
// Format the message body.
$message = $system->format($message);
$message2 = $system->format($message2);
// Send e-mail.
$message['result'] = $system->mail($message);
$message['result2'] = $system->mail($message2);
if ($message['result'] && $message['result2'] == TRUE) {
drupal_set_message(t('Your order has been sent. Thank you!'));
}
else {
drupal_set_message(t('There was a problem sending your message and it was not sent.'), 'error');
}
}
- Now it sends the first email (
$message = $system->format($message);
but not the second one. How can I make it work? - How can I empy the cart values after sending the emails? The cart empties when I close the browser, but I want to delete it after sending as well.