How do I get the vendor's email address linked with the order's listings?

add_action('woocommerce_order_status_changed', 'send_cancelled_email_notifications', 10, 4 );
function send_cancelled_email_notifications( $order_id, $old_status, $new_status, $order ){
    if ( $new_status == 'cancelled' || $new_status == 'failed' ){
        $wc_emails = WC()->mailer()->get_emails(); // Get all WC_emails objects instances
        $customer_email = $order->get_billing_email(); // Get the customer email
    }
 
    if ( $new_status == 'cancelled' ) {
        // change the recipient of the instance
        $wc_emails['WC_Email_Cancelled_Order']->recipient = $customer_email;
        // Sending the email from this instance
        $wc_emails['WC_Email_Cancelled_Order']->trigger( $order_id );
    } 
    elseif ( $new_status == 'failed' ) {
        // change the recipient of the instance
        $wc_emails['WC_Email_Failed_Order']->recipient = $customer_email;
        // Sending the email from this instance
        $wc_emails['WC_Email_Failed_Order']->trigger( $order_id );
    } 
}

I wrote the above code,
so I could send an email to the admin and customer when the order’s status was changed to canceled.
And then I also want to send an email to the vendor.
But I can’t search the vendor’s email linked with the order’s listings.
Please, could you teach me?"

Hi,

If there is an order, its id can be extracted by the order meta hp_vendor, and the author can be obtained through post_author (vendor is a post of the `hp_vendor type).

​I hope this is helpful to you.

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