Skip to content

Instantly share code, notes, and snippets.

@SitesByYogi
Created May 27, 2022 16:20
Show Gist options
  • Save SitesByYogi/778f1a6247f6caf77e78d32645ef30a9 to your computer and use it in GitHub Desktop.
Save SitesByYogi/778f1a6247f6caf77e78d32645ef30a9 to your computer and use it in GitHub Desktop.
Mark Cash Payment as Paid
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