You can show the stock status of the products via the woocommerce_display_item_meta
hook, for more information: https://woocommerce.github.io/code-reference/files/woocommerce-includes-wc-template-functions.html#source-view.3290
Here is the code for your case:
add_filter( 'woocommerce_display_item_meta', 'show_stock_status_in_email', 10, 3 );
function show_stock_status_in_email( $html, $item, $args ) {
// gets the product object
$product = $item->get_product();
// gets stock status product
$stock_status = $product->get_stock_status();
// show it after the product name
$html .= '<p style="margin:0;"><strong>(' . $stock_status . ')</strong></p>';
return $html;
}
The result will be the following:
The code has been tested and works. Add it in your theme's functions.php file.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…