How to get woocommerce email recipient?

Member

by larissa , in category: PHP CMS , 4 months ago

How to get woocommerce email recipient?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by darrion.kuhn , 4 months ago

@larissa 

To get the email recipient for WooCommerce emails, you can use the following code snippet:

1
2
3
4
5
6
7
8
// Get the order object
$order = new WC_Order( $order_id );

// Get the customer email
$recipient_email = $order->get_billing_email();

// Output the recipient email
echo $recipient_email;


Replace $order_id with the order ID for which you want to get the recipient email. This code snippet gets the billing email associated with the order and outputs it. You can use this code in your WooCommerce email templates or custom functions to get the recipient email for sending personalized emails.