Shay Mei Posted August 1, 2019 Share Posted August 1, 2019 Hello everyone, I'm running a campaign that gives away $20 credits for free when a new user creates an account on my website. Is there any way to auto issue credits when a new client creates an account via WHMCS? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 1, 2019 Share Posted August 1, 2019 5 hours ago, Shay Mei said: Is there any way to auto issue credits when a new client creates an account via WHMCS? not from the admin settings and off-hand, I can't think of an existing addon that can do it. ultimately, if you're not bothered about issuing an add funds invoice for the credit, you could use a ClientAdd action hook to add $20 to their account when it's being created - that means that as soon as the client logs in, they will be able to use the $20. of course, by default WHMCS doesn't usually show them their credit balance in the client area (though it will at checkout), so you might also need to use sentq's credit sidebar hook too. if you only use one currency on your site, e.g USD, then that's a simple hook; if it's a multi-currency site, then that gets a little more complicated as you've have to calculate the $20 deposit in the client's chosen currency and add that amount instead. 0 Quote Link to comment Share on other sites More sharing options...
Shay Mei Posted August 6, 2019 Author Share Posted August 6, 2019 On 8/1/2019 at 9:53 PM, brian! said: not from the admin settings and off-hand, I can't think of an existing addon that can do it. ultimately, if you're not bothered about issuing an add funds invoice for the credit, you could use a ClientAdd action hook to add $20 to their account when it's being created - that means that as soon as the client logs in, they will be able to use the $20. of course, by default WHMCS doesn't usually show them their credit balance in the client area (though it will at checkout), so you might also need to use sentq's credit sidebar hook too. if you only use one currency on your site, e.g USD, then that's a simple hook; if it's a multi-currency site, then that gets a little more complicated as you've have to calculate the $20 deposit in the client's chosen currency and add that amount instead. Thank you Brian. It's exactly what I was looking for! :D 0 Quote Link to comment Share on other sites More sharing options...
Shay Mei Posted August 6, 2019 Author Share Posted August 6, 2019 Hey Brian, ^^" I noticed that it's written in php, which I have zero experience with. Which variable should I hook? Could you give me an example of the code? 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted August 7, 2019 Share Posted August 7, 2019 Be careful creating money out from nothing. Make sure you are not going to have invoicing issues. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 7, 2019 Share Posted August 7, 2019 On 06/08/2019 at 10:09, Shay Mei said: ^^" I noticed that it's written in php, which I have zero experience with. Which variable should I hook? Could you give me an example of the code? so to "preload" a new account upon creation with a credit balance of 20 (in the client's chosen currency) is a simple hook... <?php add_hook('ClientAdd', 1, function($vars) { $client = \WHMCS\User\Client::find($vars['userid']); if ($client) { $client->credit = 20; $client->save(); } }); so if there is only one currency in your WHMCS, e.g USD, then this will give them a $20 credit balance; if you have multiple currencies, and they choose EUR as their currency, this will give them a €20 credit balance - remember that once a client has chosen a currency, they cannot change it... and if they've made an order, you shouldn't change their currency for them either. btw - another way to do this would be to use promotional codes - e.g a code that a user can only use once, only at signup and only for specific products... if you can do that, then it avoids using the above hook... either way, you're deducting $20 (or €20 etc) from their invoice. 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.