public function start_ipn($data, $config)
    {
        require_once 'assets/google-checkout/library/googlecart.php';
        require_once 'assets/google-checkout/library/googleitem.php';
        require_once 'assets/google-checkout/library/googleshipping.php';
        require_once 'assets/google-checkout/library/googletax.php';
        $merchant_id = $config['merchant_id'];
        // Your Merchant ID
        $merchant_key = $config['merchant_key'];
        // Your Merchant Key
        $server_type = $config['sandbox'];
        $currency = "USD";
        $cart = new GoogleCart($merchant_id, $merchant_key, $server_type, $currency);
        $cart->SetMerchantPrivateData(new MerchantPrivateData(array("transaction_id" => $data['transaction_id'])));
        $i = 1;
        foreach ($data["cart"]["items"] as $items) {
            ${'item_' . $i} = new GoogleItem($items['title'], "", $items['quantity'], $this->_currency_round($items["price"]));
            ${'item_' . $i}->SetMerchantItemId($items["product_id"]);
            $cart->AddItem(${'item_' . $i});
            $i++;
        }
        // Applying a discount
        if ($data['cart_discount'] != 0) {
            ${'item_' . $i} = new GoogleItem("Discount Applied", "", 1, "-" . $this->_currency_round($data['cart_discount']));
            $cart->AddItem(${'item_' . $i});
        }
        // Calculating the Tax by taking the subtotal, subtracting the discount and
        // dividing by the pre-calculated rate.
        // -- Then formatting the number by 2 decimal places
        if ($data['cart_tax'] == 0) {
            $taxrate = 0;
        } else {
            $taxrate = number_format($data['cart_subtotal'] - $data['cart_discount'] / $data['cart_tax'], 2);
        }
        $tax_rule = new GoogleDefaultTaxRule($taxrate);
        $tax_rule->SetWorldArea(true);
        $cart->AddDefaultTaxRules($tax_rule);
        $ship_1 = new GoogleFlatRateShipping("Shipping", $data['cart_shipping']);
        $cart->AddShipping($ship_1);
        // Specify <edit-cart-url>
        $cart->SetEditCartUrl($data['return']);
        // Specify "Return to xyz" link
        $cart->SetContinueShoppingUrl($data['cancel_return']);
        // Define rounding policy
        $cart->AddRoundingPolicy("CEILING", "TOTAL");
        echo '	<html>
   	        			<head>
   	        				<title>Google Checkout</title>
   	        			</head>
   	        			<body onLoad="document.forms[\'gateway_form\'].submit();">
							<form method="post" name="gateway_form" action="' . $cart->checkout_url . '">
			    				<input type="hidden" name="cart" value="' . base64_encode($cart->GetXML()) . '"/>
								<input type="hidden" name="signature" value="' . base64_encode($cart->CalcHmacSha1($cart->GetXML())) . '" />
								<p style="text-align:center;">
									Your order is being processed... will be redirected to the payment website.
								 	<br />
								 	<br />
								 	If you are not automatically redirected to Google Checkout within 5 seconds...<br /><br />
									<input type="submit" value="Click Here">
								</p>
							</form>
						</body>
					</html>';
    }
 /**
  * Add the taxation information to the google object representation of the customers cart
  *
  * @return void
  **/
 private function AddTaxInformationToCart()
 {
     if (!GetConfig('TaxConfigured')) {
         $GLOBALS['ISC_CLASS_LOG']->LogSystemDebug(array('payment', $this->GetName()), "Tax isn't configured at line: " . __LINE__);
         return;
     }
     switch (GetConfig('TaxTypeSelected')) {
         case 2:
             // Avoid divide by 0 errors
             if (GetConfig('DefaultTaxRate') == 0) {
                 $GLOBALS['ISC_CLASS_LOG']->LogSystemDebug(array('payment', $this->GetName()), "Tax isn't configured at line: " . __LINE__);
                 return;
             }
             // Flat rate taxing
             if (GetConfig('DefaultTaxRateBasedOn') == 'subtotal') {
                 $shipping_taxed = 'false';
             } else {
                 $shipping_taxed = 'true';
             }
             include_once dirname(__FILE__) . '/library/googletax.php';
             $tax_rule = new GoogleDefaultTaxRule(GetConfig('DefaultTaxRate') / 100, $shipping_taxed);
             $tax_rule->SetWorldArea(true);
             $this->cart->AddDefaultTaxRules($tax_rule);
             break;
         case 1:
             if (GetConfig('PricesIncludeTax') == 1) {
                 return;
             }
             $query = "SELECT *\n\t\t\t\t\tFROM [|PREFIX|]tax_rates\n\t\t\t\t\tWHERE taxratestatus=1";
             $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
             while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
                 // Flat rate taxing
                 if ($row['taxratebasedon'] == 'subtotal') {
                     $shipping_taxed = 'false';
                 } else {
                     $shipping_taxed = 'true';
                 }
                 include_once dirname(__FILE__) . '/library/googletax.php';
                 $tax_rule = new GoogleDefaultTaxRule($row['taxratepercent'] / 100, $shipping_taxed);
                 if ($row['taxratecountry'] == 0) {
                     $tax_rule->SetWorldArea();
                     $this->cart->AddDefaultTaxRules($tax_rule);
                     continue;
                 }
                 $country = GetCountryISO2ById($row['taxratecountry']);
                 $query = sprintf("SELECT taxratestates FROM [|PREFIX|]tax_rates WHERE taxratecountry='%d'", $GLOBALS['ISC_CLASS_DB']->Quote($row['taxratecountry']));
                 $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
                 $states = array();
                 while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
                     $state = $row['taxratestates'];
                     $stateIds = explode(",", $state);
                     foreach ($stateIds as $id) {
                         if (!empty($id)) {
                             $state = GetStateInfoById($id);
                             $states[] = $state['stateabbrv'];
                         }
                     }
                 }
                 if (empty($states)) {
                     $tax_rule->AddPostalArea($country);
                 } else {
                     $tax_rule->SetStateAreas($states);
                 }
                 $this->cart->AddDefaultTaxRules($tax_rule);
             }
     }
 }
 /**
  * Prepares the payment form
  * and returns HTML Form to be displayed to the user
  * generally will have a message saying, 'confirm entries, then click complete order'
  *
  * Submit button target for onsite payments & return URL for offsite payments should be:
  * index.php?option=com_tienda&view=checkout&task=confirmPayment&orderpayment_type=xxxxxx
  * where xxxxxxx = $_element = the plugin's filename
  *
  * @param $data     array       form post data
  * @return string   HTML to display
  */
 function _prePayment($data)
 {
     /*
      * get all necessary data and prepare vars for assigning to the template
      */
     $vars = new JObject();
     $order = JTable::getInstance('Orders', 'TiendaTable');
     $order->load($data['order_id']);
     $items = $order->getItems();
     $vars->orderpayment_id = $data['orderpayment_id'];
     $vars->orderpayment_amount = $data['orderpayment_amount'];
     $vars->orderpayment_type = $this->_element;
     $vars->merchant_id = $this->_getParam('merchant_id');
     $vars->type_id = JRequest::getInt('id');
     //$vars->post_url = JRoute::_("index.php?option=com_tienda&controller=payment&task=process&ptype={$this->_element}&paction=proceed&tmpl=component");
     $vars->button_url = $this->_getPostUrl(false);
     $vars->note = JText::_('COM_TIENDA_GOOGLECHECKOUT_NOTE_DEFAULT');
     $uri = JFactory::getURI();
     $url = $uri->toString(array('path', 'query', 'fragment'));
     $vars->r = base64_encode($url);
     // Include all the required files
     require_once dirname(__FILE__) . "/{$this->_element}/library/googlecart.php";
     require_once dirname(__FILE__) . "/{$this->_element}/library/googleitem.php";
     require_once dirname(__FILE__) . "/{$this->_element}/library/googleshipping.php";
     require_once dirname(__FILE__) . "/{$this->_element}/library/googletax.php";
     $cart = new GoogleCart($this->_getParam('merchant_id'), $this->_getParam('merchant_key'), $this->_getServerType(), $this->params->get('currency', 'USD'));
     $totalTax = 0;
     $totalPrice = 0;
     foreach ($items as $itemObject) {
         //
         $item_temp = new GoogleItem($itemObject->orderitem_name, $itemObject->orderitem_name, $itemObject->orderitem_quantity, $itemObject->orderitem_price + $itemObject->orderitem_attributes_price);
         // in argument of GoogleItem first itemname , itemDescription,quantity, unti price
         $cart->AddItem($item_temp);
         $totalPrice = $totalPrice + $itemObject->orderitem_final_price;
         $totalTax = $totalTax + $itemObject->orderitem_tax;
     }
     //check if coupons is not empty
     if (!empty($data['coupons'])) {
         $couponIds = array();
         $couponIds = $data['coupons'];
         //NOTE: checking the coupon if its valid for the user is already done in the controller
         JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models');
         $model = JModel::getInstance('Coupons', 'TiendaModel');
         $model->setState('filter_ids', $couponIds);
         $coupons = $model->getList();
         if (!empty($coupons)) {
             $totalDiscount = 0;
             foreach ($coupons as $coupon) {
                 $orderitem_name = $coupon->coupon_code . " " . JText::_('COM_TIENDA_DISCOUNT');
                 if (empty($coupon->coupon_type)) {
                     // get the value
                     switch ($coupon->coupon_value_type) {
                         case "1":
                             // percentage
                             $amount = $coupon->coupon_value / 100 * ($totalPrice + $totalTax);
                             break;
                         case "0":
                             // flat-rate
                             $amount = $coupon->coupon_value;
                             break;
                     }
                 }
                 $item_temp = new GoogleItem($orderitem_name, $orderitem_name, 1, "-" . $amount);
                 // in argument of GoogleItem first itemname , itemDescription,quantity, unti price
                 $cart->AddItem($item_temp);
                 $totalDiscount = $totalDiscount + $amount;
             }
         }
     }
     if (!empty($data['shipping_plugin']) && $order->order_shipping > 0) {
         //check if usps plugin
         if ($data['shipping_plugin'] == 'shipping_usps') {
             $data['shipping_name'] = str_replace("®", "", $data['shipping_name']);
             //convert entity character to hexadecimal character
             //$data['shipping_name'] = str_replace("®", "&#x3C;sup&#x3E;&#x26;reg;&#x3C;/sup&#x3E;", $data['shipping_name']);
         }
         // Add shipping
         $shipTemp = new GooglePickup($data['shipping_name'], $order->order_shipping + $order->order_shipping_tax);
         // shipping name and Price as an argument
         $cart->AddShipping($shipTemp);
     }
     //adjust the tax rate if discount is available
     if ($order->order_discount > 0) {
         $taxRate = $this->taxRateAdjustment($order->order_subtotal, $order->order_discount, $order->order_tax);
     } else {
         //compute the tax rate for default tax
         $totalOrder = $order->order_total - ($order->order_shipping + $order->order_shipping_tax);
         $taxRate = $this->calcDefaultTaxRate($totalOrder, $order->order_subtotal);
     }
     // Set default tax options
     $tax_rule = new GoogleDefaultTaxRule($taxRate);
     $tax_rule->SetWorldArea(true);
     $cart->AddDefaultTaxRules($tax_rule);
     //$reponseURL = JURI::root() ."plugins/tienda/{$this->_element}/library/responsehandler.php";
     // Add merchant calculations options
     //$cart->SetMerchantCalculations(
     //"{$reponseURL}", // merchant-calculations-url
     //   "true", // merchant-calculated tax
     //  "false", // accept-merchant-coupons
     //  "false"); // accept-merchant-gift-certificates
     $checkout_return_url = JURI::root() . "index.php?option=com_tienda&view=checkout&task=confirmPayment&orderpayment_type=" . $this->_element . "&paction=display_message";
     $cart->SetContinueShoppingUrl($checkout_return_url);
     // set oredr id and the Data
     $mcprivatedata = new MerchantPrivateData();
     $mcprivatedata->data = array("orderPaymentId" => $data['orderpayment_id']);
     $cart->SetMerchantPrivateData($mcprivatedata);
     $vars->cart = $cart;
     $html = $this->_getLayout('prepayment', $vars);
     return $html;
 }
function UseCase2()
{
    // Create a new shopping cart object
    $merchant_id = "";
    // Your Merchant ID
    $merchant_key = "";
    // Your Merchant Key
    $server_type = "sandbox";
    $currency = "USD";
    $cart = new GoogleCart($merchant_id, $merchant_key, $server_type, $currency);
    // Add items to the cart
    $item_1 = new GoogleItem("Dry Food Pack AA1453", "A pack of highly nutritious dried food for emergency", 2, 24.99);
    $item_1->SetTaxTableSelector("food");
    $item_2 = new GoogleItem("MegaSound 2GB MP3 Player", "Portable MP3 player - stores 500 songs", 1, 175.49);
    $item_2->SetMerchantPrivateItemData(new MerchantPrivateItemData(array("color" => "blue", "weight" => "3.2")));
    $item_2->SetMerchantItemId("Item#012345");
    $cart->AddItem($item_1);
    $cart->AddItem($item_2);
    // Add shipping options
    $ship_1 = new GoogleFlatRateShipping("Ground", 15);
    $restriction_1 = new GoogleShippingFilters();
    $restriction_1->SetAllowedWorldArea(true);
    $ship_1->AddShippingRestrictions($restriction_1);
    $ship_2 = new GooglePickup("Pick Up", 5);
    $cart->AddShipping($ship_1);
    $cart->AddShipping($ship_2);
    // Add default tax rules
    $tax_rule_1 = new GoogleDefaultTaxRule(0.17);
    $tax_rule_1->AddPostalArea("GB", "SW*");
    $tax_rule_1->AddPostalArea("FR");
    $tax_rule_1->AddPostalArea("DE");
    $tax_rule_2 = new GoogleDefaultTaxRule(0.1);
    $tax_rule_2->SetWorldArea(true);
    $cart->AddDefaultTaxRules($tax_rule_1);
    $cart->AddDefaultTaxRules($tax_rule_2);
    // Add alternate tax table
    $tax_table = new GoogleAlternateTaxTable("food");
    $tax_rule_1 = new GoogleAlternateTaxRule(0.05);
    $tax_rule_1->AddPostalArea("GB");
    $tax_rule_1->AddPostalArea("FR");
    $tax_rule_1->AddPostalArea("DE");
    $tax_rule_2 = new GoogleAlternateTaxRule(0.03);
    $tax_rule_2->SetWorldArea(true);
    $tax_table->AddAlternateTaxRules($tax_rule_1);
    $tax_table->AddAlternateTaxRules($tax_rule_2);
    $cart->AddAlternateTaxTables($tax_table);
    // Add <merchant-private-data>
    $cart->SetMerchantPrivateData(new MerchantPrivateData(array("animals" => array("type" => "cat,dog"))));
    // Specify <edit-cart-url>
    $cart->SetEditCartUrl("http://www.example.com/edit");
    // Specify "Return to xyz" link
    $cart->SetContinueShoppingUrl("http://www.example.com/continue");
    // Request buyer's phone number
    $cart->SetRequestBuyerPhone(true);
    // Define rounding policy
    $cart->AddRoundingPolicy("CEILING", "TOTAL");
    // Display XML data
    // echo "<pre>";
    // echo htmlentities($cart->GetXML());
    // echo "</pre>";
    // Display a medium size button
    echo $cart->GetXML();
}
function UseCase3()
{
    //Create a new shopping cart object
    $merchant_id = "";
    // Your Merchant ID
    $merchant_key = "";
    // Your Merchant Key
    $server_type = "sandbox";
    $currency = "USD";
    $cart = new GoogleCart($merchant_id, $merchant_key, $server_type, $currency);
    // Add items to the cart
    $item = new GoogleItem("MegaSound 2GB MP3 Player", "Portable MP3 player - stores 500 songs", 1, 175.49);
    $item->SetMerchantPrivateItemData("<color>blue</color><weight>3.2</weight>");
    $cart->AddItem($item);
    // Add merchant calculations options
    $cart->SetMerchantCalculations("http://200.69.205.154/~brovagnati/tools/unitTest/demo/responsehandlerdemo.php", "false", "true", "true");
    // accept-merchant-gift-certificates
    // Add merchant-calculated-shipping option
    $ship = new GoogleMerchantCalculatedShipping("2nd Day Air", 10.0);
    // Default, fallback price
    $restriction = new GoogleShippingFilters();
    $restriction->AddAllowedPostalArea("GB");
    $restriction->AddAllowedPostalArea("US");
    $restriction->SetAllowUsPoBox(false);
    $ship->AddShippingRestrictions($restriction);
    $address_filter = new GoogleShippingFilters();
    $address_filter->AddAllowedPostalArea("GB");
    $address_filter->AddAllowedPostalArea("US");
    $address_filter->SetAllowUsPoBox(false);
    $ship->AddAddressFilters($address_filter);
    $cart->AddShipping($ship);
    // Set default tax options
    $tax_rule = new GoogleDefaultTaxRule(0.15);
    $tax_rule->SetWorldArea(true);
    $cart->AddDefaultTaxRules($tax_rule);
    $cart->AddRoundingPolicy("UP", "TOTAL");
    // Display XML data
    // echo "<pre>";
    // echo htmlentities($cart->GetXML());
    // echo "</pre>";
    // Display a disabled, small button
    echo $cart->CheckoutButtonCode("SMALL", false);
}
        /**
         * Generate the Google Checkout button link
         **/
        public function generate_googlecheckout_form($order_id)
        {
            global $woocommerce;
            require_once GOOGLE_CHECKOUT_LIB . 'googlecart.php';
            require_once GOOGLE_CHECKOUT_LIB . 'googleitem.php';
            require_once GOOGLE_CHECKOUT_LIB . 'googleshipping.php';
            require_once GOOGLE_CHECKOUT_LIB . 'googletax.php';
            $order = new WC_Order($order_id);
            $shipping_name = explode(' ', $order->shipping_method);
            // Check if this is a test purchase
            if ($this->testmode == 'yes') {
                $server_type = "sandbox";
            } else {
                $server_type = "checkout";
            }
            $merchant_id = $this->merchant_id;
            // Your Merchant ID
            $merchant_key = $this->merchant_key;
            // Your Merchant Key
            $currency = get_option('woocommerce_currency');
            $cart = new GoogleCart($merchant_id, $merchant_key, $server_type, $currency);
            // Specify <edit-cart-url>
            $cart->SetEditCartUrl(get_permalink(get_option('woocommerce_cart_page_id')));
            // Specify "Return to xyz" link
            $cart->SetContinueShoppingUrl(add_query_arg('key', $order->order_key, add_query_arg('order', $order_id, get_permalink(get_option('woocommerce_thanks_page_id')))));
            // Order key
            $cart->SetMerchantPrivateData(new MerchantPrivateData(array("cart-id" => $order->id)));
            // Request buyer's phone number
            $cart->SetRequestBuyerPhone(true);
            // Default tax  - for shipping, if used
            if ($order->order_shipping_tax > 0) {
                // We manually calculate the shipping tax percentage here
                $calculated_shipping_tax_percentage = $order->order_shipping_tax / $order->order_shipping;
                $tax_rule_for_shipping = new GoogleDefaultTaxRule($calculated_shipping_tax_percentage, 'true');
                $tax_rule_for_shipping->SetWorldArea(true);
                $cart->AddDefaultTaxRules($tax_rule_for_shipping);
            }
            // Shipping Cost
            if ($order->order_shipping > 0) {
                $ship_1 = new GoogleFlatRateShipping($order->shipping_method, number_format($order->order_shipping, 2));
                $restriction_1 = new GoogleShippingFilters();
                $restriction_1->SetAllowedWorldArea(true);
                $ship_1->AddShippingRestrictions($restriction_1);
                $cart->AddShipping($ship_1);
            }
            // Cart Contents
            $item_loop = 0;
            $myvat = array();
            if (sizeof($order->get_items()) > 0) {
                foreach ($order->get_items() as $item) {
                    $_product = new WC_Product($item['id']);
                    if ($_product->exists() && $item['qty']) {
                        $item_loop++;
                        // Change tax format from 25.00 to 0.25
                        $item_tax_percentage = number_format($order->get_item_tax($item, false) / $order->get_item_total($item, false, false) * 100, 2, '.', '');
                        $item_vat = $item_tax_percentage / 100;
                        $myvat[$item_loop] = $item_vat;
                        ${"item_" . $item_loop} = new GoogleItem($item['name'], "", $item['qty'], $order->get_item_total($item, false, false));
                        // Name the alternate-tax-table
                        $vat_name = "vat" . $item_vat;
                        ${"item_" . $item_loop}->SetMerchantItemId($item['id']);
                        ${"item_" . $item_loop}->SetTaxTableSelector($vat_name);
                        $cart->AddItem(${"item_" . $item_loop});
                    }
                }
            }
            // Discount
            if ($order->order_discount > 0) {
                $item_loop++;
                ${"item_" . $item_loop} = new GoogleItem(__('Discount', 'woothemes'), "", "1", -$order->order_discount);
                ${"item_" . $item_loop}->SetTaxTableSelector("no_tax");
                $cart->AddItem(${"item_" . $item_loop});
            }
            // Tax
            // Loops through all tax classes that has been added to the cart and add these as Alternate tax tables to google Checkout.
            $taxrule_loop = 1;
            $no_duplicate_vat = array_unique($myvat);
            foreach ($no_duplicate_vat as $value) {
                // Name the alternate-tax-table
                $vat_name = "vat" . $value;
                $tax_table = new GoogleAlternateTaxTable($vat_name);
                ${"tax_rule_" . $taxrule_loop} = new GoogleAlternateTaxRule($value);
                ${"tax_rule_" . $taxrule_loop}->SetWorldArea(true);
                $tax_table->AddAlternateTaxRules(${"tax_rule_" . $taxrule_loop});
                $cart->AddAlternateTaxTables($tax_table);
                $taxrule_loop++;
            }
            // The form
            return $cart->CheckoutButtonCode("SMALL") . '<script type="text/javascript">
						jQuery(function(){
							jQuery("body").block(
								{ 
									message: "<img src=\\"' . $woocommerce->plugin_url() . '/assets/images/ajax-loader.gif\\" alt=\\"Redirecting...\\" />' . __('Thank you for your order. We are now redirecting you to Google Checkout to make payment.', 'woothemes') . '", 
									overlayCSS: 
									{ 
										background: "#fff", 
										opacity: 0.6 
									},
									css: { 
                                   		padding:        20, 
                                   		textAlign:      "center", 
                                   		color:          "#555", 
                                   		border:         "3px solid #aaa", 
                                   		backgroundColor:"#fff", 
                                   		cursor:         "wait",
                                   		lineHeight:        "32px"
                               		} 
								});
							jQuery("#submit_googlecheckout_payment_form").click();
						});
					</script>';
        }
