public function OrderReceiptSubscriber::sendOrderReceipt in Commerce Core 8.2
Sends an order receipt email.
Parameters
\Drupal\state_machine\Event\WorkflowTransitionEvent $event: The event we subscribed to.
File
- modules/
order/ src/ EventSubscriber/ OrderReceiptSubscriber.php, line 56
Class
- OrderReceiptSubscriber
- Sends a receipt email when an order is placed.
Namespace
Drupal\commerce_order\EventSubscriberCode
public function sendOrderReceipt(WorkflowTransitionEvent $event) {
/** @var \Drupal\commerce_order\Entity\OrderInterface $order */
$order = $event
->getEntity();
$order_type_storage = $this->entityTypeManager
->getStorage('commerce_order_type');
/** @var \Drupal\commerce_order\Entity\OrderTypeInterface $order_type */
$order_type = $order_type_storage
->load($order
->bundle());
if ($order_type
->shouldSendReceipt()) {
$this->orderReceiptMail
->send($order, $order
->getEmail(), $order_type
->getReceiptBcc());
}
}