• Hello everyone

    A customer wants us to enable access to downloads as soon as the order goes “on-hold” since all of the downloads are free. Usually if the order only contains free products the download links are available instantly. Whereas if there’s even a single product that costs let’s say 1$ – you’ll have to wait for the links until someone sets the order status to “processing”.

    Is there a way to get around this? Even if it means simply automatically setting every order to “processing”/”complete”?

    I have rather good knowledge in PHP and the WordPress environment – yet have to get used to how WooCommerce handles certain things.

    Thank you very much for your help in advance! If I need to specify anything more – let me know! 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Shameem (woo-hc)

    (@shameemreza)

    Hi @aequinokte

    Is there a way to get around this? Even if it means simply automatically setting every order to “processing”/”complete”?

    You can use the code snippet shared here (or here) or a plugin like WooCommerce Order Status Control, or Autocomplete WooCommerce Orders.

    However, please note that automatically completing orders could potentially lead to issues if you’re selling physical products that need to be shipped, as you might miss the “processing” step.

    I hope this helps! If you have any other questions, feel free to ask.

    Thread Starter aequinokte

    (@aequinokte)

    Hi @shameemreza

    Oh that’s relatively simple! Thank you – yeah I’d set the orders to “processing” since that also can triggers a download-link mail after updating the right download settings.

    Thank you very much!

    Thread Starter aequinokte

    (@aequinokte)

    Hello @shameemreza

    Uhm I’ve realized (after testing) that the shared code snippet hooks on ‘woocommerce_payment_complete_order_status’ which means it updates the order status once payment is complete. But what I would prefer is to make downloadable products available as soon as possible – even before payment since all the downloadables are FREE. Sadly if there is something that costs in the cart it doesn’t make the downloads available until everything is paid.

    Is there a hook for the order status once the order is being placed?

    Plugin Support Shameem (woo-hc)

    (@shameemreza)

    Hi @aequinokte

    In that case, you may consider using the woocommerce_new_order hook. This hook is triggered as soon as an order is created, which should allow you to set the order status to processing or complete immediately after the order is placed, regardless of whether or not payment has been made.

    Let me give you a clearer example:

    add_action( 'woocommerce_new_order', 'auto_complete_free_virtual_orders', 10, 1 );
    function auto_complete_free_virtual_orders( $order_id ) {
    if ( ! $order_id ) {
    return;
    }
    $order = wc_get_order( $order_id );

    if ( count( $order->get_items() ) > 0 ) {
    foreach ( $order->get_items() as $item ) {
    if ( $item['product_id'] == YOUR_FREE_PRODUCT_ID ) { //replace with your free product ID
    $order->update_status( 'completed' );
    break;
    }
    }
    }
    }

    I hope this helped you in the right direction!

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.