WooCommerce License Keys has WordPress hooks all over the place to allow you full customization. The following are the action hooks we think you will want to use the most, you are free to take a look at the code to find more.
woocommerce_license_keys_generated
Triggered after license keys are created for an order item.
Parameters
$order_id
int
Order ID.
$item
WC_OrderItem
The order item object which contains the license key data information.
Example
add_action( 'woocommerce_license_keys_generated', function( $order_id, $item ) { foreach ( LicenseKey::from_order( $order_id ) as $license_key ) { $license_key = apply_filters( 'woocommerce_license_key', $license_key ); // Do code } }, 10, 2 );
woocommerce_license_key_activation_activated
Triggered by the API when an activation has been activated in a license key.
Parameters
$license_key
LicenseKey model
License key data model already filtered with filter hook `woocommerce_license_key`
.
$activation_id
int
Activation ID or activation timestamp.
Example
add_action( 'woocommerce_license_key_activation_activated', function( $license_key, $activation_id ) { // To do code over license key echo $license_key->the_key; // Find the activation foreach ( $license_key->uses as $activation ) { if ( $activation['date'] === $activation_id ) { // Do code echo $activation['ip']; } } }, 10, 2 );
woocommerce_license_key_activation_validated
Triggered by the API when an activation has been validated.
Parameters
$license_key
LicenseKey model
License key data model already filtered with filter hook `woocommerce_license_key`
.
$activation_id
int
Activation ID or activation timestamp.
Example
add_action( 'woocommerce_license_key_activation_validated', function( $license_key, $activation_id ) { // To do code over license key echo $license_key->the_key; // Find the activation foreach ( $license_key->uses as $activation ) { if ( $activation['date'] === $activation_id ) { // Do code echo $activation['ip']; } } }, 10, 2 );
woocommerce_license_key_activation_deactivated
Triggered by the API when an activation has been deactivated.
Parameters
$license_key
LicenseKey model
License key data model already filtered with filter hook `woocommerce_license_key`
.
$activation_id
int
Activation ID or activation timestamp.
Example
add_action( 'woocommerce_license_key_activation_validated', function( $license_key, $activation_id ) { // To do code over license key echo $license_key->the_key; // Activation removed echo date( get_option( 'date_format', 'Y-m-d' ), $activation_id ); }, 10, 2 );
woocommerce_license_key_saved
Triggered by the API when an activation is saved or updated. For example, when a new activation is added or deactivated.
We recommend to triggered by you as well if you plan to update the license key using a model.
Parameters
$license_key
LicenseKey model
License key data model already filtered with filter hook `woocommerce_license_key`
.
Example
add_action( 'woocommerce_license_key_saved', function( $license_key ) { // To do code over license key echo $license_key->the_key; } );
woocommerce_license_key_cancelled
Triggered when an order with a generated license key has been canceled or refunded.
Parameters
$license_key
LicenseKey model
License key data model already filtered with filter hook `woocommerce_license_key`
.
$order_id
int
Related order id.
Example
add_action( 'woocommerce_license_key_cancelled', function( $license_key, $order_id ) { // Your code here }, 10, 2 );
woocommerce_license_key_renewed
Only available on WooCommerce License Keys extended plugin.
Triggered when a license key has been renewed (semi-automatic subscription).
Parameters
$license_key
LicenseKey model
License key data model already filtered with filter hook `woocommerce_license_key`
.
$item
WC_OrderItem
Order item.
$order
WC_Order
Order.
Example
add_action( 'woocommerce_license_key_renewed', function( $license_key, $item, $order ) { // Your code here }, 10, 3 );
woocommerce_license_key_extended
Only available on WooCommerce License Keys extended plugin.
Triggered when a license key has been extended (semi-automatic subscription).
Parameters
$license_key
LicenseKey model
License key data model already filtered with filter hook `woocommerce_license_key`
.
$item
WC_OrderItem
Order item.
$order
WC_Order
Order.
Example
add_action( 'woocommerce_license_key_extended', function( $license_key, $item, $order ) { // Your code here }, 10, 3 );