/** | |
* 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' ); | |
} |
I've noticed this works intermittently, not sure the cause.
Same here, some times it works, but not always, i'm investigating...
Hi, this code auto complete PAID ORDERS? That is only i need, that auto complete only if the order is paid.
It works for all orders even unpaid. It must work only for paid orders.
Doesn't work for my case because I don't display a "Thank You" page, I guess. Any other way to hiik it so something else?
Doesn't work for my case because I don't display a "Thank You" page, I guess. Any other way to hiik it so something else?
You could hook woocommerce_payment_complete'
. For a full list of hooks, check this.
For orders in process, after receiving payment, change the if to:
if ( $order_status == 'processing' )
This worked for me, for paid orders only!
Is there any way of adapting this snippet to work for recurring subscription renewals, using WooCommerce Subscriptions?
Does this work if a place it in a CodeSnippet plug in???