public function ShipmentSubscriber::onShip in Commerce Shipping 8.2
Checks shipment mail settings and sends confirmation email to customer.
Parameters
\Drupal\state_machine\Event\WorkflowTransitionEvent $event: The transition event.
File
- src/
EventSubscriber/ ShipmentSubscriber.php, line 65
Class
Namespace
Drupal\commerce_shipping\EventSubscriberCode
public function onShip(WorkflowTransitionEvent $event) {
/** @var \Drupal\commerce_shipping\Entity\ShipmentInterface $shipment */
$shipment = $event
->getEntity();
/** @var \Drupal\commerce_shipping\Entity\ShipmentTypeInterface $shipment_type */
$shipment_type = $this->entityTypeManager
->getStorage('commerce_shipment_type')
->load($shipment
->bundle());
$order = $shipment
->getOrder();
assert($order !== NULL);
// Continue only if settings are configured to send confirmation.
if ($shipment_type
->shouldSendConfirmation()) {
$this->shipmentConfirmationMail
->send($shipment, $order
->getEmail(), $shipment_type
->getConfirmationBcc());
}
}