• Resolved alexislevrai

    (@alexislevrai)


    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 ?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support ckadenge (woo-hc)

    (@ckadenge)

    Hello @alexislevrai,

    Thanks for reaching out.

    Helping out with custom coding of this nature is outside the scope of support that our support staff can help out with here, although I would recommend the following:

    1. Running the exact question you’re asking, along with the code provided, through an AI platform like ChatGPT for recommendations/changes to your code;
    2. Checking whether there are existing plugins in the WordPress plugin repository that might be doing that already.
    3. Joining our WooCommerce Slack community (it does have a developer channel where you can ask coding questions): https://woo.com/community-slack/

    Hope it helps!

    Thread Starter alexislevrai

    (@alexislevrai)

    Okay thank you

    Hi @alexislevrai,

    Thanks for getting back to us. We are glad to help! Just so you know – we will now close this ticket as solved. Just so you know – we will now close this ticket as solved. If you have any other questions or issues, please feel free to open a new ticket and we’ll be happy to assist you.

    Thank you for choosing WooCommerce and have a great day!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Confirmation email before stock update’ is closed to new replies.