From 5d06ab1dfa511740a7f2bf98f6f17ff8f25f07cd Mon Sep 17 00:00:00 2001
From: Juraj Nemec <60540-poker10@users.noreply.drupalcode.org>
Date: Sat, 7 Dec 2024 19:30:52 +0000
Subject: [PATCH] Issue #3252466: Check in queue if still in stock

---
 src/Plugin/QueueWorker/CommerceStockNotifyQueue.php | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/Plugin/QueueWorker/CommerceStockNotifyQueue.php b/src/Plugin/QueueWorker/CommerceStockNotifyQueue.php
index 715aaf9..4a73506 100644
--- a/src/Plugin/QueueWorker/CommerceStockNotifyQueue.php
+++ b/src/Plugin/QueueWorker/CommerceStockNotifyQueue.php
@@ -99,6 +99,10 @@ class CommerceStockNotifyQueue extends QueueWorkerBase implements ContainerFacto
         // The product or variation is inactive, ignore it.
         throw new \Exception("Variation $sku (or it\'s parent product) is unpublished. Skipping for now.");
       }
+      if (!commerce_stock_notifications_check_stock($variation)) {
+        // There is no stock right now, do nothing.
+        return;
+      }
       // Parameters that will be used during the mailing procedure.
       $params = [
         'mail_title' => $this->token->replace(AdminConfigForm::getValuesFromConfig()['email_subject'], [
-- 
GitLab