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
Hello,
Thanks, is it possible to hook into this with the API to enable the license after it’s been delivered?
@davehealey
Seems like it’s possible but it’s custom work and you need any developer help to achieve this work.
thanks
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() );
}
}
@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?
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 🙂