doudi8298 2016-10-07 15:11
浏览 80
已采纳

使用支票付款方式将订单状态更改为“处理”状态

I need to make WooCommerce push payments made by check into the "processing" status rather than the "on hold" status. I tried the snippet below however it doesn't seem to have an effect.

Here is my code:

add_filter( 'woocommerce_payment_complete_order_status', 'sf_wc_autocomplete_paid_orders' );

function sf_wc_autocomplete_paid_orders( $order_status, $order_id ) {

$order = wc_get_order( $order_id );

if ($order->status == 'on-hold') {
    return 'processing';
}

return $order_status;
}

How can I achieve this?

Thanks.

  • 写回答

2条回答 默认 最新

  • du5591 2016-10-07 15:48
    关注

    Here is the function you are looking at hooked in woocommerce_thankyou hook:

    add_action( 'woocommerce_thankyou', 'cheque_payment_method_order_status_to_processing', 10, 1 );
    function cheque_payment_method_order_status_to_processing( $order_id ) {
        if ( ! $order_id )
            return;
    
        $order = wc_get_order( $order_id );
    
        // Updating order status to processing for orders delivered with Cheque payment methods.
        if (  get_post_meta($order->id, '_payment_method', true) == 'cheque' )
            $order->update_status( 'processing' );
    }
    

    This code goes in function.php file of your active child theme (or theme) or also in any plugin file.

    This is tested and works.


    Related thread: WooCommerce: Auto complete paid Orders (depending on Payment methods)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 csmar数据进行spss描述性统计分析
  • ¥15 各位请问平行检验趋势图这样要怎么调整?说标准差差异太大了
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 wpf界面一直接收PLC给过来的信号,导致UI界面操作起来会卡顿
  • ¥15 init i2c:2 freq:100000[MAIXPY]: find ov2640[MAIXPY]: find ov sensor是main文件哪里有问题吗
  • ¥15 运动想象脑电信号数据集.vhdr
  • ¥15 三因素重复测量数据R语句编写,不存在交互作用
  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?