Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Garconis/b99679085be24d59751f8785d7ddf9ec to your computer and use it in GitHub Desktop.
Save Garconis/b99679085be24d59751f8785d7ddf9ec to your computer and use it in GitHub Desktop.
WooCommerce | Force orders to auto complete
<?php
/**
* Auto Complete all WooCommerce orders.
*/
add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' );
function custom_woocommerce_auto_complete_order( $order_id ) {
if ( ! $order_id ) {
return;
}
$order = wc_get_order( $order_id );
$order->update_status( 'completed' );
}
@Garconis
Copy link
Author

Garconis commented Aug 8, 2019

There are certain instances when the store owner wants orders to be automatically approved.

I’ve had to use this on a paid subscription membership site (to auto enroll people in a LearnDash course) and FooEvents (to automatically send people their tickets)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment