Change default ‘X domains per key’ with arbitrary text within WooCommerce Software License

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInPrint this page

By woocommerce-sl,posted on August 1, 2017

As default the WooCommerce Software License plugin output a ‘X domains per key’ within order page, client and admin e-mails, my account areas etc. This because is presumed the purchasable is being linked to a domain (e.g. a downloadable software).

But this is not necessarily to say that way, arbitrary texts can be used depending on the Product type and profile.

Change this

to

This can be achieved using the filter woo_sl/html/max_instances_per_key. 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;
}


Category: