WooCommerce Subscriptions: Code that processes renewals?
-
Our WooCommerce store includes memberships, which are created and sold as a type of subscription. The subscription term is one month and it auto-renews every month until canceled. We use Keap (InfusionSoft) tags to track certain aspects of each subscription, and naturally the tags should renew every month when the subscription does. However, there are some bugs in the Keap part of this process, which I need to find and fix.
Problem: I can’t find the code that is handling the Keap updates. I can’t even find the code that processes the renewals themselves in WooCommerce Subscriptions. I’ve searched do_action() calls, I’ve searched add_action and add_filter calls, and I can’t find anything that looks relevant. I see a lot of do_action calls that name hooks, but no associated add_action or add_filter calls. I see several hooks that might be associated with renewals, but the names never appear in any do_action() call. The most confusing part is some add_filter() calls that have arrays of arrays as the second parameter, such as:
switch ( $webhook->get_resource() ) {
? ? ? ? ? ? case 'order':
? ? ? ? ? ? ? ? $topic_hooks['order.created'][] = 'wcs_webhook_order_created';
? ? ? ? ? ? ? ? break;
? ? ? ? ? ? case 'subscription':
? ? ? ? ? ? ? ? $topic_hooks = apply_filters( 'woocommerce_subscriptions_webhook_topics', array(
? ? ? ? ? ? ? ? ? ? 'subscription.created' ?=> array(
? ? ? ? ? ? ? ? ? ? ? ? 'wcs_api_subscription_created',
? ? ? ? ? ? ? ? ? ? ? ? 'wcs_webhook_subscription_created',
? ? ? ? ? ? ? ? ? ? ? ? 'woocommerce_process_shop_subscription_meta',
? ? ? ? ? ? ? ? ? ? ),
? ? ? ? ? ? ? ? ? ? 'subscription.updated' ?=> array(
? ? ? ? ? ? ? ? ? ? ? ? 'wcs_webhook_subscription_updated',
? ? ? ? ? ? ? ? ? ? ? ? 'woocommerce_update_subscription',
? ? ? ? ? ? ? ? ? ? ),
? ? ? ? ? ? ? ? ? ? 'subscription.deleted' ?=> array(
? ? ? ? ? ? ? ? ? ? ? ? 'woocommerce_subscription_trashed',
? ? ? ? ? ? ? ? ? ? ? ? 'woocommerce_subscription_deleted',
? ? ? ? ? ? ? ? ? ? ? ? 'woocommerce_api_delete_subscription',
? ? ? ? ? ? ? ? ? ? ),
? ? ? ? ? ? ? ? ? ? 'subscription.switched' => array(
? ? ? ? ? ? ? ? ? ? ? ? 'wcs_webhook_subscription_switched',
? ? ? ? ? ? ? ? ? ? ),
? ? ? ? ? ? ? ? ), $webhook );
? ? ? ? ? ? ? ? break;
? ? ? ? }What does this code do? How do I trace this maze of actions that are named but apparently never called, and filters that are written but don’t seem to ever be run? Is there some trick to tracing filter and action calls, other than “search for the filter/action name in the site code and see what comes up?” How can I find the code I’m looking for?
- You must be logged in to reply to this topic.