Created
February 17, 2020 06:42
-
-
Save harishankerr/0a3b26aad69131f6b5114193de2699d3 to your computer and use it in GitHub Desktop.
Update order status to `processing` for the cheque payments method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('woocommerce_order_status_changed', 'wc_auto_complete_by_payment_method'); | |
function wc_auto_complete_by_payment_method($order_id) | |
{ | |
if ( ! $order_id ) { | |
return; | |
} | |
global $product; | |
$order = wc_get_order( $order_id ); // Get the order ID. | |
/* Checks if the order is on hold. If it is on hold, and if the payment method is cheque payments, set the order status to `Processing` */ | |
if ($order->data['status'] == 'on-hold') { | |
$payment_method=$order->get_payment_method(); | |
if ($payment_method == "cheque") | |
{ | |
$order->update_status( 'processing' ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment