我需要通过检查进入“正在处理”状态而不是“暂停”状态来使 WooCommerce 推送付款。我尝试了下面的代码片段,但它似乎没有效果。
这是我的代码:
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;
}
我怎样才能做到这一点?
谢谢。
最佳答案
这是您在 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' );
}
此代码位于您的事件子主题(或主题)的 function.php 文件中或任何插件文件中。
这已经过测试并且有效。
相关主题:WooCommerce: Auto complete paid Orders (depending on Payment methods)
关于php - 将使用支票付款方式制作的订单状态更改为 "processing"状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39920555/