Syncing WooCommerce Subscriptions to Intercom now even more powerful

We believe that subscription sites succeed or fail based on the quality of their customer support. And so, the WooCommerce Subscriptions module of our WooCommerce to Intercom plugin got some ❤️ this dev sprint.

v1.10 is in internal testing now and should be released this week. 🤓

Alongside some small tweaks to the automatic subscriber tagging/untagging, 3 new filters have been added, whilst refactoring lead to 6 filters and a handful of private functions being deprecated for more efficient code.

Below we run over the 3 new filters, a couple of examples and some info on what’s been deprecated.

‘ewi_sub_tag_name’

Used to rename the tag that is given to or removed from a User who holds ANY active subscriptions on your site.

Accepted Arguments:

  • String $tag_title

Example: Change the tag name for your active subscribers from ‘subscribers’ to ‘VIPs’:

add_filter('ewi_sub_tag_name', 'ektgn_change_subs_tag_name', 20, 1);

function ektgn_change_subs_tag_name($tag_title){
  return 'VIPs';
}

‘ewi_subs_event_meta’

Add/remove/change the event meta data based on what happened to the Subscription.

Accepted Arguments:

  • Array $meta_data
  • WC_Subscription $sub_object
  • String $action – the action that triggered the filter.

    for status changes: status_pending, status_active, status_on-hold, status_pending-cancel, status_cancelled or status_expired
    
    for scheduled actions: 'sched_end_of_prepaid_term' or 'sched_trial_end'
    
    for payment actions: 'payment_completed' or 'payment_failed'
    
This filter replaces and deprecates the following filters from v1.10.0.
If you’re using them, please switch to ‘ewi_subs_event_meta’.

Deprecated filters:

  • ewi_subscription_activated_meta
  • ewi_subscription_end_prepaid_meta
  • ewi_subscription_trial_ended_meta
  • ewi_subscription_payment_meta
  • ewi_subscription_payment_failed_meta
  • ewi_subscription_activated_meta

‘ewi_subs_event_name’

Change the event title that’s synced, based on the Subscriptions new status

Accepted Arguments:

  • String $event_title – the event’s title eg ‘subscription activated’ or ‘subscription on-hold’
  • String $action – the action that triggered the filter.

    for status changes: status_pending, status_active, status_on-hold, status_pending-cancel, status_cancelled or status_expired
    
    for scheduled actions: 'sched_end_of_prepaid_term' or 'sched_trial_end'
    
    for payment actions: 'payment_completed' or 'payment_failed'
    

Example: Change the event name from ‘subscription activated’ to ‘Ching ching baby!’

add_filter('ewi_subs_event_name', 'ektgn_change_subs_event_activated', 20, 2);

function ektgn_change_subs_event_activated($event_title, $action){
  if ('active' !== $action) {
    // this is not triggered by a status change to 'active' so we return the initial value.
    return $event_title;
  }
 
  return 'Ching ching baby!';
}
Posted in:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.