Skip to content

Instantly share code, notes, and snippets.

@harishankerr
Created February 17, 2020 06:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harishankerr/0a3b26aad69131f6b5114193de2699d3 to your computer and use it in GitHub Desktop.
Save harishankerr/0a3b26aad69131f6b5114193de2699d3 to your computer and use it in GitHub Desktop.
Update order status to `processing` for the cheque payments method
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