Viewing 7 replies - 1 through 7 (of 7 total)
  • A.Tariq

    (@arsalantariq)

    Hi @davehealey
    At the moment this feature is not available but in the setting, there is an option: Allow users to activate their license keys.

    Please see the screenshot in the below link.

    https://www.awesomescreenshot.com/image/20742420?key=4e20d34b1868c51d8ed4b728efeca266

    Thanks

    Thread Starter CaptainMorgan

    (@davehealey)

    Hello,

    Thanks, is it possible to hook into this with the API to enable the license after it’s been delivered?

    A.Tariq

    (@arsalantariq)

    @davehealey
    Seems like it’s possible but it’s custom work and you need any developer help to achieve this work.

    thanks

    Thread Starter CaptainMorgan

    (@davehealey)

    For anyone else who wants this, here is the snippet you need.

    add_action('lmfwc_event_post_order_license_keys', 'auto_activate_key');
    
    function auto_activate_key( $args ) {
    
    	$orderId = $args['orderId'];
      	$licenses = $args['licenses'];
    	
    	foreach ($licenses as $license) {
    		lmfwc_activate_license( $license->getDecryptedLicenseKey() );
      	}
    }
    Thread Starter CaptainMorgan

    (@davehealey)

    @arsalantariq The snippet I put in my last post is working well except it seems the $licenses array only ever has one value in it even when there are multiple licenses in the order. So only the first license in the order is getting activated. Am I doing something wrong?

    Thread Starter CaptainMorgan

    (@davehealey)

    Ok I found a new solution

    add_action('lmfwc_event_post_order_license_keys', 'auto_activate_key');
    
    function auto_activate_key( $args ) {
    
    	$orderId = $args['orderId'];
    	
    	LicenseManagerForWooCommerce\Repositories\Resources\License::instance()->updateBy(
    		array('order_id' => $orderId),
    		array('times_activated' => 1)
    	);
    }

    @davehealey Great, thanks for your support ??

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Auto Activate’ is closed to new replies.