Autocomplete Paid Orders in WooCommerce

There is a snippet you may have seen to automatically complete orders in WooCommerce. The only problem is this will only autocomplete orders when the customer visits the thank you page. For situations where the user skips the thank you page or the order is automated, this won’t help us. What we need is to take this snippet and use a different hook.

WooCommerce has just what we need in the woocommerce_payment_complete hook. This is triggered once the order has been paid for. When we add this to the snippet, this is what we end up with.

add_action( 'woocommerce_payment_complete', 'ijab_autocomplete_paid_orders' );
function ijab_autocomplete_paid_orders( $order_id ) { 
    if ( ! $order_id ) {

    $order = wc_get_order( $order_id );
    $order->update_status( 'completed' );

Now this snippet will autocomplete orders even if the thank you page isn’t triggered like with subscription renewals.

Leave a Reply

%d bloggers like this: