Advertisement
thesufi

WooCommerce Send Order Invoice Upon Placing Order

Sep 16th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.63 KB | None | 0 0
  1. /*
  2.  * Automatically send order invoice to customer, once order is placed.
  3.  *
  4.  * Works only when order status is "pending".
  5.  */
  6. function dctit_custom_woocommerce_pending_order_invoice_notification( $order_id ) {
  7.     $order = wc_get_order( $order_id );
  8.    
  9.     //should not be doing anything, if order is not in pending status
  10.     if( ! $order->has_status( 'pending' ) ) {
  11.         return;
  12.     }
  13.    
  14.     //send email
  15.     WC()->mailer()->get_emails()['WC_Email_Customer_Invoice']->trigger( $order_id );
  16. }
  17. add_action( 'woocommerce_checkout_order_processed', 'dctit_custom_woocommerce_pending_order_invoice_notification', 20, 1 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement