Change the Order Status After Successful Payment Using Subscriptions for WooCommerce

The following code snippet can be used to change the status of an order to ‘completed’ after a payment has been processed successfully. Simply add the following code snippet to the active child theme function.php.

5 thoughts on “Change the Order Status After Successful Payment Using Subscriptions for WooCommerce

  1. colin
    Colin says:

    Hi Safwana
    So adding the above code will just mark the original order as complete, but leave all the recurring payment alone? i.e. if a customers has 5 recurring payments, the original order will say complete, but the remaining 4 payments will all work fine and live in the WebToffee Subscriptions tab?
    Thanks

    • Safwana
      Safwana says:

      Hi Colin,

      The above code snippet will change the status of orders to “completed” when it comes in as “processing”. Also, if the recurring order comes in the processing status, that will also be marked as completed.
      If the parent order is set to complete from processing, that will not affect the remaining recurring orders and they will occur as expected.

  2. Rob says:

    Does this work for recurring subscriptions?

    At the moment, only the first payment is taken and the subscription then shows as ‘on hold’.

    I’ve done something similar to the above snippet for virtual products setting them to complete when payment is taken, but the subscriptions have a status of ‘active’ when complete.

    So does this work, or should I just change it to $order->update_status(‘active’); ?

    (I don’t have access to the site’s database to see what it’s actually stored as).

      • Safwana
        Safwana says:

        Hi Rob,

        The above snippet will let you mark the parent order as complete, which would be set to processing by default after payment processing. The subscription order status will be set to active if the order status is either processing or complete, considering the payment completed successfully.

        The issue could be related to payment failure. Please reach us via our support desk and share us the version of the plugin and the payment gateway plugin you are using so that the developers can have a look.

Leave a Reply

Your email address will not be published. Required fields are marked *