Guest User

Untitled

a guest
Dec 7th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  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. }
Add Comment
Please, Sign In to add comment