Initial Setup (Mandatory) for License Management

For the License Manager for Woocommerce from Themehigh to function on your WooCommerce Store, you will need to do following modifications,
  1. In your Licensed Product - Instantiate License manager function in the licensed plugin file.  
  2. In your Woocommerce Store - Configure License Related details for Products and Product Variations
These steps are mandatory for your store to communicate between the products on your client sites for regular check and validation of the product licenses.

Following are the modifications to be done on Licensed Product File

Download and Configure the Client Php File

  1. Download the Client PHP file [class-license-manager.php] from URL
  2. Copy the Client file to the Plugin Root folder (to be licensed)
  3. Open the copied class-license-manager.php file.
  4. Rename the Class TH_License_Manager at 2 instances to the name you would like to use with your plugin. (The class name must be unique for each Licensed Product)Instance 1 →  if(!class_exists('Your_Unique_Class_Name')):Instance 2 →  class Your_Unique_Class_Name
  5. Instantiates the renamed function in the licensed plugin file. Below you can find the sample code:
    function init_license_manager(){
    	if (!class_exists('TH_License_Manager') ) {
    		$api_url = 'http://yourserver.com/';
    		require_once( plugin_dir_path( __FILE__ ) . 'class-license-manager.php' );
    		TH_License_Manager::instance(__FILE__, $api_url, 'plugin');
    	}
    }
    init_license_manager();
    
    Note: Replace the parameter ‘plugin’ with ‘theme’, if the license settings are applied for a theme.
  6. Update the http://yourserver.com/ with your store URL
  7. Rename the Class name TH_License_Manager with the class name (Your_Unique_Class_Name) defined in the Client PHP file.
  8. Save the file.

[IMPORTANT] If the Software Identifier entered in the Product → License Setting is not the same as Plugin Name, then include the software identifier as a parameter to the function. Refer to the code below:

function init_license_manager(){
	if (!class_exists('TH_License_Manager') ) {
		$api_url = 'http://yourserver.com/';
		require_once( plugin_dir_path( __FILE__ ) . 'class-license-manager.php' );
		TH_License_Manager::instance(__FILE__, $api_url, 'plugin','Software Identifier');
	}
}
init_license_manager();

To add the URL to click here in "License Not activated, click here to activate" message on Licensed Products, 

  1. Copy the below-given code snippet to the Licensed Product file
    function thnp_license_page_url($url, $prefix){
    	$url = 'admin.php?page=thnp_license';
    	return admin_url($url);
    }
    add_filter('thlm_license_page_url_new_plugin', 'thnp_license_page_url', 10, 2);
    
  2. Replace the $url value with the URL of the tab where license settings are placed
  3. Replace new_plugin in the filter (thlm_license_page_url_new_plugin) with the software title. (In the Software title, Change all the Capital letters to small letters and replace spaces with Underscores).
  4. Save

To Display "Find out how to get your license key." message in Licensed Products, 

  1. Copy the below-given code snippet to the Licensed Product file
    function thnp_license_form_title_note( $title_note ){
    	$help_doc_url = 'https://www.themehigh.com/help-guides/';
    
    	$title_note = 'Find out how to <a href="%s" target="_blank">get your license key </a>.';
    
    	$title_note  = sprintf($title_note, $help_doc_url);
    	return $title_note;
    }
    add_filter('thlm_license_form_title_note_new_plugin', 'thnp_license_form_title_note');
    
  2. Replace the URL https://www.themehigh.com/help-guides/ in the above code snippet with suitable redirection URL to your Help doc
  3. Modify the text in the href tag as per your choice of the display message.
  4. Replace new_plugin in the filter with the software title (In the Software title, Change all the Capital letters to small letters and replace spaces with Underscores).
  5. Save
After performing the above steps, install & active the License Manager Plugin on your site. You can find the License Settings under WordPress Settings.

Woocommerce Store - Configure License Related details for Products and Product Variations

License Manager for Woocommerce comes in with the license management for Simple as well as Variable Products. To Configuring the License and have proper license management, you need to add relevant information on Product Page in 2 sections:
  1. Expiry and Activation Limit Details
  2. License Settings Information

Expiry and Activation Limit setting:

Go to Products → All Products. → Edit the Simple/Variable product.
  • Simple Product

  1. Enable the check-boxes Downloadable and Enable License
  2. Under the General tab for the product, fill the following details with respect to the downloadable Licensed Product:  
    1. Downloadable files - Add the ZIP File of the plugin for which the license settings are applied as mentioned in the topic Modifications on Licensed Product File

    2. Download Limit - Default feature of the woocommerce downloadable product, the maximum number of downloads possible for the product.

    3. Download expiry - You can enter the number of days after which the download link expires or leave blank if you do not want to set an expiry. The Download expiry will function as the expiry of the License key as well.

    4. Software Activation Limit: You can choose the number of sites for the software license to be activated. If you do not want to impose a limit,  just leave this blank for unlimited activations.

  3. Click on the Update button after making necessary changes.
 
  • Variable Product

  1. Go to Products → All Products.
  2. Click on Add Product/Edit a Variable product
  3. Enable the Enable License Checkbox.
  4. Navigate to the Variations tab, where you can find all the variations available for the product. If no variations are available, create it from the Attribute as per your requirement.
  5. Select the Variation and Enable the check-box Downloadable. Fill the rest of the required fields.
    1. Downloadable files - Add the ZIP File of the plugin for which the license settings are applied as mentioned in the topic Modifications on Licensed Product File
    2. Download Limit - Maximum number of downloads possible for a key. If you do not want to impose a limit for the downloads just leave this blank for unlimited downloads.
    3. Download expiry - You can enter the number of days after which the download link expires or leave blank if you do not want to set an expiry. The Download expiry will function as the expiry of the License key as well.
    4. Software Activation Limit: You can choose the number of sites for the software license to be activated. If you do not want to impose a limit,  just leave this blank for unlimited activations. Note: These details need to be filled in for each variation that needs to be licensed.
  6. Click on Save changes button after making necessary changes
  7. Update to confirm the changes made for the Product.
 

License Settings Information for Product:

Navigate to License Setting tab inside Product Detail Page, fill in the required fields.  
  • Software Identifier: The field name to identify the product. The system identifies the Plugin Name as Software identifier. Make sure to use the Plugin Name itself as the Software Identifier. In some cases, Plugin name and software title may differ, Replace Plugin name with Software title.
  • Software Version:  The current version number of your product. The version number should be the same as provided in the plugin file.
  • Software Page URL: The URL of your current product page
  • Software Author: The Author details of your product
  • Author URL: The URL of the author page
  • WP Version required: The minimum version of WordPress required for the product to run. If the version required and the current version of the client site are different A message, Your current WordPress version is x.x.x. The required WordPress version is y.y.y or later. while an update is available at WordPress
  • Tested Recent WP version: The latest version of WordPress that is tested & compatible with the software.
  • Updated Date: The date of the latest update of your product.
  • Description Page: Select from the drop-down list (which populates the pages in your website) the page that corresponds to your plugin details.
  • Installation Page: Select from the drop-down list (which populates the pages in your website) the page with details to the installation of your product.
  • Changelog Page: Select from the drop-down list (which populates the pages in your website) the Change log respective to your plugin.
  • Enable renewal coupon: Enabling this would generate a coupon and will be shared with the user along with the License validity expiry reminder.
Click on the Update on entering relevant data.

Leave a Reply

Your email address will not be published. Required fields are marked *