chateaux Posted January 25, 2013 Share Posted January 25, 2013 Hello, I am writing a hook to update an external AP which is called on the ShoppingCartCheckoutCompletePage, the following $vars relate to the product purchased are made available to me via the $vars variable: [orderid] => 33 [ordernumber] => 4527979924 [invoiceid] => 33 I need to find specific details relating to the product purchased so I can update my external app accordingly and am sure their is a simple way to do this. I just cant find the information in the documentation. Can anyone advise? Many thanks! Array ( [carttpl] => verticalsteps [currency] => Array ( [id] => 1 [c ode] => USD [prefix] => $ [suffix] => USD [format] => 1 [rate] => 1.00000 ) [ipaddress] => 55.555.55.55 [ajax] => [numitemsincart] => 0 [orderid] => 33 [ordernumber] => 4527979924 [invoiceid] => 33 [ispaid] => 1 [amount] => 0.01 [paymentmethod] => paypal [clientdetails] => Array ( [userid] => 5 [id] => 5 [firstname] => Firstname [lastname] => Lastname [companyname] => [email] => myemail@myisp.com [address1] => my address [address2] => [city] => my city [state] => my state [postcode] => 0070 [countrycode] => ZZ [country] => ZZ [countryname] => Country Name [phonecc] => 00 [phonenumber] => 000000000 [notes] => [password] => 13e535b50a1ced7a629d386ee6291678:l%G)o [currency] => 1 [defaultgateway] => [cctype] => [cclastfour] => [securityqid] => 0 [securityqans] => [groupid] => 0 [status] => Active [credit] => 0.00 [taxexempt] => [latefeeoveride] => [overideduenotices] => [separateinvoices] => [disableautocc] => [language] => [lastlogin] => Date: 24/01/2013 10:48<br>IP Address: 55.555.555.555<br>Host: hostname [billingcid] => 0 ) ) 0 Quote Link to comment Share on other sites More sharing options...
chateaux Posted January 25, 2013 Author Share Posted January 25, 2013 Reviewing the API functionality I see I can use: http://docs.whmcs.com/API:Get_Products However the only commands available to me via the internal API are: $command = "getproducts"; $adminuser = "admin"; $values["gid"] = 5; //OR PID, GID, MODULE $results = localAPI($command,$values,$adminuser); None of which has been made available on the checkout complete page via the $vars... 0 Quote Link to comment Share on other sites More sharing options...
chateaux Posted January 25, 2013 Author Share Posted January 25, 2013 It would seem the other option would be to use: http://docs.whmcs.com/API:Get_Orders Using any of these: [orderid] => 33 [ordernumber] => 4527979924 [invoiceid] => 33 $command = "getorders"; $adminuser = "admin"; $values["id"] = $vars['orderid']; $results = localAPI($command,$values,$adminuser); I get an empty array as a result... Anyone know what to do? I just need to know what the client has ordered... should be simple, just cant work it out. 0 Quote Link to comment Share on other sites More sharing options...
chateaux Posted January 25, 2013 Author Share Posted January 25, 2013 Ahh ok - that would explain why I cant find an API function to grab the product details. One more question, is there a way to pass a variable to WHMCS when a client places an order? I need this to divert the customer back to the app... or should I just add a variable to the users session? 0 Quote Link to comment Share on other sites More sharing options...
WHMCS JamesX Posted January 25, 2013 Share Posted January 25, 2013 (edited) Considering the hook point which you've referenced, you may want to have a look at $smarty as well. However, whatever information isn't available as a variable needs to be obtained from the database. Edited January 25, 2013 by WHMCS JamesX 0 Quote Link to comment Share on other sites More sharing options...
chateaux Posted January 25, 2013 Author Share Posted January 25, 2013 Opting to simply pull the information our of the database... but am stumped as to how to link back to products, this is what I have to work with: Invoice ID Order Number Order ID The object is to get the ID's from the order placed and find out which products where purchased and so I am looking at the following tables: 1. tbproducts - this is where my products that I created live and my ultimate destination 2. tblorders - I have the orderID for this table and OrderNum for this table, however there are no references to the tblproducts database 3. tblinvoices - I have the InvoiceID, however their are no further references to any other table 4. tblinvoiceitems - I have the InvoiceID for this table AND the product description here BUT no ID. I could match the product description in this table to the product description in tblproducts, however this is something I am not prepared to accept as a solution... I do note a 'relid' however I am unsure what table this relates to? Ahh, okay I have worked it out... in table tblinvoiceitems, the products I have created are listed as type: "hosting", so when I look in the tbl hosting table, I find the products that have been purchased. I guess the naming convention is due to the WHMCS having stemmed from a hosting background. So this is my process, hope it helps others: Create hook for: ShoppingCartCheckoutCompletePage 1. The ID from the $vars I require is: OrderID 2. Use OrderID in table tblhosting to grab the information I need Voila, Thanks! 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.