poppabear Posted February 22, 2009 Share Posted February 22, 2009 (edited) Ok, so where do i start ? Lets see, i am trying to run some code after an invoice is marked "PAID" ... Using the actionhook_InvoicePaid($vars) function in actionhooks.php First a little information: 1. I have a few products that require custom automation. 2. I use Directadmin as my control panel 3. WHMCS Version: 3.8.1 Basically i want to be able to grab the product description of the current invoice and be able to use that to determine which code to process. If you know anything about php you will understand exactly what i am trying to do with the code provided below: function actionhook_InvoicePaid($vars) { # This function runs when an invoice is fully paid and therefore the services renewed include('includes/httpsocket.php'); // SET INVOICE ID # $invid = $vars["InvoiceID"]; // GET CLIENTID $qclientid = mysql_query("SELECT userid FROM tblinvoices WHERE id = $invid"); $rclientid = mysql_fetch_row($qclientid); $clientid = $rclientid[0]; // GET PRODUCT DESCRIPTION $qproduct = mysql_query("SELECT description FROM tblinvoiceitems WHERE invoiceid = $invid"); $rproduct = mysql_fetch_row($qproduct); $product = $rproduct[0]; echo $product; #### START AUTOMATION FOR EMAIL HOSTING #### // CHECKS FOR EMAIL PRODUCT if(strpos($product, "Email 1") === true) { $uname = mysql_query("SELECT value FROM tblcustomfieldsvalues WHERE fieldid = 1 and relid = $clientid"); $pass = mysql_query("SELECT value FROM tblcustomfieldsvalues WHERE fieldid = 4 and relid = $clientid"); $user = mysql_fetch_row($uname); $passwd = mysql_fetch_row($pass); $domain = "email.DOMAIN.com"; $quota = "10000"; $sock = new HTTPSocket; $sock->connect('IPADDRESS',2222); $sock->set_login("USERNAME","PASSWORD"); $sock->set_method('POST'); $sock->query('/CMD_API_POP', array( 'action' => 'create', 'domain' => $domain, 'user' => $user[0], 'passwd' => $passwd[0], 'quota' => $quota )); header('Location: cart.php?a=complete'); } #### END AUTOMATION FOR EMAIL HOSTING #### #### START AUTOMATION FOR MYSQL HOSTING #### // CHECKS FOR PRODUCT if(strpos($product, "MySql 1") === true) { $qdname = mysql_query("SELECT value FROM tblcustomfieldsvalues WHERE fieldid = 5 and relid = $clientid"); $qduser = mysql_query("SELECT value FROM tblcustomfieldsvalues WHERE fieldid = 6 and relid = $clientid"); $qdpass = mysql_query("SELECT value FROM tblcustomfieldsvalues WHERE fieldid = 7 and relid = $clientid"); $dname = mysql_fetch_row($qdname); $duser = mysql_fetch_row($qduser); $dpass =mysql_fetch_row($qdpass); $sock = new HTTPSocket; $sock->connect('IPADDRESS',2222); $sock->set_login("USERNAME","PASSWORD"); $sock->set_method('POST'); $sock->query('/CMD_API_DATABASES', array( 'action' => 'create', 'name' => $dname[0], 'user' => $duser[0], 'passwd' => $dpass[0], 'passwd2' => $dpass[0] )); header('Location: cart.php?a=complete'); } #### END AUTOMATION FOR MYSQL HOSTING #### #### START AUTOMATION FOR VIP MEMBERS #### if(strpos($product, "VIP") === true) { $qstatus = mysql_query("SELECT status FROM tblclients WHERE id = $clientid"); $rstatus = mysql_fetch_row($qstatus); $status = $rstatus[0]; if($status == "Active") { mysql_query("UPDATE tblcustomfieldsvalues SET value = 'true' WHERE fieldid = 8 and relid = $clientid"); } } #### END AUTOMATION FOR VIP MEMBERS #### } Note: I edited private information from the code ... its not needed for this post. I have tested the Email 1 & MySql 1 code through the actionhook_ShoppingCartCheckout($vars) function so the automatation part works fine ... i think is how my $products are being read through the if statements or something .. i am not to sure. Also, While testing this i am useing a coupon code for 100% off the product/services for testing purposes. This marks the invoice "PAID" .. which i assume would fire the action hook (i could be wrong). Conclusion: Am i pulling my product information wrong ? Am i testing this the wrong way? Do you see something in my code that is broken ? I am getting nothing ... no errors, no echo's, no updates in the Database, Directadmin API is not running its portion of the code. It seems if the code is not even being executed at all ... BTW: error_reporting(E_ALL); AND: a simple echo $product; never shows up anywhere on the screen during the entire ordering process. I hope i provided enough information for someone to assist me in this .. i have a lot to contribute to this community as i am developing some nice modules/add-ons/integration/customizations to WHMCS. Thanks in advance Edited February 22, 2009 by poppabear 0 Quote Link to comment Share on other sites More sharing options...
poppabear Posted February 23, 2009 Author Share Posted February 23, 2009 I have fixed my problem ... i used ereg() instead of strpos() That was the only thing wrong, everything appears to be working great now. Thanks to those that atleast *thought* about replying 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.