Setup Free Trial Product/Service on WHMCS – GK~Blog

Setup Free Trial Product/Service on WHMCS


In this tutorial we will go over the steps to set up a free trial product in WHMCS system. Free Trial product can be used for any product you want to offer a trial version.


Step 1 (Setup Product)

Go to: Setup >> Products/Services And add your Free Trial product by click “Create a New Product“.

Fill in the details of your product in all required fields according to your needs.

Under the tab “Pricing”  Select the “Payment Type” Free, Edit the “Auto Terminate/Fixed Term” field and enter the number of days after activation to automatically terminate.

If you want to limit the possibility to order more than one Free Trial product, under the tab “Upgrades” do not allow upgrading to paid product.


Step 2 (Create limits)

Create a new PHP file in your WHMCS “/includes/hooks” folder named “limit_free_trial.php“.

Within the file paste the following function:

function limitFreeTrialOrders($vars) {
    if(mysql_num_rows(mysql_query("SELECT id FROM `tblhosting` WHERE `userid` = '{$_SESSION['uid']}' AND `packageid` = 'YOUR PACKAGE ID'")) > 0) {
        global $errormessage;
        $errormessage = "<li>You can order Free Trial product only once!.</li>";
add_hook("ShoppingCartValidateCheckout", 1, "limitFreeTrialOrders");

Do not forget to edit the SQL query line and put your product id insted of “YOUR PACKAGE ID“.


Step 3 (Testing)

Try to order one Free Trial product And after that try to order one more Free Trial product. If you are unable to order Free Trial product again It means you’ve finished setup and configuring your Free Trial product.

Enjoy 🙂