Virtuemart, and QuickBooks

Joomla and VirtueMart provide an easy to use and feature rich combination of content management and eCommerce. A lot of my clients who use VirtueMart were asking me about Quickbooks integration so that they could easily track online purchases. has provided Quickbooks export for a while but the existing Payment module for VirtueMart did not pass itemized order information. To meet the increasing demand for this functionality I decided to modify the existing payment module to pass the required information.

Please note that Intuit is depreciating IIF and XML file import into QuickBooks in favor of using the XML Web Connector. Exporting the IFF file from and import into QuickBooks is no longer recommended. This code snippet is still useful for passing itemized order details.

Using Advanced Integration Method (AIM) we can pass the itemized order information by using the "x_line_item" field. The allowed information includes:

  • Item ID - String - 31 characters
  • Item Name - String - 31 characters
  • Item Description - String - 255 characters
  • Item Quantity - Integer - positive
  • Item Price - Decimal - 2 decimal places
  • Item Taxable - Boolean - Y or N

The existing payment module is located in:


At around line 400 you can find the code:

  1. // strip off trailing ampersand
  2. $poststring = substr($poststring, 0, -1);

Adding the following PHP code in front of that line adds the desired functionality.

  1. // GB Edit Begin - Add itemized list of products in order
  3. // Get the cart products
  4. $cart = $_SESSION['cart'];
  5. $cart_ids ="";
  7. for($i = 0; $i < $cart["idx"]; $i++) {
  8.   // get the product IDs for a query
  9.   $cart_ids.=$cart[$i]["product_id"].",";
  10.   // make an easy method of getting the quantity by product ID
  11.   $cart_qty[$cart[$i]["product_id"]]=$cart[$i]["quantity"];
  12. };
  14. if (strlen($cart_ids)>1) $cart_ids = substr($cart_ids, 0, -1);
  16. // set the database query
  17. $dbit = new ps_DB;
  18. $qt= "SELECT #__{vm}_product.product_id AS p_id,
  19.          #__{vm}_product.product_name AS p_name,
  20.          #__{vm}_product.product_sku AS p_sku,
  21.          #__{vm}_product_price.product_price AS p_price,
  22.          #__{vm}_tax_rate.tax_rate AS p_tax_rate
  23.      FROM #__{vm}_product
  24.      LEFT OUTER JOIN #__{vm}_product_price ON
  25.          (#__{vm}_product.product_id = #__{vm}_product_price.product_id)
  26.      LEFT OUTER JOIN #__{vm}_tax_rate ON
  27.          (#__{vm}_product.product_tax_id = #__{vm}_tax_rate.tax_rate_id)
  28.      WHERE #__{vm}_product.product_id IN (".$cart_ids.") LIMIT 30";
  29. $dbit->query($qt);
  31. // output text string
  32. $line_items= "";
  33. $line_count=1;
  34. // iterate through results and build api text
  35. while($dbit->next_record()) {
  36.   if ($dbit->f("p_tax_rate")>0) {
  37.     $taxable="Y";
  38.   } else {
  39.     $taxable="N";
  40.   };
  41.   $line_items .= "x_line_item=" .
  42.     urlencode(
  43.       $line_count . '<|>' .
  44.       substr($dbit->f("p_sku"), 0, 31) . '<|>' .
  45.       substr($dbit->f("p_name"), 0, 255) . '<|>' .
  46.       $cart_qty[$dbit->f("p_id")] . '<|>' .
  47.       round($dbit->f("p_price"),2) .'<|>' . $taxable
  48.     ) . "&";
  49.     $line_count++;
  50. };
  52. // append the outupt string to the main post string
  53.   $poststring .= $line_items;
  55. // GB Edit End - Add itemized list of products in order
  56. // original code below
  58. // strip off trailing ampersand
  59. $poststring = substr($poststring, 0, -1);

When I get some free time I hope to add this contribution to the VirtueMart project. As far as I can tell this it the only cost effective method of linking Joomla and Quickbooks. I looked at porting a great Quickbooks export module made for Zen Cart but it would involve extensive work. By using we can archive the same results with minimal effort. Hopefully this will help some folk out there.


Virtuemart customization

Hi thank you for the awesome tutorial!!! Great job! You seem to know a lot about VirtueMart. I am trying to stop the payment method from attempting to authorize the customer info. Any idea on what code could be removed to do that? Could you explain? I just need to be able to get the customer payment info along with recurring payments but not authorize. Thanks in advance!

Mike Miller wrote 12 years 8 weeks ago
gbrandys's picture

Option in settings

Mike, This is normally an option in the payment setting within VirtueMart. Teh default is "Authorize & Capture" which will check for funds and collect them. The other option is "Authorize" which just checks for available funds and then requires manual processing in the managment web site to collect the funds. No code changes required.

gbrandys wrote 11 years 7 weeks ago shipping charges

I wanted to know how to add shipping charges in I searched a lot but didn't got proper solution.

Please guide me. wanted to add shipping charges to form as per quantity.
Waiting for reply. Thanks

Prashant Korane wrote 12 years 24 weeks ago
gbrandys's picture

Shipping options


Shipping is independant of the payment module. There are many options to calculate shipping and all of the shipping charges will be passed to by default. You should have a look at the VirtueMart User Manual: Shipping Modules<

gbrandys wrote 11 years 7 weeks ago


Just curious, since I can't seem to find a publication date for this post, which version(s) of Joomla/VM was this designed for? Have you tested it yourself? Sounds like a great solution to a very relevant problem.

Please let me know! Though I suppose I could just try it and see what happens, but I support most of my clients remotely and could save everyone a lot of time and energy with a little info up front...


Marshall wrote 13 years 3 weeks ago
gbrandys's picture

Compatible with VirtueMart 1.0.15 and 1.1.8

I just checked the current code for both releases of VirtueMart; 1.0.15 and 1.1.8. The code change looks to be compatible with these versions. The line numbers are slightly off so you will have to find the properly place to make the changes.

I had this code change working on one client's site for over a year before I created a new site for them. The new site is much more robust because it does not use Joomla or VirtueMart and has full synchronization between the online store and QuickBooks using an XML connector.

gbrandys wrote 13 years 2 days ago

Add your comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account associated with the e-mail address you provide, it will be used to display your avatar.
 S@@E5SMS9    .d8@@Mb.    .d9H9@b.    .d9H9@b.   8S@HH595HH 
MMM d95P YE5b d89P Y@@b d89P Y@@b d58P
8@9 9S@ E85 E85 d88P
M5M@5@Hb. .d98P EE9dE@5b. EE9dE@5b. d89P
"YSEb .od@H5P" 9SMP "Y@9b 9SMP "Y@9b 5S@M@M89
SEE dMMP" 5H5 9M9 5H5 9M9 dMMP
YS8b dH@P 995" Y8@b dSEP Y8@b dSEP dHHP
"YHM85P" H985H@58M "YHMS@P" "YHMS@P" dHEP