Jump to content

Help with product details when using hooks


chateaux

Recommended Posts

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
       )
)

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated