Actions / Filters

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

Type – Filter
Arguments – 4 ( (intval)1, $order_id, $order_item_id, $key)

Read more

By woocommerce-sl, posted on August 2, 2017

Type – Filter
Arguments – 3 ($data, $order_product, $order_id)

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

By woocommerce-sl, posted on August 3, 2023

Name
woo_sl/cron/schedule_interval

Type
Filter

Arguments
(text) $schedule_interval

Description
The filter allows interaction with the default cron schedule interval, which is set to hourly.

Example of usage
As default, the CRON process the expired licences every hour. If require a different interval, the current filter can be used. The following code changes the cron to run every half hour.

        add_filter ('woo_sl/cron/schedule_interval', '_woo_sl_cron_schedule_interval');
    function _woo_sl_cron_schedule_interval( $schedule_interval )
        {
            return 'half_hour';  
        }
    
    //register the custom schedule interval
    //More details at https://developer.wordpress.org/reference/hooks/cron_schedules/
    add_filter( 'cron_schedules',   array( $this, '_woo_sl_cron_custom_schedule_interval' ));
    function _woo_sl_cron_custom_schedule_interval( $schedules )
        {
            $schedules['half_hour'] = array(
                                            'interval'  => 60 * 30,
                                            'display'   => __('Every half hour', 'software-license')
                                        );
            
            return $schedules;   
            
        }

Read more

By woocommerce-sl, posted on June 9, 2020

Name
WOOSL/API/product_validation/granted_statuses

Type
Filter

Arguments
$granted_statuses

Description
Add custom statuses for granted product statuses

Example of usage

    add_filter('WOOSL/API/product_validation/granted_statuses', 'WOOSL_API_product_validation_granted_statuses');
    function WOOSL_API_product_validation_granted_statuses( $granted_statuses )
        {
            
            $granted_statuses[] = 'promotion';
               
            return $granted_statuses;   
        }

Read more