• I need to get the subscription key of a particular subscription to pass into a custom function. I have referenced the documentation where it shows how to get the key, but I have failed to integrate this into my code. So what my code does is, when a renewal is triggered, I hook into processed_subscription_payment with my function. So this code is run only when a subscription renewal is payed. Code is below.

    Documentation is here: https://docs.woothemes.com/document/subscriptions/develop/functions/management-functions/

    Code here (which resides in functions.php):

    add_action( 'processed_subscription_payment', 'callupdater' );
    
    function callupdater()
    {
    	//need to get the subscription key here to pass to updatedays()
            $key = .....
    	updatedays(key);
    }
    
    function updatedays($subscription_key)
    {
    	//do some tasks with the key
    }

    Any help is very much appreciated. I am very new to PHP so excuse my ignorance.

Viewing 1 replies (of 1 total)
  • Thread Starter beaver316

    (@beaver316)

    I figured out the answer, so I thought I’d post it. My code looks like this now and it works:

    add_action( 'processed_subscription_payment', 'updatedays', 10, 2 );
    
    function updatedays($user_id, $subscription_key)
    {
        //do what I need to the sub key
    }

    There really needs to be more examples on the Woothemes documentation though..

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Woocommerce Subscriptions] How to get subscription key or id’ is closed to new replies.