Set parent order manually for WooCommerce Subscriptions

Last Updated on: 6th November 2023, 10:15 am

WooCommerce Subscriptions is a great plugin for managing recurring payments on your WooCommerce site. However, sometimes the parent order may go missing, due to migrations, a rollback, or other unforeseen circumstances. If this happens, you can set the parent order manually using the following code snippet:

// insert the subscription ID
$subscription = wcs_get_subscription( 256 ); 

// insert the order ID.
$subscription->set_parent_id( 258 );


To use this code snippet, you will need to know the subscription ID and the parent order ID. You can find the subscription ID by going to WooCommerce > Subscriptions and looking at the list of subscriptions. The parent order ID is the ID of the order that created the subscription. You can find this ID by going to WooCommerce > Orders and looking at the order details.

I use the fabolous to run this.

Once the command has finished running, the parent order will be set for the subscription. You can then verify this by going to WooCommerce > Subscriptions and looking at the order details for the subscription.

Make sure to back up your database before running the code snippet.

Leave a Reply

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

Con Schneider