Actions / Filters

By woocommerce-sl, posted on April 8, 2020

Name
woo_sl/show_extend_button/label

Type
Filter

Arguments
$label
$order_id
$order_item_id
$new_price
$_product_expire_units
$_product_expire_time

Description
Change the Extend Button label

Example of usage

    add_filter('woo_sl/show_extend_button/label', 'custom_show_extend_button_label', 10, 5);
    function custom_show_extend_button_label( $label, $order_id, $order_item_id, $new_price, $_product_expire_units, $_product_expire_time )
        {
            
            $label = 'Extend Product for ' . $new_price;
               
            return $label;   
        }

Read more

By woocommerce-sl, posted on August 30, 2017

Type
Filter

Arguments
(array) $product_fields

Description
Add / Remove / Change admin product fields.

Example of usage

    add_filter('woo_sl/admin/product_fields', 'custom_product_fields');
    function custom_product_fields( $product_fields )
        {
            
            foreach($product_fields as  $key    =>  $product_field_data)
                {
                    if( is_array( $product_field_data ) && ( !isset($product_field_data['function']) ||   $product_field_data['function'] !=  'WOO_SL_admin_product::html_license_keys' ) )
                        {   
                            $product_fields[$key]['style'] =   'display: none';
                        }     
                    
                }
               
            return $product_fields;   
        }

Read more

By woocommerce-sl, posted on August 1, 2017

Read more

By woocommerce-sl, posted on August 2, 2017

Trigger before licence interface actions buttons. This send along 1 arguments:

$licence_id

Read more

By woocommerce-sl, posted on August 2, 2017

Trigger after licence interface actions buttons. This send along 1 arguments:

$licence_id

Read more

By woocommerce-sl, posted on August 2, 2017

Read more

By woocommerce-sl, posted on August 8, 2024

Type
Action

Arguments
int $licence_id
array $args

Description
This filter allows developers to modify the columns displayed in the license details table within the my-licence-manage.php template file. By using this filter, you can append additional columns, remove existing ones, or change the content of the default columns. The default columns include License Key, Status, Domain, and Action.

Example of usage
The following example demonstrates how to add a new column called “Creation Date” to the license details table, which displays the creation date of each license. Keep in mind you have to add a table “Creation Date” header in the my-licence-manage.php template file, as explained in the article Update the License templates

add_filter('woo_sl/interface/license_keys_meta_box/td', 'theme_add_create_date_column', 10, 3);

function theme_add_create_date_column($licence_id, $args)
{
    // Retrieve the license details using the licence ID.
    $license_data = WOO_SL_functions::get_licence_key_data_by_licence_id($licence_id);

    // Extract the expiration date from the license data, or default to 'N/A' if not set.
    $created_date = isset ( $license_data->created ) ? $license_data->created : __('N/A', 'software-license');

    // Build the expiration date column as an HTML <td> element.
    $args['columns']['created_date'] = '<td>' . esc_html( $created_date ) . '</td>';

    return $args;
}

In this example:
– The filter woo_sl/interface/license_keys_meta_box/td is hooked into a custom function theme_add_expiration_date_column.
– The $columns array contains all the existing table columns, each defined as an HTML <td> element.
– The custom function appends a new column to display the license’s creation date. If no creation date is found, it returns “N/A”.
– The $order_item_id and $license_group_id parameters are used to retrieve the relevant order and license details necessary for extracting the expiration date.

By using this filter, you can easily extend or customize the license details table to include any additional information you wish to display.

Read more

By woocommerce-sl, posted on August 1, 2017

Type
Filter

Arguments
text $instances
integer order_item_id
integer $licence_group_id

Description
Add / Remove / Change ‘instances per key’ text.

Example of usage
An example on how to change the text from ‘7 domains per key’ to ‘7 seats per key’:


add_filter('woo_sl/html/max_instances_per_key', 'theme_html_max_instances_per_key', 10, 3);

function theme_html_max_instances_per_key($instances, $order_item_id, $licence_group_id)
{
	$order_id = WOO_SL_functions::get_order_by_item_id($order_item_id);
	$order_licence_details = WOO_SL_functions::get_order_licence_details($order_id);
	$product_licence_data = $order_licence_details[$order_item_id][$licence_group_id];
	$max_instances_per_key = $product_licence_data->license_data['max_instances_per_key'];
	$instances = ' - ' . sprintf(_n('1 seat', '%s seats', $max_instances_per_key, 'software-license') , $max_instances_per_key) . ' per key';
	return $instances;
}

Read more

By woocommerce-sl, posted on September 26, 2018

Type
Filter

Arguments
(string) $text

Description
Change the default HTML text ‘You can manage your keys from My Account’

Example of usage

Change the default text to something else

    add_filter('woo_sl/html/manage_keys', 'custom_html_manage_keys');
    function custom_html_manage_keys( $text )
        {
            
            $text = __('See your account for more keys.', 'software-license');
               
            return $text;   
        }

Read more

By woocommerce-sl, posted on November 28, 2023

Type
Filter

Arguments
(string) $html
(int) $order_item_id
(object) $order_item
(object) $order
(more…)

Read more