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

Author: bpeh

Bernard Peh is a great passioner of web technologies and one of the co-founder of Sitecritic.net Website Design and Reviews. He works with experienced web designers and developers everyday, developing and designing commercial websites. He specialises mainly in SEO and PHP programming.

3 thoughts on “Woocommerce: Send Invoice Straight Away When Payment Successful”

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

Comments are closed.