Mytihost Posted Monday at 11:21 AM Share Posted Monday at 11:21 AM Hey All Looking for some advice. I currently sell a product with monthly and yearly billing. Currently on the first month they get a 100% discount off the first months subscription to evaluate the service free of charge. My issue is yearly I would like to affectively do the same. The idea is if someone purchases a yearly plan they get 1 free month to evaluate the service. Example someone placed an order today the product would be set up today. However invoice and payment would then be due the following month on the 2nd March for the year. Is this achievable using a hook I know I can create a trial product for evaluation purposes but I would rather not have to create a separate product if I can defer invoice payment to the following month this would then essentially be there evaluation period. Thanks 0 Quote Link to comment Share on other sites More sharing options...
RadWebHosting Posted yesterday at 11:12 AM Share Posted yesterday at 11:12 AM (edited) Try something like this: <?php /** * WHMCS Hook: Add 1 month to Next Due Date * Only runs for a specific product after provisioning * * Trigger: AfterModuleCreate */ use WHMCS\Database\Capsule; add_hook('AfterModuleCreate', 1, function ($vars) { // CHANGE THIS to your target Product ID $targetProductId = 123; $serviceId = (int) ($vars['serviceid'] ?? 0); if (!$serviceId) { return; } $service = Capsule::table('tblhosting') ->where('id', $serviceId) ->first(); if ( !$service || (int) $service->packageid !== $targetProductId || empty($service->nextduedate) ) { return; } $nextDue = new DateTime($service->nextduedate); $nextDue->modify('+1 month'); Capsule::table('tblhosting') ->where('id', $serviceId) ->update([ 'nextduedate' => $nextDue->format('Y-m-d'), ]); }); Change 123 to your specific product ID. Edited yesterday at 11:17 AM by RadWebHosting specific product use case 0 Quote Link to comment Share on other sites More sharing options...
Mytihost Posted 5 hours ago Author Share Posted 5 hours ago On 2/4/2026 at 11:12 AM, RadWebHosting said: Try something like this: <?php /** * WHMCS Hook: Add 1 month to Next Due Date * Only runs for a specific product after provisioning * * Trigger: AfterModuleCreate */ use WHMCS\Database\Capsule; add_hook('AfterModuleCreate', 1, function ($vars) { // CHANGE THIS to your target Product ID $targetProductId = 123; $serviceId = (int) ($vars['serviceid'] ?? 0); if (!$serviceId) { return; } $service = Capsule::table('tblhosting') ->where('id', $serviceId) ->first(); if ( !$service || (int) $service->packageid !== $targetProductId || empty($service->nextduedate) ) { return; } $nextDue = new DateTime($service->nextduedate); $nextDue->modify('+1 month'); Capsule::table('tblhosting') ->where('id', $serviceId) ->update([ 'nextduedate' => $nextDue->format('Y-m-d'), ]); }); Change 123 to your specific product ID. Hi thank you for the input Im looking to achieve it on first point of purchase. Idea is when they purchase a yearly plan as normal it will stop invoice generation or modify the invoice set it to zero giving them essentially a one month trial before they commit to the yearly subscription. The first real invoices will be sent the following month for the year subscription. Maybe im over thinking it. Looking for a work around so I dont need to create trial products. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.