Woocommerce: Send Invoice Straight Away When Payment Successful

One good feature I really want is to send an invoice straight away when payment is successful. At the moment, customers receive an order completion notification email which I find it useless. To send an invoice, you have to login to wp-admin and click on the send invoice button.

We can add some custom code in functions.php in your theme folder to achieve this functionality

 * remove order status completed notification
 * @param  WC_Email $this woocommerce email class
 * @return null
function do_not_send_order_complete_notification($this) {
  remove_action('woocommerce_order_status_completed_notification', array($this,'customer_completed_order'));
  // you can add other stuff you want to do here...
add_action('woocommerce_email', 'do_not_send_order_complete_notification');

 * send invoice straight away if payment is successful
 * @param  string $order_id valid payment order id
 * @return null
function send_invoice_upon_payment_successful($order_id) {
  global $woocommerce;
  $order = new WC_Order($order_id);
  $mailer = $woocommerce->mailer();
  $mailer->customer_invoice( $order );
add_action('woocommerce_payment_complete', 'send_invoice_upon_payment_successful');

For woocommerce 2.x, the send_invoice_upon_payment_successful function still works, however do_not_send_order_complete_notification function doesn’t. See my 2.x update here

Like it.? Share it:

3 Responses to Woocommerce: Send Invoice Straight Away When Payment Successful

  1. Klaus Hansen

    Does this work with latest version of woocommerce (2.0)?
    I cant get it to work with woocommerce 2.0.8.

  2. bpeh

    nope. woocommerce 2.0 too big a change.

  3. bpeh

    hi klaus, see my 2.x updated code as per link above. cheers.