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');

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

  1. Carlos

    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

    Reply
    • gema

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

      Reply

Leave a Reply

(will not be published)