Beispiel #7
0
        $rate = (double) $tax_result->fields['tax_rate'] / 100.0;
        $GDtaxRule = new GoogleDefaultTaxRule($rate, 'true');
        if ($tax_result->fields['countries_iso_code_2'] == 'US') {
            if ($tax_result->fields['zone_code'] == 'All Areas') {
                $GDtaxRule->SetCountryArea('ALL');
            } else {
                $GDtaxRule->SetStateAreas($tax_result->fields['zone_code']);
            }
        } else {
            $GDtaxRule->AddPostalArea($tax_result->fields['countries_iso_code_2']);
        }
        $Gcart->AddDefaultTaxRules($GDtaxRule);
    }
} else {
    $GDtaxRule = new GoogleDefaultTaxRule(0, 'false');
    $GDtaxRule->SetWorldArea(true);
    $Gcart->AddDefaultTaxRules($GDtaxRule);
}
if (sizeof($tax_class_unique) > 1 || sizeof($tax_class_unique) == 1 && sizeof($module_info_enabled) != sizeof($tax_class)) {
    $Gcart->SetButtonVariant(false);
    $Gwarnings[] = GOOGLECHECKOUT_STRING_WARN_MULTIPLE_SHIP_TAX;
}
$i = 0;
$tax_tables = array();
foreach ($tax_array as $tax_table) {
    $tax_result = $db->Execute("select distinct countries_name, coalesce(zone_code, 'All Areas') zone_code, tax_rate, countries_iso_code_2\n                               from " . TABLE_TAX_RATES . " as tr " . " inner join " . TABLE_ZONES_TO_GEO_ZONES . " as ztgz on tr.tax_zone_id = ztgz.geo_zone_id " . " inner join " . TABLE_COUNTRIES . " as c on ztgz.zone_country_id = c.countries_id " . " left join " . TABLE_ZONES . " as z on ztgz.zone_id=z.zone_id\n                               where tr.tax_class_id= '" . $tax_array[$i] . "'");
    $num_rows = $tax_result->RecordCount();
    $tax_rule = array();
    $GAtaxTable = new GoogleAlternateTaxTable(!empty($tax_name_array[$i]) ? $tax_name_array[$i] : 'none', 'false');
    for ($j = 0; $j < $num_rows; $j++) {
        $tax_result->MoveNext();