By looking at the code proposed by the module commerce_stock
I believe you'll have to write a new EventSubscriber that subscribe to the event onOrderComplete
.
So you create the file: modules/custom/my_custom_commerce_stock/src/EventSubscriber/SendEmailWhenNoStockSubscriber.php
<?php
namespace Drupal\my_custom_commerce_stock\EventSubscriber;
class SendEmailWhenNoStockSubscriber implements EventSubscriberInterface {
public static function getSubscribedEvents() {
'commerce_order.post_transition' => 'onOrderComplete',
}
public function onOrderComplete(WorkflowTransitionEvent $event) {
// code to send email.
}
}
If you don't know how to send an email with Drupal, this is very well documented:
If you don't want to code, you can try the following module https://www.drupal.org/project/commerce_stock_notifications