We use a simple PHP code to display Stock Availability at WooCommerce Shop Availability at WooCommerce Shop or category Page. Showing stocks of Product on WooCommerce Shop pages and Category pages helps your customer to navigate easily in store and view only those products which are in stock. Such options helps in quick decision making for customer on online store.
Table of Contents
Below steps will help you to Display Stock Availability at WooCommerce Shop and Category page
Enable Inventory Management in WooCommerce Settings
- To enable the Inventory management go to WooCommerce -> Settings -> Products -> Inventory
- Enable the Inventory Management and Save the settings.
PHP Snippet : Code to add in Functions.php file to display Stock Quantity / Status
Add below code in functions.php file of child theme
add_action( 'woocommerce_after_shop_loop_item', 'scriptfeeds_stock_shop', 10 );
function scriptfeeds_stock_shop() {
global $product;
echo wc_get_stock_html( $product );
}
After adding and saving the code. Check WooCommerce Product category and Shop pages.
So that’s all you need to follow to show or Display Stock Availability at WooCommerce Shop and category page. Give it a try and let us know how it works. You can connect with our Developer Team for any help.
Happy Coding!