When I try to retrieve stock_status through the REST API for a specific product (example ID 999), it always shows stock_status as null, even though when I view the product in Woocommerce Admin interface, the product is showing as In Stock.
Is this because Stock Management in Woocommerce settings is disabled? I dont register a stock quantity, but I do monitor general availability based on the stock status value showing as “In Stock” or “On Backorder”.
$product = $woocommerce->get('products/999');
echo "<b>Product ID:</b> " . $product->id . "<br>";
echo "<b>Product Name:</b> " . $product->name . "<br>";
echo "<b>Product Status:</b> " . $product->status . "<br>";
echo "<b>Product Visibility:</b> " . $product->catalog_visibility . "<br>";
echo "<b>Product Stock Status:</b> " . $product->stock_status . "<br>";
The above always shows Stock Status as empty.
appie is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.