hmaddy Posted January 30, 2023 Share Posted January 30, 2023 add_hook('OrderPaid', 1, function($vars) { 1. Above hook will work only on order time or it will execute in order time and renewal also. 2. on this hook how can i get or collect customer name, and email id to a variable. 0 Quote Link to comment Share on other sites More sharing options...
DennisHermannsen Posted January 30, 2023 Share Posted January 30, 2023 You'd need to query the database for that information. It can be done like this: <?php use WHMCS\User\Client; add_hook('OrderPaid', 1, function($vars) { $client = Client::find($vars['userId']); // First name: $client->firstname // Last name: $client->lastname }); You can find more information about working with models in WHMCS here: https://docs.whmcs.com/Using_Models If you're familiar with models in Laravel, you can basically use the same features as Laravel offers. 0 Quote Link to comment Share on other sites More sharing options...
hmaddy Posted January 30, 2023 Author Share Posted January 30, 2023 <?php use WHMCS\User\Client; add_hook('OrderPaid', 1, function($vars) { // Perform hook code here... $client = Client::find($vars['userId']); $fname = client->firstname; $email = client->email; $orderid = $vars['orderid']; $userid = $vars['userid']; $invoiceid = $vars['invoiceid']; ?> Now how can i check it whether the data is available or not. 0 Quote Link to comment Share on other sites More sharing options...
DennisHermannsen Posted January 31, 2023 Share Posted January 31, 2023 9 minutes ago, hmaddy said: Now how can i check it whether the data is available or not. What do you mean? 0 Quote Link to comment Share on other sites More sharing options...
hmaddy Posted January 31, 2023 Author Share Posted January 31, 2023 <?php use WHMCS\User\Client; add_hook('OrderPaid', 1, function($vars) { // Perform hook code here... $client = Client::find($vars['userId']); $fname = client->firstname; $email = client->email; $orderid = $vars['orderid']; $userid = $vars['userid']; $invoiceid = $vars['invoiceid']; ?> This is also not working. 0 Quote Link to comment Share on other sites More sharing options...
DennisHermannsen Posted January 31, 2023 Share Posted January 31, 2023 Well, you're not doing anything with the code. You're just setting a bunch of variables that aren't used anywhere. 0 Quote Link to comment Share on other sites More sharing options...
hmaddy Posted January 31, 2023 Author Share Posted January 31, 2023 i tried to echo the variables to a file. its not creating. like echo $invoiceid >> /home/mail/public_html/log.txt 0 Quote Link to comment Share on other sites More sharing options...
DennisHermannsen Posted January 31, 2023 Share Posted January 31, 2023 You're trying to use a bash command in PHP. That won't work. Use this instead: https://www.php.net/manual/en/function.file-put-contents.php 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.