WooCommerce get product stock information

Today we talk about how WooCommerce get product stock information? In our example, we will get product stock information like stock status, manage stock, and stock quantity. So let’s start with our example.

If you want to load product information by it id then use the following code.

$p_id = 20;
$product_info = wc_get_product( $p_id );

Now you have product object. You can get stock infromation with the following code.

$product->get_manage_stock(); // get product manage stock
$product->get_stock_quantity(); // get product stock quantity
$product->get_stock_status(); // get stock status

Qaisar Satti

Hi, I'm Qaisar Satti! I've been a developer for over 20 years, and now I love sharing what I've learned through tutorials and guides. Whether you're working with Magento, PrestaShop, or WooCommerce, my goal is to make your development journey a bit easier and more fun. When I'm not coding or writing, you can find me exploring new tech trends and hanging out with the amazing developer community. Thanks for stopping by, and happy coding!