0

I've created a custom field Customer Level for users, and I've also created a custom order status autoprocess. Now I want to auto-process orders based on customer level:

add_action('woocommerce_checkout_order_processed', 'auto_process_orders');

function auto_process_orders($order_id) {
    $current_user = wp_get_current_user();
    if ( $current_user->customer_level >= 5  ) {
        $order = new WC_Order( $order_id );
        $order->update_status( 'autoprocessed' );
    }
}

.. but it just doesn't work. Order stays "on-hold" (since I'm using bank transfer as payment method).

0

Figured it. woocommerce_thankyou is the hook to be used.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.