I need to know WooCommerce new order email to given email address for only in specific products.
Ex: if any body buy a product X need a new order email to Y. The Y is not set in as back end Recipient. Is there any hook to achieve this ?
I tried follow
add_action( 'woocommerce_order_status_completed', 'custom_woocommerce_order_status_completed' );
function custom_woocommerce_order_status_completed( $order_id ) {
$order = new WC_Order($order_id);
$items = $order->get_items();
foreach ($items as $key => $value) {
if($value == 10) { // given product id
// trigger order complete email for specific email address
}
}
}