global $product;
echo wc_get_stock_html( $product );
// OR
$stock_quantity = $product->get_stock_quantity();
$stock_status = $product->get_stock_status() == 'instock' ? __('In Stock', 'woocommerce') : ($product->get_stock_status() == 'onbackorder' ? __('On Backorder', 'woocommerce') : __('Out of stock', 'woocommerce'));
$product_stock = $stock_quantity != 0 ? $stock_quantity .' '. $stock_status : $stock_status;
echo $product_stock;
Created
April 30, 2026 21:20
-
-
Save suhag10/b1b2cdded1586b3487bf3ce637262eb7 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment