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. Authorize.net has provided Quickbooks export for a while but the existing Authorize.net Payment module for VirtueMart did not pass itemized order information. To meet the increasing demand for this functionality I decided to modify the exisiting payment module to pass the required information.
Using Authorize.net Advanced Intergration Method (AIM) we can pass the itemized order information by using the "x_line_item" field. The allowed information includes:
The existing Authorize.net payment module is located in:
<<site-root>>/adminstrator/components/com_virtuemart/classes/payment/ps_authorize.php
At around line 400 you can find the code:
$poststring = substr($poststring, 0, -1);
Adding the following PHP code infront of that line adds the desired functionality.
// GB Edit Begin - Add itemized list of products in order // Get the cart products $cart = $_SESSION['cart']; $cart_ids =""; for($i = 0; $i < $cart["idx"]; $i++) { // get the product IDs for a query $cart_ids.=$cart[$i]["product_id"].","; // make an easy method of getting the quantity by product ID $cart_qty[$cart[$i]["product_id"]]=$cart[$i]["quantity"]; }; // set the database query $dbit = new ps_DB; $qt= "SELECT #__{vm}_product.product_id AS p_id, #__{vm}_product.product_name AS p_name, #__{vm}_product.product_sku AS p_sku, #__{vm}_product_price.product_price AS p_price, #__{vm}_tax_rate.tax_rate AS p_tax_rate FROM #__{vm}_product LEFT OUTER JOIN #__{vm}_product_price ON (#__{vm}_product.product_id = #__{vm}_product_price.product_id) LEFT OUTER JOIN #__{vm}_tax_rate ON (#__{vm}_product.product_tax_id = #__{vm}_tax_rate.tax_rate_id) WHERE #__{vm}_product.product_id IN (".$cart_ids.") LIMIT 30"; $dbit->query($qt); // output text string $line_items= ""; $line_count=1; // iterate through results and build api text while($dbit->next_record()) { if ($dbit->f("p_tax_rate")>0) { $taxable="Y"; } else { $taxable="N"; }; $line_items .= "x_line_item=" . $line_count . '<|>' . $cart_qty[$dbit->f("p_id")] . '<|>' . ) . "&"; $line_count++; }; // append the outupt string to the main post string $poststring .= $line_items; // GB Edit End - Add itemized list of products in order // original code below // strip off trailing ampersand
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 ZenCart but it would involve extensive work. By using Authorize.net we can achive the same results with minimal effort. Hopefully this will help some folk out there.