gpt4 book ai didi

COD payment with WooCommerce Subscriptions renewals: Customize order status(使用WooCommerce订阅续订的CoD支付:定制订单状态)

转载 作者:bug小助手 更新时间:2023-10-25 09:32:51 27 4
gpt4 key购买 nike



I am trying to use Cash on Delivery payment method with WooCommerce Subscriptions. But on renewal the order gets the status "Pending payment" (and the subscription goes "on-hold) I would like the order to be "Processing" status.

我正在尝试使用货到付款的方式与WooCommerce订阅。但在续订时,订单的状态为“Pending Payment”(订阅状态为“On-Hold”),我希望订单处于“正在处理”状态。


I tried this snippet but it doesn't seem to work with subscriptions renewal orders:

我尝试了这个片段,但它似乎不适用于订阅续订订单:


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

更多回答
优秀答案推荐

Updated - Try the following:

更新-尝试以下操作:


add_filter( 'wcs_new_order_created', 'customize_renewal_cod_order_status', 10, 3 );
function customize_renewal_cod_order_status( $order, $subscription, $type ) {
$parent_order = $subscription->get_related_orders('all', 'parent');
$parent_order = reset($parent_order);

if ( $type === 'renewal_order' && $parent_order->get_payment_method() === 'cod' && $order->has_status('on-hold') ) {
$order->set_status('wc-processing');
$order->save();

$subscription->set_status('wc-active'); // Optional
$subscription->save(); // Optional
}
return $order;
}

It should work now.

现在应该行得通了。


更多回答

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com