在 Woocommerce 中将 COD 默认订单状态更改为 "On Hold" 而不是 "Processing"

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

我需要帮助解决与插件 "WooCommerce Pay for Payment" 有关的问题,该插件计算了一些额外的运费。问题是,这个插件自动设置 "processing" 状态,导致感谢电子邮件付款(在本地付款的情况下)并且不发送关于新订单的电子邮件通知,所以客户很困惑(我没有汇款,我收到电子邮件 "thanks for your payment").

我试过这个解决方案:

但它只是将订单状态更改回 "on-hold" 但无论如何都会发送电子邮件感谢付款。

我只需要在每封新订单电子邮件中向客户发送有关新订单的信息,仅此而已(我想手动将状态更改为 "processing")。

感谢您的帮助,我不知道如何解决,因为我找不到 PHP 文件导致插件中的状态发生变化。

编辑:对不起大家。这是 woocommerce 插件中 COD 的问题。不像我提到的那样支付付款。 Woocommerce COD 自动设置 "processing" status.

我在 github 上找到了解决方案:here

这是第一个代码。

根据这个问题的答案,这段代码有效对我来说很好:

function sv_wc_cod_order_status( $status ) {
    return 'on-hold';
}
add_filter( 'woocommerce_cod_process_payment_order_status', 'sv_wc_cod_order_status', 15 ); 

更新: you found in Github is outdated, clumsy and complicated, since there is a dedicated filter hook 现在的代码。您最好尝试这个轻量级有效的代码,它将 "Cash on delivery" 支付网关 (COD) 的默认订单状态设置为 "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';
}

代码进入您的活动子主题(活动主题)的 functions.php 文件。已测试并有效。



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

上面的两个解决方案是相同的,除了:

  • @LoicTheAztek 的解决方案在核心函数中有 2 个参数,挂钩优先级为“10”
  • @Jiří-Prek 的解决方案在核心函数中有一个参数并且具有“15”挂钩优先级

但对于我的 WP5.1.1 和 WC3.5.7

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

生成错误

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

所以我更喜欢在主函数中使用只有一个参数的代码

就我而言,

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

在 WC 4.42 + WP 5.4.1 中表现出色

谢谢!