Voeg de volgende code toe in de functions.php


add_shortcode( 'stock_status', 'display_product_stock_status' );
function display_product_stock_status( $atts) {

    $atts = shortcode_atts(
        array('id'  => get_the_ID() ),
        $atts, 'stock_status'
    );

    $product = wc_get_product( $atts['id'] );

    $stock_status = $product->get_stock_status();

    if ( 'instock' == $stock_status) {
        return '<p class="stock in-stock">In stock</p>';
    } else {
        return '<p class="stock out-of-stock">Out of stock</p>';
    }
}

Plaats de volgende shortcode in de layout: [stock_status]