I’m using the observer event called checkout_cart_product_add_after, but when I use this method below to get the quantity in stock I just can get the configurable product stock quantity, my simple product is working though.
$quoteItem = $observer->getEvent()->getQuoteItem();
$product = $quoteItem->getProduct();
$typeId = $product->getTypeId();
$productStockData = $product->getExtensionAttributes()->getStockItem();
$productQty = (int) $productStockData->getQty();
$message = __(
'%1 may require a lead time.',
$product->getName()
);
if ($product->getManageStock() && $productQty <= 0) {
$this->messageManager->addWarningMessage($message);
}