Components
At the moment you can't configure the order receipt email subject. The subject is hardcoded in the OrderReceiptMail service.
There is an issue to fix this, but until that happens the only way to alter the email subject is to use the hook_mail_alter().
/**
* Implements hook_mail_alter().
*/
function MY_MODULE_mail_alter(&$message) {
if ($message['key'] == 'order_receipt' && !empty($message['params']['order'])) {
/** @var \Drupal\commerce_order\Entity\OrderInterface $order */
$order = $message['params']['order'];
$message['from'] = 'noreply@example.com';
$message['subject'] = t('Receipt for Order ID: @number', [
'@number' => $order->getOrderNumber(),
]);
}
}
About the Author
Goran Nikolovski is a senior web developer who loves working with Drupal, React, and React Native. He is the founder of this website and he enjoys sharing his knowledge. Need help with anything? Get in touch.