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.
现在应该行得通了。
更多回答
我是一名优秀的程序员,十分优秀!