akust0m Posted September 27, 2023 Share Posted September 27, 2023 Hello! Is there a way via a script/API to perform the 'Recalculate' function on all active domains in WHMCS? The reason I want to do this is that we have some TLD's that we need to adjust pricing for. I understand there is the Bulk Pricing Updater tool but I don't think this will be suitable. The reason for this is that some of our clients have promo codes associated with their domains and we'd need to recalculate their new recurring amount based on the current TLD pricing in '/admin/configdomains.php'. Also, if you have a lot of TLD's on various registration lengths and on different prices, the Bulk Pricing Updater tool doesn't make things easy. I found this: https://marketplace.whmcs.com/product/4017-auto-recalculate-prices Does anyone know if this tool does what I'm asking? I'm surprised WHMCS hasn't got native functionality for this yet! 😕 Thanks in advance! 0 Quote Link to comment Share on other sites More sharing options...
lkitching Posted September 27, 2023 Share Posted September 27, 2023 You can use the API to build a script to do this, cycling through each domain and auto-recalculating the price. https://developers.whmcs.com/api-reference/updateclientdomain/ 0 Quote Link to comment Share on other sites More sharing options...
SimpleSonic Posted September 27, 2023 Share Posted September 27, 2023 Here is a daily cron hook to recalculate domain pricing: Â <?php /* * Hook to automatically recalculate pricing for domains after daily cron is ran */ if (!defined("WHMCS")) die("This file cannot be accessed directly"); use WHMCS\Database\Capsule; add_hook('DailyCronJob', 1, function($vars) { logActivity('Starting autorecalculate for domains ', 0); $adminUsername = ''; // Optional for WHMCS 7.2 and later foreach (Capsule::table('tbldomains')->pluck('id') as $v) { localAPI('UpdateClientDomain', array('domainid' => $v, 'autorecalc' => true), $adminUsername); } logActivity('Ending autorecalculate for domains ', 0); }); Â 0 Quote Link to comment Share on other sites More sharing options...
akust0m Posted September 27, 2023 Author Share Posted September 27, 2023 Thank you so much @ResellerWiz! What would be the best way to run this on-demand as a once-off? 0 Quote Link to comment Share on other sites More sharing options...
akust0m Posted September 28, 2023 Author Share Posted September 28, 2023 Also, is there a way to select only domains/ID's with the status 'Active'? 0 Quote Link to comment Share on other sites More sharing options...
SimpleSonic Posted September 28, 2023 Share Posted September 28, 2023 55 minutes ago, akust0m said: Also, is there a way to select only domains/ID's with the status 'Active'? You’re welcome to modify it to fit your needs. 0 Quote Link to comment Share on other sites More sharing options...
akust0m Posted September 28, 2023 Author Share Posted September 28, 2023 Thank you so much, I really appreciate it! 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.