Hello,
I’m using this code below to show the stock status of a product in confirmation e-mail.
add_filter( 'woocommerce_display_item_meta', 'show_stock_status_in_email', 10, 3 );
function show_stock_status_in_email( $html, $item, $args ) {
$product = $item->get_product();
$stock_status = $product->get_stock_status();
$html .= '<p style="margin:0;"><strong>(' . $stock_status . ')</strong></p>';
return $html;
}It work well but I notice that when a product is the last piece in stock, in the e-mail it appear as “Out of stock” or “In Backorder” depending of the product configuration.
I have therefore deduced that the confirmation e-mail must be sent after the stock update.
I mean if I have a “Red Hat” product that only have 1 quantity in stock -> a client order it -> payment is confirmed -> woocommerce update the quantity in stock to 0 -> confirmation email is sent with stock status “out of stock” -> client is in panic mode
Is there a way to solve that ?
Maybe by sending the confirmation email before stock update ?
