steven-one Posted December 11, 2011 Share Posted December 11, 2011 Hello, I'm want to make an action hook when an invoice is created. The only variable I can use is invoiceid. How do I get also the client details and invoice details in that action hook? Do I need to use the API or is there a better way of getting those variables? Thanks! 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted December 11, 2011 Share Posted December 11, 2011 You can use SQL queries and/or the API to pull the data you need. For example, if you want to get the clients first name, last name, and email address, you would use something like this. <?php function do_something_cool($vars) { $invoiceid = $vars['invoiceid']; $_query = "SELECT c.firstname, c.lastname, c.email FROM tblclients c, tblinvoices i WHERE i.userid = c.id AND i.id='$invoiceid'"; $data = full_query($_query); $result = mysql_fetch_array($data); $firstname = $result[0]; $lastname = $result[1]; $email = $result[2]; } add_hook("InvoiceCreated", 1, "do_something_cool"); ?> 0 Quote Link to comment Share on other sites More sharing options...
steven-one Posted December 12, 2011 Author Share Posted December 12, 2011 Thank you. The API didn't work for me but the SQL did. But now I'm facing another problem. I can't include an api class. I get a blank page. 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted December 12, 2011 Share Posted December 12, 2011 Thank you. The API didn't work for me but the SQL did. But now I'm facing another problem. I can't include an api class. I get a blank page. Some code examples of what you're doing would be helpful. You have to be careful with actionhooks. If theres an error in them some things in WHMCS will not function properly. 0 Quote Link to comment Share on other sites More sharing options...
steven-one Posted December 12, 2011 Author Share Posted December 12, 2011 include("../class.mollie.php"); logActivity("test1"); $sms = new mollie(); logActivity("test2"); In the activity log I get only test1. Not test2. Same problem if I use require() and put logActivity() in front of it. So my conclusion is that the action hook does work, but there goes something wrong with the include/require. If I use require().. the problem starts there. If I use include() the problem start when I want to use the class. :roll:So it has to be the class. I put the class in the includes directory. 0 Quote Link to comment Share on other sites More sharing options...
steven-one Posted December 12, 2011 Author Share Posted December 12, 2011 I found it. Source should be includes/class.php you need the full path, not the related path to the file 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted December 12, 2011 Share Posted December 12, 2011 yeah, relative paths are a pain in the butt, never use them if it can be avoided. 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.