Change the subscription status to on hold when the customer pays with COD

WooCommerce Subscriptions by default activate a subscription only when the order status is at least Processing.
That means that also when the customer choose to pay with COD (Cash on Delivery), he will have the subscription active immediately after the checkout process completes.

It makes sense that the COD default status is not On Hold. The order needs to be processed before to get the payment, so On Hold would be wrong since you are actually processing the order, shipping it, and only then you receive the payment.

Sometimes though, with a subscription, this behaviour could be wrong.

There’s a way to put the subscription on hold when the customer choose to pay with COD. Open the file functions.php located in wp-content/themes/your-theme-name/ and add this code at the end of the file:

This code checks if the payment gateway used is COD, in that case, checks if the order status is Completed. If the gateway is that, but the order status is not Completed, the subscription status changes to “On Hold” so the customer can’t use it before you receive the payment.

You don’t have to worry about manually activating the subscription when you received the payment. As soon as you change the order status to Completed, the subscription status changes to Active automatically.

More Posts That You Might Like…

8 responses to “Change the subscription status to on hold when the customer pays with COD”

  1. […] a tutorial on settings WooCommerce subscriptions to hold when the COD gateway is used from Nicola […]

  2. Hello Nicola,
    I actually need to set the default order status for COD to pending instead of processing. I have tried this

    add_action( ‘woocommerce_thankyou’, ‘my_order_status’, 50 );
    function my_order_status( $order_id ) {
    if ( ! $order_id ) {
    $order = wc_get_order( $order_id );
    if ( ( get_post_meta( $order->id, ‘_payment_method’, true ) == ‘cod’ ) && ( $order->status == ‘processing’ ) ) {

    but it did not work…could you tell me what I am doing wrong?
    Thank you so much!

  3. Hi Nicola,

    I really appreciate the great content you post in your blog it has truly helped me a lot.

    I have a question regarding woocommerce subscriptions:
    How can you make every new subscription, automatically be on hold?

    Thank you in advance,


    1. Hi Daniel,
      You can use the same code, but without checking what is the payment gateway ID.

      1. Thank you for the quick reply Nicola.

        That’s the thing, I tried that and it didn’t work so I contacted you for some help.

        What I understand from your reply and what I tried is this:

        On line 14 instead of:

        if ( $payment_gateway->id == ‘cod’ && $order->get_status() != ‘completed’ ) {

        I wrote:

        if ( $order->get_status() != ‘completed’ ) {

        This is what you meant right?

        By the way I’m running woocommerce 3.1.2 and woocommerce subscribtions 2.2.7

        Thank you so much, for replying to the comment.


  4. Hi Nikola,
    I think you might be able to help me with this issue I’ve been having for quite a while now. As you know, by default, when a customer starts their free trial, the subscription status is set to active, however there is a bit of setup required for my service so I would like the subscription status of products within specific categories to be set to pending by default. And when I am ready to begin the actual trial I can just activate it manually. Any idea how to accomplish this? I t would be greatly appreciated! ?

  5. Another thing I’m trying t achieve is for a customer to be able to check a box in a gravity form and when they submit the form it will add the product to their cart. Would u know how I can make this happen?

  6. colin froggatt Avatar
    colin froggatt

    Hi, this is using the now deprecated “WC_Subscriptions_Manager::put_subscription_on_hold” (as of 2.0). How would we do this for v3? -C

Leave a Reply



Receive new articles from this blog directly in your inbox!

No spam guaranteed!

Blog at

%d bloggers like this: