通过 WooCommerce 订阅续订进行 COD 付款:自定义订单状态

问题描述 投票:0回答:1

我正在尝试对 WooCommerce 订阅使用货到付款付款方式。但续订时,订单状态为“待付款”(并且订阅变为“暂停”),我希望订单处于“处理中”状态。

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

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';
}
php wordpress woocommerce orders woocommerce-subscriptions
1个回答
0
投票

已更新 - 尝试以下操作:

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

现在应该可以工作了。

© www.soinside.com 2019 - 2024. All rights reserved.