public function OrderReceiptMail::send in Commerce Core 8.2
Sends the order receipt email.
Parameters
\Drupal\commerce_order\Entity\OrderInterface $order: The order.
string $to: The address the email will be sent to. Must comply with RFC 2822. Defaults to the order email.
string $bcc: The BCC address or addresses (separated by a comma).
Return value
bool TRUE if the email was sent successfully, FALSE otherwise.
Overrides OrderReceiptMailInterface::send
File
- modules/
order/ src/ Mail/ OrderReceiptMail.php, line 55
Class
Namespace
Drupal\commerce_order\MailCode
public function send(OrderInterface $order, $to = NULL, $bcc = NULL) {
$to = isset($to) ? $to : $order
->getEmail();
if (!$to) {
// The email should not be empty.
return FALSE;
}
$subject = $this
->t('Order #@number confirmed', [
'@number' => $order
->getOrderNumber(),
]);
$body = [
'#theme' => 'commerce_order_receipt',
'#order_entity' => $order,
'#totals' => $this->orderTotalSummary
->buildTotals($order),
];
if ($billing_profile = $order
->getBillingProfile()) {
$body['#billing_information'] = $this->profileViewBuilder
->view($billing_profile);
}
$params = [
'id' => 'order_receipt',
'from' => $order
->getStore()
->getEmail(),
'bcc' => $bcc,
'order' => $order,
];
$customer = $order
->getCustomer();
if ($customer
->isAuthenticated()) {
$params['langcode'] = $customer
->getPreferredLangcode();
}
return $this->mailHandler
->sendMail($to, $subject, $body, $params);
}