Posted on 18/06/2020 09:39:23
Hi Adrian,
Yes, if stock > 0 on the product or in any stock location then it is "back in stock" and a notification will be sent.
Here is the query we use:
Dim query As New CommandBuilder()
query.Add("SELECT n.* FROM EcomNotification n")
query.Add("INNER JOIN EcomProducts p ON p.ProductID = n.NotificationProductID AND p.ProductVariantID = n.NotificationProductVariantID AND p.ProductLanguageID = n.NotificationProductLanguageID")
query.Add("WHERE NotificationContextAreaID = {0} AND NotificationSentTime IS NULL", areaId)
query.Add(" AND ((n.NotificationProductUnitID = '' AND p.ProductStock > 0) OR")
query.Add(" (p.ProductDefaultUnitID > '' AND EXISTS (")
query.Add(" SELECT 1 FROM EcomStockUnit")
query.Add(" WHERE p.ProductID = StockUnitProductID AND p.ProductVariantID = StockUnitVariantID AND StockUnitQuantity > 0 ")
query.Add(" AND (n.NotificationProductUnitID = '' OR StockUnitID = n.NotificationProductUnitID))))")
query.Add("ORDER BY n.NotificationUserID, n.NotificationEmail")
Best regards,
Morten