daily pastebin goal
65%
SHARE
TWEET

Untitled

a guest Dec 7th, 2018 47 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. <?php
  2.  
  3. add_action( 'woocommerce_order_status_changed', array( $this, 'my_child_invoice_automation' ), 10, 4 );
  4. add_action( 'woocommerce_germanized_order_confirmation_sent', array( $this, 'my_child_invoice_automation_instant' ), 10, 1 );
  5.  
  6. /**
  7. * Generate invoices after status transition
  8. */
  9. function my_child_invoice_automation( $order_id, $status_from, $status_to, $order ) {
  10.     // Check the payment method
  11.     if ( 'paypal' === $order->get_payment_method() ) {
  12.         // Check the new order status -> generate invoice when status switched to processing
  13.         if ( 'processing' === $status_to ) {
  14.              WC_GZDP_Invoice_Helper::instance()->auto_generate_invoice( $order_id );
  15.         }
  16.     }
  17. }
  18.  
  19. /**
  20. * Generate invoices as soon as order is placed
  21. */
  22. function my_child_invoice_automation_instant( $order_id ) {
  23.     $order = wc_get_order( $order_id );
  24.    
  25.     if ( 'invoice' === $order->get_payment_method() ) {
  26.         WC_GZDP_Invoice_Helper::instance()->auto_generate_invoice( $order_id );
  27.     }
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top