• Resolved maikbrauer

    (@maikbrauer)


    In order to change afterwards the Order Status Flag after Purchasing is complete I wanted to check if the Virtual Flag has been set for the Product which was part of the order.

    If the Virtual Flag was Part of the Order I wanted to change the ORDER Status myself via PHP code. But how to get this specific flag after a purchase has been done.

    Example code inside functions.php:

    
    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' );
    }
    

    But this example covers everything also the ones which are set as not Virtual.
    Any idea from where to get the values to put them into the piece of code?

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Mirko P.

    (@rainfallnixfig)

    Hi there,

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook Community group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Cheers.

    Mirko P.

    (@rainfallnixfig)

    Hi there,

    We’ve not seen any activity on this thread for a while, so I’m marking this thread as resolved.

    Hopefully, you were able to find a solution and the above resources for developers were helpful. If you have further questions, please feel free to open a new topic.

    Thread Starter maikbrauer

    (@maikbrauer)

    Hi, thanks for the ping and also for pointing me to the correct people/group.

    No not really solved yet. So I would not call this thread as solved.
    I am now talking to the #developer channel in Slack and got already some snippets which are not working as expected. I am still trying to get this somehow done with the help of the community.

    But let’s close this thread then for now and if there is something else, I ‘ll come back here. Thanks for now and take care.

    Cheers

    Hello,

    Thanks for letting us know!

    Let us know if you have any further questions, if so, I recommend creating a new thread.

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Check if Flag “VIRTUAL” was set for an order’ is closed to new replies.