WooCommerce Order and Subscription Creation Actions
Actions not firing upon subscription creation? Try these actions and filters.
If you’re using a WooCommerce plugin like Cartflows, subscription
actions initialized using woocommerce_checkout_subscription_created
may not fire.
In the case of Cartflows, child orders created in Upsells or Downflows do not
trigger the aforementioned action, presumably because a unique checkout is not
occuring.
If you still need to trigger an action for creation of a Cartflow upsold
subscription, there is also an undocumented action wcs_create_subscription
.
There is also a filter with the same name, you can check out the source
here.
It seems like this using this hook may be more robust than
woocommerce_checkout_subscription_created
or the status change actions.
Example of usage:
1 | function on_subscription_created($subscription) |
Note on Subscriptions Created via Admin
The wcs_create_subscription
action will not fire for subscriptions created via
the admin interface. In order to trigger actions in admin, you must use the
stranglely-named woocommerce_process_shop_order_meta
, and then add logic to confirm that
the order is a subscription. See this stackoverflow
post for more information.