• Resolved arthurlam1

    (@arthurlam1)


    Hi all,

    In the documentation, this code was provided:

    https://docs.woocommerce.com/document/automatically-complete-orders/

    /**
     * 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 have tried it but it does not appear to work (ie. Orders where users select Cash on Delivery go to Processing and orders where users select Direct Bank Transfer go to On Hold still. Placed it in my functions.php file of my child theme.

    Can someone help me out, please?

    • This topic was modified 4 years, 6 months ago by arthurlam1.
Viewing 4 replies - 1 through 4 (of 4 total)
  • @arthurlam1 – I’ve just run a test with Direct bank transfer and a simple product, while having that code active in my functions.php file.
    The order went direct to Completed.

    You may consider trying a conflict test to ensure no other plugins are affecting the status of the order or woocommerce_thankyou hook.

    The best way to determine this is to:

    • Temporarily switch your theme to Storefront
    • Disable all plugins except for WooCommerce
    • Repeat the action that is causing the problem

    If you’re not seeing the same problem after completing the conflict test, then you know the problem was with the plugins and/or theme you deactivated. To figure out which plugin is causing the problem, reactivate your other plugins one by one, testing after each, until you find the one causing conflict. You can find a more detailed explanation on how to do a conflict test here.

    – Joey

    Thread Starter arthurlam1

    (@arthurlam1)

    @jricketts4 Hey Joey, thanks. Could you let me know where to find the default order status for each payment option? I am trying to troubleshoot to see if there are any conflicts.

    Thank you.

    Plugin Support Aashik P – a11n

    (@aashik)

    Could you let me know where to find the default order status for each payment option

    Do you mean the order status without the above snippet configured? In that case:

    * Direct Bank Transfer (BACS) and Check Payments should be On-Hold
    * Cash on Delivery should be processing
    * PayPal Standard would be Processing as long as the payment was successful.

    Please let us know if you have any further questions on this – we’re happy to help.

    Plugin Support Aashik P – a11n

    (@aashik)

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Code provided in documentation to complete orders not working?’ is closed to new replies.