1
votes

I´m working on my store, all products I´m selling are virtual, because they provide unlock codes.

I´m using plugin named StockUnlock to achieved API access with my providers: till here everything is ok.

In order of the StockUnlock plugin takes action when the client purchased his product the order status must be processing after payment received, but it's not:
When I received the payment the status goes to complete and the plugin don't work. The payment method I´m using is woo-credits (Woo Credits plugin).

How this could be solved, to get a processing status instead of completed?

1
Welcome to StackOverflow! Your question needs some work so the community can better help you. Take a look at how to ask a good question and give it another try.Chris Albert

1 Answers

1
votes

This behavior comes from the Woo Credit plugin (You could contact authors support threads).

Now you could try this code that will target 'woo_credits' payment gateway only and will update order status back to 'processing', once customer has submitted his order in "Order Received" page (thankyou):

add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_paid_order', 999, 1 );
function custom_woocommerce_auto_complete_paid_order( $order_id ) {
    // Only for 'woo_credits' payment gateway
    if ( ! $order_id || 'woo_credits' != get_post_meta($order_id, '_payment_method', true) )
        return;

    // Get an instance of the WC_Order object
    $order = wc_get_order( $order_id );

    // Update order status back to 'processing'
    $order->update_status( 'processing' );
}

Code goes in function.php file of your active child theme (or active theme).

This code is untested, but could work for you.