Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter aequinokte

    (@aequinokte)

    Hey @shameemreza

    Thank you for the article on the lifecycle! That helped a lot to understand on how it actually works. I still find issues in changing the status of the order – but luckily sending completed mails works now. I do not have the time to dissect everything sadly. I hoped to provide more info as to why things work / don’t work. Here’s the solution to my problem though:

    add_action( ‘woocommerce_checkout_order_processed’, ‘auto_complete_free_virtual_orders’, 10, 1 );
    function auto_complete_free_virtual_orders( $order_id ) {
    $order = wc_get_order( $order_id );

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

    foreach ( $order->get_items() as $item ) {
    $product = $item->get_product();
    if ( $product->is_downloadable() && $product->get_price() == 0 ) {
    $order->update_status( 'completed' );
    $mailer = WC()->mailer()->get_emails();
    $mailer['WC_Email_Customer_Completed_Order']->trigger( $order_id );
    break;
    }
    }
    }

    The $order->update_status( 'completed' ); probably gets triggered but some other event might prevent that from happening. Either way! Thank you very much for your help!

    Have a nice day!

    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?

    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!

    Hello @steviek13 & @valwa!

    I have found the issue. Check your environment setting in the wp-config.php. If SCRIPT_DEBUG is set to true (define(‘SCRIPT_DEBUG’, true)) WordPress will use dev CSS- & JS-Files instead of the usual minified files (EDIT: and seems to handle some Warnings/Errors differently).

    Let me know if this resolves your issue as well @steviek13

    Cheers!

    Can confirm – same issue on our site. Plugin freshly installed and activated. Sadly not able to get to the Settings page and enter any keys.

    Thanks for all your work though! I’d love to get notified and test it out as soon as it’s running again :3

Viewing 5 replies - 1 through 5 (of 5 total)