Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
610 views
in Technique[技术] by (71.8m points)

php - Change COD default order status to "On Hold" instead of "Processing" in Woocommerce

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 ); 
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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"


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...