Send an email to vendor when an order is created to on hold

Hi, when an order is created to on hold, I would like an email to be sent to both the customer and the vendor. At present, it is only sent to the customer. I imagine something like this :
Does anyone have an idea of how to make this work ?

function send_email_on_hold_status( $order_id, $old_status, $new_status, $order ) {
    if ( 'on-hold' === $new_status ) {
        // Get customer email
        $customer_email = $order->get_billing_email();

        // Get vendor email
        // There should be a way to retrieve the seller's email related to the order
        $vendor_email = get_vendor_email($order_id);

        // Email content
        $subject = "Your order is now on hold";
        $message = "Order #{$order_id} is on hold. Contact the buyer at the {$user_phone} ";

        // Send email to seller
        wp_mail( $seller_email, $subject, $message );


Sorry, there’s no simple code snippet for this, it would require a custom implementation. If customizations beyond the available features are required for your site, please consider hiring someone for custom work

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.