1

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?

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
  • 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](https://stackoverflow.com/help/how-to-ask) and give it another try. – Chris Albert Jan 06 '18 at 15:53

1 Answers1

1

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.

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
  • Ok that code works fine for me, just another question, I must assume that for other payment gateway that is in the same situation I can use same code just changing the id of the payment, fro example 'woo_credits' for 'BACS' – Kader Gómez Jan 08 '18 at 19:50
  • @kadergomez Yes exactly… I have others similar answers like my very first one: https://stackoverflow.com/a/35689563/3730754 … – LoicTheAztec Jan 08 '18 at 19:52
  • Ok I´m trying to set the same code for this other plugin ¨User Wallet Credit System¨ so I use your exact code and replace 'woo_credits' for 'wpuw' and doesn´t work, any idea. Thanks in advance. – Kader Gómez Jan 08 '18 at 20:14
  • @kadergomez Try to contact me on skype chat, my Id is `marsloic` – LoicTheAztec Jan 08 '18 at 20:29