Skip to content

Instantly share code, notes, and snippets.

@paaljoachim
Last active January 8, 2020 14:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save paaljoachim/643ed78229ab0b0d9d0ad5dfeec80240 to your computer and use it in GitHub Desktop.
Save paaljoachim/643ed78229ab0b0d9d0ad5dfeec80240 to your computer and use it in GitHub Desktop.
WooCommerce auto confirm order code snippet from Kathy. Any order marked for "processing" will be changed to complete without the need to manually click the complete button through the order screen in WooCommerce.
add_filter( 'woocommerce_payment_complete_order_status', 'kia_order_payment_complete_order_status', 10, 2 );
function kia_order_payment_complete_order_status( $order_status, $order_id ) {
$order = wc_get_order( $order_id );
if ( 'processing' == $order_status &&
( 'pending' == $order->status ) ) {
$order_status = 'completed';
}
return $order_status;
}
@paaljoachim
Copy link
Author

paaljoachim commented Jan 10, 2018

Place the above code in your child theme functions.php file or create an external php file for WooCommerce code snippets.

From the WooCommerce Slack channel: https://woocommercecommunity.slack.com/messages/C1K9K3UD9/convo/C1K9K3UD9-1515504591.000267/

Another code suggestion for only having virtual products become auto completed: https://www.skyverge.com/blog/how-to-set-woocommerce-virtual-order-status-to-complete-after-payment/

Alternative plugin: https://wordpress.org/plugins/woocommerce-autocomplete-order/

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