WooCommerce - Send New Order / Customer Invoice Email from functions.php file
<p>I am trying to send new order email and customer invoice email through functions.php file.</p>

<p>How to fire complete order object to send as an email?</p>

<p>I am trying two different type of code.</p>

<pre><code>add_action('woocommerce_payment_complete', 'my_custom_checkout_field_looking');
function my_custom_checkout_field_looking( $order_id ) {
    $order = new WC_Order( $order_id );

    // first type of Code. Send Email but did not send complete order object.

    $mailer = WC()-&gt;mailer();
    $subject = 'New Order Email # ' . $order_id;
    $mailer-&gt;send( 'example@gmail.com', $subject, $mailer-&gt;wrap_message( $subject, $order ), '', '' );

    // Second type of Code. Do not send email and doing nothing

    global $woocommerce;
    $mailer2 = $woocommerce-&gt;mailer();
    // Email customer with order-processing receipt
    $email = $mailer2-&gt;emails['WC_Email_Customer_Invoice'];
    $email-&gt;trigger( $order );
    // Email admin with new order email
    $email = $mailer2-&gt;emails['WC_Email_New_Order'];
    $email-&gt;trigger( $order );  
}
</code></pre>