Send an invoice automatically with WooCommerce 2.x

The Question: “WooCommerce only sends invoice when triggered in the Dashboard. How to send these invoice automatically?”. Stackexchange.com WordPress Development does not allow WooCommerce questions any more. That is why i post the answer for this question here.

Add an action to your woocommerce_order_status_completed_notification or woocommerce_order_status_pending_to_processing_notification in functions.php:

function sendinvoice($orderid)
{
    $email = new WC_Email_Customer_Invoice();
    $email->trigger($orderid);
}   

add_action('woocommerce_order_status_completed_notification','sendinvoice');

Comments

3 responses to “Send an invoice automatically with WooCommerce 2.x”

  1. Carlos Avatar

    Hello, when I put the code in but its sent to me admin email. I would like it to be sent to customers that completed a order.

    Any assistance would be greatly appreciated.

    Thanks

    Carlos

  2. txtsd Avatar

    This works on wordpress 3.x too!

    1. gema Avatar

      can you give me tutorial for doing this ? where I can found this actions woocommerce_order_status_completed_notification ?