Last active
October 9, 2024 00:30
-
-
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.
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_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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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/