Jump to content

Invoice items from database or api


jbr1

Recommended Posts

Hi,

 

I'm trying to get the items of an invoice from the database.

The information i want to get is just like on the invoice, only then with every item i also want to know the product id.

 

When is use the API function "Get Invoice" it doesn't display the items at all.

 

I'm asking this on this forum because i tried a lot of ways to get the information i want, but WHMCS doesn't seem to save this information?

 

Another way this could be solved is expanding the Hook "InvoiceCreated" so that it doesn't only gives back the invoiceid, but also the information like products and prices.

 

Thanks in advance, Jeffry

Link to comment
Share on other sites

I know, but i only get this:

 

<?xml version="1.0" encoding="utf-8"?>
<whmcsapi version="4.3.1">
<action>getinvoice</action>
<result>success</result>
<invoiceid></invoiceid>
<invoicenum></invoicenum>
<userid>3</userid>
<date>2010-09-29</date>
<duedate>2010-10-14</duedate>
<datepaid>0000-00-00 00:00:00</datepaid>
<subtotal>26.61</subtotal>

<credit>0.00</credit>
<tax>0.00</tax>
<tax2>0.00</tax2>
<total>26.61</total>
<balance>26.61</balance>
<taxrate>0.00</taxrate>
<taxrate2>0.00</taxrate2>
<status>Unpaid</status>
<paymentmethod>banktransfer</paymentmethod>

<notes><![CDATA[]]></notes>
</whmcsapi>

 

And i use this code:

$url = "http://www.myurl.com/includes/api.php"; # URL to WHMCS API file

$postfields["username"] = "<username>"; 
$postfields["password"] = md5(<pass>);

$postfields["action"] = "getinvoice";
$postfields["invoiceid"] = $_GET["Id"]; // for testing so i only have to put ?Id=<id> behind my URL, doesn't change anything to how it works


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
$data = curl_exec($ch);
curl_close($ch);

echo $data;

Link to comment
Share on other sites

Ok, thanks for checking, i will open a ticket.

 

Yes I preferably make the connection with MYSQL.

But to me the database tables of an invoice are not structured in a way you can get the product id's.

Normally i know my way in databases, i've been working with them for quite some time now.

 

But maybe i am overlooking something or there are smarter people here (there have to be), that is why i asked the question here.

 

 

Jeffry

Link to comment
Share on other sites

I see what you mean. You'll probably have to match the description field in tblinvoiceitems against the stuff in tblproducts.. But even then you arent going to get all the config options correctly unless you do some post processing with regular expression matching.

 

Its doable, just a pain in the butt.

Link to comment
Share on other sites

Yeah, thats the only way i can think of. It's not the prettiest way.

E.g. someone changes the name of an product before the information of the invoice is synchronized and it doesn't properly work... Thats just a thing I have to deal with i gues.

Link to comment
Share on other sites

I can understand why they do it this way, as there are an infinite number of possible packages when you start adding in configurable options. I supposed if those were separate line items it would make it easier..

 

There doesn't seem to be any easy or nice way of doing this.

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