Show Stock Status on WooCommerce Shop & Archive Pages

By default, a product’s stock status doesn’t show in WooCommerce shop and catalog/archive pages. As a store owner,it is important to show out-of-stock products if product is in “Out of Stock” because customer should know that this product is available in your store, but when they click on the single product and then realise that the product is unavailable. That means currently Product is sold out and Secondly, listing an out-of-stock product indicates its popularity.

So, How to save the customer trouble of having to go to the individual product page. so, Here is solution. Just copy below code and add this code in your theme’s functions.php file of your active child theme (or theme).

function stock_catalog() {
    global $product;
    if ( $product->is_in_stock() ) {
        echo '
' . $product->get_stock_quantity() . __( 'in stock', 'stock' ) . '
'; } else { echo '
' . __( 'out of stock', 'stock' ) . '
'; } } add_action( 'woocommerce_after_shop_loop_item_title', 'stock_catalog' );

Leave a Comment

Scroll to Top