【问题标题】:Woocommerce Paypal Order Status Not ChangingWoocommerce Paypal 订单状态未更改
【发布时间】:2019-02-01 23:04:58
【问题描述】:
add_filter( 'woocommerce_payment_complete_order_status', 'status_after_order', 10, 2 );

function status_after_order( $order_status, $order_id ){
    echo $order_status;
}

当我们通过贝宝订购时,管理员可以设置保留库存(Woocommerce > 产品 > 库存)。超时后订单状态自动更新为管理员的“已取消”,但是当我们使用上述过滤器时,它显示“处理中”。

在这种情况下,它会给我“取消”状态的任何过滤器/操作。你能帮我解决这个问题吗?

【问题讨论】:

    标签: wordpress woocommerce


    【解决方案1】:

    好吧,首先您使用的钩子仅用于订单完成状态,这就是您没有获得订单状态的原因。

    但是我不知道你在检测到订单后到底想做什么,但你有两个解决方案:

    第一个解决方案是检测订单状态何时从任何状态更改为已取消

    add_action('woocommerce_order_status_cancelled', 'check_status', 30, 2);
    
    function check_status($order_id)
    {
        wp_die( $order_id ); // this will echo the id or you can do whatever you want here 
    
    }
    

    第二种解决方案是使用此钩子检查订单是否已从某种状态更改为另一种状态:

    add_action('woocommerce_order_status_changed', 'check_status', 30, 3);
    
    function test12($id, $old_status, $new_status)
    {
    
        if ($new_status == 'cancelled') {
            //do Somthing
        }
    
    }
    

    【讨论】:

      猜你喜欢
      • 2017-05-24
      • 2018-01-01
      • 2022-09-30
      • 2018-08-30
      • 2019-07-30
      • 2022-10-05
      • 2021-04-08
      • 2016-08-04
      • 1970-01-01
      相关资源
      最近更新 更多