Created
May 27, 2022 16:20
-
-
Save SitesByYogi/778f1a6247f6caf77e78d32645ef30a9 to your computer and use it in GitHub Desktop.
Mark Cash Payment as Paid
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_thankyou', 'wc_auto_complete_paid_order' ); | |
function wc_auto_complete_paid_order( $order_id ) { | |
if ( ! $order_id ) { | |
return; | |
} | |
$order = wc_get_order( $order_id ); | |
if( $order->has_status('processing') ) { | |
$order->update_status( 'completed' ); | |
} else { | |
$order->update_status( 'cancelled' ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment