phpwordpresswoocommerceorderswoocommerce-subscriptions

COD payment with WooCommerce Subscriptions renewals: Customize order status


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.

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

Solution

  • 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.