Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_action( 'woocommerce_order_status_changed', array( $this, 'my_child_invoice_automation' ), 10, 4 );
- add_action( 'woocommerce_germanized_order_confirmation_sent', array( $this, 'my_child_invoice_automation_instant' ), 10, 1 );
- /**
- * Generate invoices after status transition
- */
- function my_child_invoice_automation( $order_id, $status_from, $status_to, $order ) {
- // Check the payment method
- if ( 'paypal' === $order->get_payment_method() ) {
- // Check the new order status -> generate invoice when status switched to processing
- if ( 'processing' === $status_to ) {
- WC_GZDP_Invoice_Helper::instance()->auto_generate_invoice( $order_id );
- }
- }
- }
- /**
- * Generate invoices as soon as order is placed
- */
- function my_child_invoice_automation_instant( $order_id ) {
- $order = wc_get_order( $order_id );
- if ( 'invoice' === $order->get_payment_method() ) {
- WC_GZDP_Invoice_Helper::instance()->auto_generate_invoice( $order_id );
- }
- }
Add Comment
Please, Sign In to add comment