1
votes

I need help with a problem-related to plugin "WooCommerce Pay for Payment" which counting some extra fee in shipping. Problem is, that this plugin sets automatically "processing" status in order which causes thanking email for payment (in case of local payment) and don't send email notification about a new order, so customer is confused (I didn't send any money and I received email "thanks for your payment").

I tried this solution: Set WooCommerce order status when order is created from processing to pending

But it only changes order status back to "on-hold" but sends email thank for payment anyway.

Only one thing that I need is to send to the customer in every new order email about a new order, nothing more (I would like to change status to "processing" manually).

Thank you for help, I have no idea how to resolve because I couldn't find PHP file causing a change of status in the plugin.

EDIT: Sorry to all. This was problem of COD in woocommerce plugin. Not Pay for payment as I mentioned. Woocommerce COD automatically set "processing" status.

I found solution for this on github:here

Its the first code.

Based on the answer to this question, this code worked fine for me:

function sv_wc_cod_order_status( $status ) {
    return 'on-hold';
}
add_filter( 'woocommerce_cod_process_payment_order_status', 'sv_wc_cod_order_status', 15 ); 
3
If you found a solution, please post an answer to your own question. - Kevin Workman
I have found a much better and efficient solution than the one you found on Github, since there is a dedicated filter hook in for COD Payment method… Please check the answer. It is tested and works. - LoicTheAztec
LoicTheAztec: I am sorry but it doesn't work. See comment bellow your answer. Thanks - Jiří Prek
Yes it's working perfectly. It's made for that. But you need to remove your other related customization code before. I have tested it on many installations from Woocommerce 3 to 3.5.x and it works just fine. When you look at the source code, we are just changing the default status from 'processing' to 'on-hold' status when using this filter. That's all. So the error comes from somewhere else. - LoicTheAztec
LoicTheAztec: Now I tried clear all functions.php and leave only your code- It isn't working. Next I deactivated all plugins except Woocommerce and Really simple ssl and again it isn't working. I have no idea what is causing this issue, but simply is not good for me. Have any idea? I am using easy commerce theme - Jiří Prek

3 Answers

8
votes

Updated: The code that you found in Github is outdated, clumsy and complicated, since there is a dedicated filter hook now. You should better try this lightweight and effective code, that will set the default order status for "Cash on delivery" payment gateway (COD) to "On Hold":

add_filter( 'woocommerce_cod_process_payment_order_status', 'change_cod_payment_order_status', 10, 2 );
function change_cod_payment_order_status( $order_status, $order ) {
    return 'on-hold';
}

Code goes in functions.php file of your active child theme (active theme). Tested and works.

enter image description here

So the default order status set by the payment gateway is now "On Hold" instead of "Processing"

1
votes

In my case,

add_filter( 'woocommerce_cod_process_payment_order_status','change_cod_payment_order_status', 10, 2 );
function change_cod_payment_order_status( $order_status, $order ) {
  return 'on-hold';
}

Worked great in WC 4.42 + WP 5.4.1

Thx!

0
votes

two solution above are same except:

  • the solution by @LoicTheAztek has 2 arguments in the core function and have a '10' hook priority
  • the solution by @Jiří-Prek has an arguments in the core function and have a '15' hook priority

but for my WP5.1.1 and WC3.5.7

function change_cod_payment_order_status( $order_status, $order ) {
return 'on-hold';

}

generating an error

PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function change_cod_payment_order_status()

so I prefer use the code with only one argument in a main function