Actions / Filters

By woocommerce-sl, posted on April 24, 2025

Type
Filter

Arguments
(string) $text

Description
Change the default HTML menu item text ‘License Manage’

Example of usage

Change the default text to something else

    add_filter('woo_sl/html/menu/license_manage', 'custom_html_menu_license_manage');
    function custom_html_menu_license_manage( $text )
        {
            
            $text = __('License Administration', 'software-license');
               
            return $text;   
        }

 

 

Read more

By woocommerce-sl, posted on April 24, 2025

Type
Filter

Arguments
(string) $text

Description
Change the default HTML button text ‘License Manage’

Example of usage

Change the default text to something else

    add_filter('woo_sl/html/button/license_manage', 'custom_html_button_license_manage');
    function custom_html_button_license_manage( $text )
        {
            
            $text = __('Keys Handling', 'software-license');
               
            return $text;   
        }

 

 

Read more

By woocommerce-sl, posted on November 25, 2023

Type
Filter

Arguments
(array) $disabled_buttons
(int) $licence_data_id
(text) $domain

Description
This filter serves to deactivate particular buttons within the License Management interface, offering enhanced control and customization over the functionality of the interface.

Example of usage
The following sample code removes the Delete button.

    add_filter('woo_sl/license_manage/get_disabled_buttons', '_licence_manage_get_disabled_buttons', 10, 3);
    function _licence_manage_get_disabled_buttons( $disabled_buttons, $licence_id, $domain )
        {
            $disabled_buttons['delete']   =   TRUE;
             
            return  $disabled_buttons;   
        }

Read more

By woocommerce-sl, posted on August 2, 2017

Type
Filter

Arguments
(array) $disabled_buttons
(int) $licence_data_id
(text) $domain

Description
This filter is designed to deactivate and block specific actions within the License Management interface, providing enhanced control and restriction over available functionalities.

Example of usage
The following sample code disable the Delete action. You can remove the Delete button using the following filter woo_sl/license_manage/disabled_buttons

    add_filter('woo_sl/license_manage/disabled_actions', '_licence_manage_disabled_actions', 10, 3);
    function _licence_manage_disabled_actions($ignore_actions, $licence_id, $domain)
        {
            $ignore_actions['delete']   =   FALSE;
             
            return  $ignore_actions;   
        }

Read more

By woocommerce-sl, posted on August 2, 2017

Name
woo_sl/generate_licence_keys_count

Type
Filter

Arguments
(int) $keys_count
(int) $order_id
(int) $order_item_id
(int) $license_group_id (more…)

Read more

By woocommerce-sl, posted on August 2, 2017

Name
woo_sl/order_processed/product_sl

Type
Filter

Arguments
(array) $data
(object) $order_item
(int) $order_id

Description
The woo_sl/order_processed/product_sl filter allows developers to modify the license-related data associated with a product in a WooCommerce order before it is saved into the order item metadata.
This hook is useful for customizing licensing behavior dynamically, such as changing the number of allowed keys, modifying expiration times, or adding additional flags based on order context or custom logic.

Here’s a standalone example showing how you can hook into woo_sl/order_processed/product_sl to tweak the license data before it’s saved. In this case we’ll:

  1. Prefix every license key with a custom string.
  2. Double the expiration time for products in a specific category.
  3. Add a custom flag into the data array.

 

/**
 * Customize license data before saving to order item meta.
 *
 * @param array              $data       Original license data arrays.
 * @param WC_Order_Item_Product $order_item The order item object.
 * @param int                $order_id   The ID of the processed order.
 * @return array Modified license data.
 */
function my_custom_modify_license_data( $data, $order_item, $order_id ) {
    // 1) Add a custom prefix to every licence_prefix entry
    foreach ( $data['licence_prefix'] as $i => $prefix ) {
        $data['licence_prefix'][ $i ] = 'MYCOMPANY-' . $prefix;
    }

    // 2) If product is in 'extended-support' category, double its expire time
    $product = $order_item->get_product();
    if ( $product && has_term( 'extended-support', 'product_cat', $product->get_id() ) ) {
        foreach ( $data['product_expire_time'] as $i => $secs ) {
            $data['product_expire_time'][ $i ] = intval( $secs ) * 2;
        }
    }

    // 3) Add a custom flag for downstream processing
    $data['my_custom_flag'] = array_fill( 0, count( $data['group_title'] ), true );

    return $data;
}
add_filter( 'woo_sl/order_processed/product_sl', 'my_custom_modify_license_data', 10, 3 );

Read more

By woocommerce-sl, posted on August 2, 2017

Type – Filter
Arguments – 2 ($_woo_sl_licensing_status, $order_item_id)

Read more

By woocommerce-sl, posted on August 2, 2017

Name
woo_sl/get_order_licence_details

Type
Filter

Arguments
(array) $order_licence_details
(int) $order_id

Description
Filter returned licence details for a product order.

Read more

By woocommerce-sl, posted on September 22, 2018

Type
Action

Arguments
(integer) $product_id
(string) $license_group_title

Description
Trigger when key extracted successfully from predefined keys list.

Example of usage

The following code send a message to admin when the number of keys is under 10

    add_action('woo_sl/generate_license_key/predefined_keys', 'custom_do_on_predefined_key_use');
    function custom_do_on_predefined_key_use( $product_id, $license_group_title )
        {
            
            $_sl_groups =   WOO_SL_functions::get_product_licensing_groups( $product_id );   
                                                                                     
            foreach($_sl_groups as  $key     => $_sl_group)
                {
                    if($_sl_group['group_title']    !=  $license_group_title )
                        continue;
                    
                    if(count($key_list) <   10)    
                        {
                            $product_post   =   get_post($product_id);
                            
                            //send a notice to admin
                            $to             =   'admin@mywebsite.com';
                            $subject        =   'Predefined List is getting low on keys';
                            $body           =   'The product ' .$product_post->post_title .' ( ID ' . $product_id . ' ) contain only ' . count($key_list) . ' keys';
                            $headers        =   array('Content-Type: text/html; charset=UTF-8');
                             
                            wp_mail( $to, $subject, $body, $headers );   
                            
                        }
                        
                    break;
                }   
        }

Read more

By woocommerce-sl, posted on May 3, 2022

Name
woo_sl/cron/process_licence_expire_notifications

Type
Filter

Arguments
(array) $items

Description
The filter allows interaction with the result items, that need processed and send expire notifications.

Example of usage
The following code check for any orders that include product ID 128 and remove the expire notification email for that record.

    add_filter ('woo_sl/cron/process_licence_expire_notifications', '_woo_sl_cron_process_licence_expire_notifications');
    function _woo_sl_cron_process_licence_expire_notifications( $items )
        {
            if ( ! is_array ( $items )  ||  count  ( $items )   <   1 )
                return $items; 
            
            foreach ( $items    as  $key    =>  $item )
                {
                    $order_id   =   WOO_SL_functions::get_order_by_item_id( $item->order_item_id );
                    
                    //create the order object
                    $order_data =   new WC_Order ( $order_id );
                    
                    //retrieve the order items
                    $order_items    =   $order_data->get_items();
                    
                    //loop the items
                    foreach ( $order_items  as $order_item ) 
                        {
                            $item_product   =   $order_item->get_product();
                            
                            $product_ID     =   $item_product->get_ID();
                            if ( $product_ID == 128 )
                                unset ( $items[ $key ] );
                        }
                }
            
            return $items;   
        }

Read more