In Woocommerce, I would like to automatically put all Woocommerce Subscriptions "on hold" rather than "active" when the order is still "processing". Once I mark the order as "completed" that subscription should change to "active".
I've tried everything I can think of, if somebody knows how to do this please let me know.
I'm running wordpress 4.8.1 / Woocommerce 3.1.2 / Woocommerce Subscriptions 2.2.7 / and the payment gateway is Stripe 3.2.3.
This can be done in two steps:
1) With a custom function hooked in
woocommerce_thankyou
action hook, when the order has a 'processing' status and contains subscriptions, we update the subscriptions status to 'on-hold':Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
2) With a custom function hooked in
woocommerce_order_status_completed
action hook, when the order status is changed to "completed", it will auto change the subscription status to "active":Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
All code is tested on Woocommerce 3+ and works.