Mytihost Posted February 2 Share Posted February 2 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 February 4 Share Posted February 4 (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 February 4 by RadWebHosting specific product use case 0 Quote Link to comment Share on other sites More sharing options...
Mytihost Posted February 5 Author Share Posted February 5 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...
RadWebHosting Posted February 6 Share Posted February 6 So, I am to understand correctly, the client "purchases" a yearly plan, but really, you just want to give them a free month and then later invoice them for the year? 0 Quote Link to comment Share on other sites More sharing options...
Mytihost Posted February 6 Author Share Posted February 6 17 hours ago, RadWebHosting said: So, I am to understand correctly, the client "purchases" a yearly plan, but really, you just want to give them a free month and then later invoice them for the year? Hello yes thats essentially what it is for so they can have a evaluation period before committing to the full year payment. 0 Quote Link to comment Share on other sites More sharing options...
wtools Posted February 8 Share Posted February 8 (edited) Yes, That's possible with hook https://developers.whmcs.com/hooks-reference/shopping-cart/#aftershoppingcartcheckout So from this hook, we can update the due date of the service. For a yearly plan , we just add 30 + current due date and update it, So the user will get an additional 30 days. Edited February 8 by wtools 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.