Beispiel #1
0
 function _getShippingMethods(&$rate, &$order, &$warehouse, $null)
 {
     $data = array();
     $data['destCity'] = $null->shipping_address->address_city;
     $data['destState'] = $null->shipping_address->address_state;
     $data['destZip'] = $null->shipping_address->address_post_code;
     $data['destCountry'] = $null->shipping_address->address_country->zone_code_2;
     $data['units'] = $warehouse->units;
     $data['zip'] = $warehouse->zip;
     $totalPrice = 0;
     if (!$rate->shipping_params->group_package || $rate->shipping_params->group_package == 0) {
         $data['weight'] = 0;
         $data['height'] = 0;
         $data['length'] = 0;
         $data['width'] = 0;
         $data['price'] = 0;
         $data['quantity'] = 0;
         $data['name'] = '';
         foreach ($order->products as $product) {
             if ($product->product_parent_id == 0) {
                 if (isset($product->variants)) {
                     foreach ($product->variants as $variant) {
                         $data['units'] = 'kg';
                         $caracs = parent::_convertCharacteristics($variant, $data);
                         $data['weight'] = round($caracs['weight'], 2) * $variant->cart_product_quantity;
                         $data['height'] = round($caracs['height'], 2) * $variant->cart_product_quantity;
                         $data['length'] = round($caracs['length'], 2) * $variant->cart_product_quantity;
                         $data['width'] = round($caracs['width'], 2) * $variant->cart_product_quantity;
                         $data['price'] = $variant->prices[0]->unit_price->price_value_with_tax * $variant->cart_product_quantity;
                         $data['name'] = $variant->main_product_name . ' :' . $variant->characteristics_text;
                         $data['quantity'] = $variant->cart_product_quantity;
                         $data['XMLpackage'][] = $this->_createPackage($data, $product, $rate, $order);
                     }
                 } else {
                     $data['units'] = 'kg';
                     $caracs = parent::_convertCharacteristics($product, $data);
                     $data['weight'] = round($caracs['weight'], 2) * $product->cart_product_quantity;
                     $data['height'] = round($caracs['height'], 2) * $product->cart_product_quantity;
                     $data['length'] = round($caracs['length'], 2) * $product->cart_product_quantity;
                     $data['width'] = round($caracs['width'], 2) * $product->cart_product_quantity;
                     $data['price'] = $product->prices[0]->price_value_with_tax * $product->cart_product_quantity;
                     $data['name'] = $product->product_name;
                     $data['quantity'] = $product->cart_product_quantity;
                     $data['XMLpackage'][] = $this->_createPackage($data, $product, $rate, $order);
                 }
             }
         }
         $usableMethods = $this->_RequestMethods($data, $data['XMLpackage']);
         return $usableMethods;
     } else {
         $data['weight'] = 0;
         $data['height'] = 0;
         $data['length'] = 0;
         $data['width'] = 0;
         $data['price'] = 0;
         $data['quantity'] = 1;
         $data['name'] = 'grouped package';
         $this->package_added = 0;
         $this->nbpackage = 0;
         $limitation = array('length' => 50, 'weight' => 10, 'width' => 50, 'height' => 50);
         if (!empty($rate->shipping_params->dim_approximation_l)) {
             $l_length = $rate->shipping_params->dim_approximation_l;
             $l_weight = $rate->shipping_params->dim_approximation_kg;
             $l_height = $rate->shipping_params->dim_approximation_h;
             $l_width = $rate->shipping_params->dim_approximation_w;
         }
         if ($l_length > 0 && $limitation['length'] > $l_length) {
             $limitation['length'] = $l_length;
         }
         if ($l_weight > 0 && $limitation['weight'] > $l_weight) {
             $limitation['weight'] = $l_weight;
         }
         if ($l_height > 0 && $limitation['height'] > $l_height) {
             $limitation['height'] = $l_height;
         }
         if ($l_width > 0 && $limitation['width'] > $l_width) {
             $limitation['width'] = $l_width;
         }
     }
     foreach ($order->products as $product) {
         if ($product->product_parent_id != 0) {
             continue;
         }
         if (isset($product->variants)) {
             foreach ($product->variants as $variant) {
                 for ($i = 0; $i < $variant->cart_product_quantity; $i++) {
                     $data['units'] = 'kg';
                     $caracs = parent::_convertCharacteristics($variant, $data);
                     $current_package = parent::groupPackages($data, $caracs);
                     if ($data['weight'] + round($caracs['weight'], 2) > $limitation['weight'] || $current_package['tmpWidth'] > $limitation['length'] || $current_package['tmpHeight'] > $limitation['height'] || $current_package['tmpLength'] > $limitation['width']) {
                         if ($this->package_added == 0) {
                             $this->nbpackage++;
                         }
                         $data['XMLpackage'] .= $this->_createPackage($data, $product, $rate, $order);
                         $data['weight'] = round($caracs['weight'], 2);
                         $data['height'] = $current_package['y'];
                         $data['length'] = $current_package['z'];
                         $data['width'] = $current_package['x'];
                         $data['price'] = $variant->prices[0]->unit_price->price_value_with_tax;
                     } else {
                         $data['weight'] += round($caracs['weight'], 2);
                         $data['height'] = max($data['height'], $current_package['y']);
                         $data['length'] = max($data['length'], $current_package['z']);
                         $data['width'] += $current_package['x'];
                         $data['price'] += $variant->prices[0]->unit_price->price_value_with_tax;
                     }
                 }
             }
         } else {
             for ($i = 0; $i < $product->cart_product_quantity; $i++) {
                 $data['units'] = 'kg';
                 $caracs = parent::_convertCharacteristics($product, $data);
                 $current_package = parent::groupPackages($data, $caracs);
                 if ($data['weight'] + round($caracs['weight'], 2) > $limitation['weight'] || $current_package['tmpWidth'] > $limitation['length'] || $current_package['tmpHeight'] > $limitation['height'] || $current_package['tmpLength'] > $limitation['width']) {
                     if ($this->package_added == 0) {
                         $this->nbpackage++;
                     }
                     $data['XMLpackage'] .= $this->_createPackage($data, $product, $rate, $order);
                     $data['weight'] = round($caracs['weight'], 2);
                     $data['height'] = $current_package['y'];
                     $data['length'] = $current_package['z'];
                     $data['width'] = $current_package['x'];
                     $data['price'] = $product->prices[0]->price_value_with_tax;
                 } else {
                     $data['weight'] += round($caracs['weight'], 2);
                     $data['height'] = max($data['height'], $current_package['y']);
                     $data['length'] = max($data['length'], $current_package['z']);
                     $data['width'] += $current_package['x'];
                     $data['price'] += $product->prices[0]->price_value_with_tax;
                 }
             }
         }
     }
     if ($data['weight'] + $data['height'] + $data['length'] + $data['width'] > 0 && $this->package_added == 0) {
         $this->package_added = 1;
         $this->nbpackage++;
         $data['XMLpackage'][] = $this->_createPackage($data, $product, $rate, $order);
     }
     $usableMethods = $this->_RequestMethods($data, $data['XMLpackage']);
     return $usableMethods;
 }
Beispiel #2
0
 function _getRates(&$rate, &$order, $heavyProduct, $null)
 {
     $db = JFactory::getDBO();
     $total_price = 0;
     foreach ($order->products as $k => $v) {
         foreach ($v->prices as $price) {
             $total_price = $total_price + $price->price_value;
         }
     }
     $data['fedex_account_number'] = @$rate->shipping_params->account_number;
     $data['fedex_meter_number'] = @$rate->shipping_params->meter_id;
     $data['fedex_api_key'] = @$rate->shipping_params->api_key;
     $data['fedex_api_password'] = @$rate->shipping_params->api_password;
     $data['show_eta'] = @$rate->shipping_params->show_eta;
     $data['show_eta_format'] = @$rate->shipping_params->show_eta_format;
     $data['packaging_type'] = @$rate->shipping_params->packaging_type;
     $data['include_price'] = @$rate->shipping_params->include_price;
     $data['currency_code'] = $this->shipping_currency_code;
     $data['weight_approximation'] = @$rate->shipping_params->weight_approximation;
     $data['use_dimensions'] = @$rate->shipping_params->use_dimensions;
     $data['dim_approximation_l'] = @$rate->shipping_params->dim_approximation_l;
     $data['dim_approximation_w'] = @$rate->shipping_params->dim_approximation_w;
     $data['dim_approximation_h'] = @$rate->shipping_params->dim_approximation_h;
     $data['methods'] = @$rate->shipping_params->methods;
     $data['destZip'] = @$null->shipping_address->address_post_code;
     $data['destCountry'] = @$null->shipping_address->address_country->zone_code_2;
     $data['zip'] = @$rate->shipping_params->origination_postcode;
     $data['total_insured'] = @$total_price;
     $data['sender_company'] = @$rate->shipping_params->sender_company;
     $data['sender_phone'] = @$rate->shipping_params->sender_phone;
     $data['sender_address'] = @$rate->shipping_params->sender_address;
     $data['sender_city'] = @$rate->shipping_params->sender_city;
     $state_zone = '';
     $state_zone = @$rate->shipping_params->sender_state;
     $query = "SELECT zone_id, zone_code_2, zone_code_3 FROM " . hikashop_table('zone') . " WHERE zone_namekey IN (" . $db->Quote($state_zone) . ")";
     $db->setQuery($query);
     $state = $db->loadObject();
     $data['sender_state'] = '';
     if (isset($state->zone_code_2) && strlen($state->zone_code_2) == 2) {
         $data['sender_state'] = $state->zone_code_2;
     } elseif (strlen($state->zone_code_3) == 2) {
         $data['sender_state'] = $state->zone_code_3;
     }
     $data['sender_postcode'] = $rate->shipping_params->sender_postcode;
     $data['recipient'] = $null->shipping_address;
     $czone_code = '';
     $czone_code = @$rate->shipping_params->sender_country;
     $query = "SELECT zone_id, zone_code_2 FROM " . hikashop_table('zone') . " WHERE zone_namekey IN (" . $db->Quote($czone_code) . ")";
     $db->setQuery($query);
     $czone = $db->loadObject();
     $data['country'] = $czone->zone_code_2;
     $data['XMLpackage'] = '';
     $data['pickup_type'] = @$rate->shipping_params->pickup_type;
     $this->nbpackage = 0;
     if (!$rate->shipping_params->group_package || $rate->shipping_params->group_package == 0) {
         $data['weight'] = 0;
         $data['height'] = 0;
         $data['length'] = 0;
         $data['width'] = 0;
         $data['price'] = 0;
         foreach ($order->products as $product) {
             if ($product->product_parent_id == 0) {
                 if (isset($product->variants)) {
                     foreach ($product->variants as $variant) {
                         $caracs = parent::_convertCharacteristics($variant, $data);
                         $data['weight_unit'] = $caracs['weight_unit'];
                         $data['dimension_unit'] = $caracs['dimension_unit'];
                         $data['weight'] += round($caracs['weight'], 2) * $variant->cart_product_quantity;
                         if ($caracs['height'] != '' && $caracs['height'] != '0.00' && $caracs['height'] != 0) {
                             $data['height'] += round($caracs['height'], 2) * $variant->cart_product_quantity;
                             $data['length'] += round($caracs['length'], 2) * $variant->cart_product_quantity;
                             $data['width'] += round($caracs['width'], 2) * $variant->cart_product_quantity;
                         }
                         $data['price'] += $variant->prices[0]->price_value_with_tax * $variant->cart_product_quantity;
                     }
                 } else {
                     $caracs = parent::_convertCharacteristics($product, $data);
                     $data['weight_unit'] = $caracs['weight_unit'];
                     $data['dimension_unit'] = $caracs['dimension_unit'];
                     $data['weight'] += round($caracs['weight'], 2) * $product->cart_product_quantity;
                     if ($caracs['height'] != '' && $caracs['height'] != '0.00' && $caracs['height'] != 0) {
                         $data['height'] += round($caracs['height'], 2) * $product->cart_product_quantity;
                         $data['length'] += round($caracs['length'], 2) * $product->cart_product_quantity;
                         $data['width'] += round($caracs['width'], 2) * $product->cart_product_quantity;
                     }
                     $data['price'] += $product->prices[0]->price_value_with_tax * $product->cart_product_quantity;
                 }
             }
         }
         if ($this->freight == true && $this->classicMethod == false || $heavyProduct == true && $this->freight == true) {
             $data['XMLpackage'] .= $this->_createPackage($data, $product, $rate, $order);
         } else {
             $data['XMLpackage'] .= $this->_createPackage($data, $product, $rate, $order, true);
         }
         $usableMethods = $this->_FEDEXrequestMethods($data, $rate);
         return $usableMethods;
     } else {
         $data['weight'] = 0;
         $data['height'] = 0;
         $data['length'] = 0;
         $data['width'] = 0;
         $data['price'] = 0;
         $current_package = array();
         $limitation = array('length' => 150, 'weight' => 119, 'dimension' => 300);
         if (!empty($rate->shipping_params->methods)) {
             foreach ($rate->shipping_params->methods as $k => $v) {
                 $l_lenght = 0;
                 $l_weight = 0;
                 $l_dimension = 0;
                 switch ($v) {
                     case 'FEDEX_GROUND':
                         $l_length = 150;
                         $l_weight = 108;
                         $l_dimension = 165;
                         break;
                     case 'FEDEX_EXPRESS_SAVER':
                         $l_length = 150;
                         $l_weight = 119;
                         $l_dimension = 130;
                         break;
                 }
                 if ($l_length > 0 && $limitation['length'] > $l_length) {
                     $limitation['length'] = $l_length;
                 }
                 if ($l_weight > 0 && $limitation['weight'] > $l_weight) {
                     $limitation['weight'] = $l_weight;
                 }
                 if ($l_dimension > 0 && $limitation['dimension'] > $l_dimension) {
                     $limitation['dimension'] = $l_dimension;
                 }
             }
         }
         foreach ($order->products as $product) {
             if ($product->product_parent_id == 0) {
                 if (isset($product->variants)) {
                     foreach ($product->variants as $variant) {
                         for ($i = 0; $i < $variant->cart_product_quantity; $i++) {
                             $caracs = parent::_convertCharacteristics($variant, $data);
                             $current_package = parent::groupPackages($data, $caracs);
                             if ($data['weight'] + round($caracs['weight'], 2) > $limitation['weight'] || $current_package['dim'] > $limitation['dimension'] || $data['width'] > $limitation['length']) {
                                 $data['XMLpackage'] .= $this->_createPackage($data, $product, $rate, $order, true);
                                 $data['weight'] = round($caracs['weight'], 2);
                                 $data['height'] = $current_package['y'];
                                 $data['length'] = $current_package['z'];
                                 $data['width'] = $current_package['x'];
                                 $data['price'] = $variant->prices[0]->price_value_with_tax;
                             } else {
                                 $data['weight'] += round($caracs['weight'], 2);
                                 $data['height'] = max($data['height'], $current_package['y']);
                                 $data['length'] = max($data['length'], $current_package['z']);
                                 $data['width'] += $current_package['x'];
                                 $data['price'] += $variant->prices[0]->price_value_with_tax;
                             }
                         }
                     }
                 } else {
                     for ($i = 0; $i < $product->cart_product_quantity; $i++) {
                         $caracs = parent::_convertCharacteristics($product, $data);
                         $current_package = parent::groupPackages($data, $caracs);
                         if ($data['weight'] + round($caracs['weight'], 2) > $limitation['weight'] || $current_package['dim'] > $limitation['dimension'] || $data['width'] > $limitation['length']) {
                             $this->nbpackage++;
                             $data['XMLpackage'] .= $this->_createPackage($data, $product, $rate, $order, true);
                             $data['weight'] = round($caracs['weight'], 2);
                             $data['height'] = $current_package['y'];
                             $data['length'] = $current_package['z'];
                             $data['width'] = $current_package['x'];
                             $data['price'] = $product->prices[0]->price_value_with_tax;
                         } else {
                             $data['weight'] += round($caracs['weight'], 2);
                             $data['height'] = max($data['height'], $current_package['y']);
                             $data['length'] = max($data['length'], $current_package['z']);
                             $data['width'] += $current_package['x'];
                             $data['price'] += $product->prices[0]->price_value_with_tax;
                         }
                     }
                 }
             }
         }
         if ($data['weight'] + $data['height'] + $data['length'] + $data['width'] > 0) {
             $this->nbpackage++;
             $data['XMLpackage'] .= $this->_createPackage($data, $product, $rate, $order, true);
         }
         $usableMethods = $this->_FEDEXrequestMethods($data, $rate);
     }
     if (empty($usableMethods)) {
         return false;
     }
     $currencies = array();
     foreach ($usableMethods as $method) {
         $currencies[$method['currency_code']] = '"' . $method['currency_code'] . '"';
     }
     $db = JFactory::getDBO();
     $query = 'SELECT currency_code, currency_id FROM ' . hikashop_table('currency') . ' WHERE currency_code IN (' . implode(',', $currencies) . ')';
     $db->setQuery($query);
     $currencyList = $db->loadObjectList();
     $currencyList = reset($currencyList);
     foreach ($usableMethods as $i => $method) {
         $usableMethods[$i]['currency_id'] = $currencyList->currency_id;
     }
     $usableMethods = parent::_currencyConversion($usableMethods, $order);
     return $usableMethods;
 }
Beispiel #3
0
 function _getShippingMethods(&$rate, &$order, &$warehouse, $heavyProduct, $null)
 {
     $data['userId'] = $rate->shipping_params->user_id;
     $data['accessLicenseNumber'] = $rate->shipping_params->access_code;
     $data['password'] = $rate->shipping_params->password;
     $data['destCity'] = $null->shipping_address->address_city;
     $data['destZip'] = $null->shipping_address->address_post_code;
     if (empty($null->shipping_address->address_country->zone_code_2)) {
         $null->shipping_address->address_country->zone_code_2 = 'US';
     }
     $data['destCountry'] = $null->shipping_address->address_country->zone_code_2;
     $data['destStatecode'] = $null->shipping_address->address_state->zone_code_3;
     $data['city'] = $warehouse->city;
     $data['zip'] = $warehouse->zip;
     $data['stateCode'] = @$warehouse->statecode;
     $data['country'] = $warehouse->country_ID;
     $data['units'] = $warehouse->units;
     $data['currency'] = $warehouse->currency;
     $data['currency_code'] = $warehouse->currency_code;
     $data['old_currency'] = $warehouse->currency;
     $data['old_currency_code'] = $warehouse->currency_code;
     $data['shipperNumber'] = $rate->shipping_params->shipper_number;
     $data['XMLpackage'] = '';
     $data['destType'] = '';
     $data['negotiated_rate'] = '';
     $limitations = array();
     if ($rate->shipping_params->destination_type == 'res') {
         $data['destType'] = '<ResidentialAddressIndicator/>';
     }
     if ($rate->shipping_params->destination_type == 'auto' && empty($order->shipping_address->address_company)) {
         $data['destType'] = '<ResidentialAddressIndicator/>';
     }
     $data['pickup_type'] = $rate->shipping_params->pickup_type;
     $totalPrice = 0;
     if ($this->freight == true && $this->classicMethod == false || $heavyProduct == true && $this->freight == true) {
         $data['weight'] = 0;
         $data['height'] = 0;
         $data['length'] = 0;
         $data['width'] = 0;
         $data['price'] = 0;
         foreach ($order->products as $product) {
             if ($product->product_parent_id == 0) {
                 if (isset($product->variants)) {
                     foreach ($product->variants as $variant) {
                         $caracs = parent::_convertCharacteristics($variant, $data);
                         $data['weight_unit'] = $caracs['weight_unit'];
                         $data['dimension_unit'] = $caracs['dimension_unit'];
                         $data['weight'] += round($caracs['weight'], 2) * $variant->cart_product_quantity;
                         $data['height'] += round($caracs['height'], 2) * $variant->cart_product_quantity;
                         $data['length'] += round($caracs['length'], 2) * $variant->cart_product_quantity;
                         $data['width'] += round($caracs['width'], 2) * $variant->cart_product_quantity;
                         $data['price'] += $variant->prices[0]->unit_price->price_value_with_tax * $variant->cart_product_quantity;
                     }
                 } else {
                     $caracs = parent::_convertCharacteristics($product, $data);
                     $data['weight_unit'] = $caracs['weight_unit'];
                     $data['dimension_unit'] = $caracs['dimension_unit'];
                     $data['weight'] += round($caracs['weight'], 2) * $product->cart_product_quantity;
                     $data['height'] += round($caracs['height'], 2) * $product->cart_product_quantity;
                     $data['length'] += round($caracs['length'], 2) * $product->cart_product_quantity;
                     $data['width'] += round($caracs['width'], 2) * $product->cart_product_quantity;
                     $data['price'] += $product->prices[0]->unit_price->price_value_with_tax * $product->cart_product_quantity;
                 }
             }
         }
         $data['XMLpackage'] .= $this->_createPackage($data, $product, $rate, $order);
         if (!empty($rate->shipping_params->negotiated_rate)) {
             $data['negotiated_rate'] = '<RateInformation><NegotiatedRatesIndicator/></RateInformation>';
         }
         $usableMethods = $this->_UPSrequestMethods($data);
         return $usableMethods;
     }
     if ($rate->shipping_params->group_package) {
         $data['weight'] = 0;
         $data['height'] = 0;
         $data['length'] = 0;
         $data['width'] = 0;
         $data['price'] = 0;
         $current_package = array();
         foreach ($order->products as $product) {
             if ($product->product_parent_id == 0) {
                 if (isset($product->variants)) {
                     foreach ($product->variants as $variant) {
                         for ($i = 0; $i < $variant->cart_product_quantity; $i++) {
                             $caracs = parent::_convertCharacteristics($variant, $data);
                             $current_package = parent::groupPackages($data, $caracs);
                             if ($data['weight_unit'] == 'KGS') {
                                 $limitations['weight'] = 70;
                             } else {
                                 $limitations['weight'] = 150;
                             }
                             if ($data['dimension_unit'] == 'CM') {
                                 $limitations['dimension'] = 419;
                             } else {
                                 $limitations['dimension'] = 165;
                             }
                             if ($data['weight'] + round($caracs['weight'], 2) > $limitations['weight'] || $current_package['dim'] > $limitations['dimension']) {
                                 $this->nbpackage++;
                                 $data['XMLpackage'] .= $this->_createPackage($data, $product, $rate, $order, true);
                                 $data['weight'] = round($caracs['weight'], 2);
                                 $data['height'] = $current_package['y'];
                                 $data['length'] = $current_package['z'];
                                 $data['width'] = $current_package['x'];
                                 $data['price'] = $variant->prices[0]->unit_price->price_value_with_tax;
                             } else {
                                 $data['weight'] += round($caracs['weight'], 2);
                                 $data['height'] = max($data['height'], $current_package['y']);
                                 $data['length'] = max($data['length'], $current_package['z']);
                                 $data['width'] += $current_package['x'];
                                 $data['price'] += $variant->prices[0]->unit_price->price_value_with_tax;
                             }
                         }
                     }
                 } else {
                     for ($i = 0; $i < $product->cart_product_quantity; $i++) {
                         $caracs = parent::_convertCharacteristics($product, $data);
                         $current_package = parent::groupPackages($data, $caracs);
                         if ($data['weight_unit'] == 'KGS') {
                             $limitations['weight'] = 70;
                         } else {
                             $limitations['weight'] = 150;
                         }
                         if ($data['dimension_unit'] == 'CM') {
                             $limitations['dimension'] = 419;
                         } else {
                             $limitations['dimension'] = 165;
                         }
                         if ($data['weight'] + round($caracs['weight'], 2) > $limitations['weight'] || $current_package['dim'] > $limitations['dimension']) {
                             $this->nbpackage++;
                             $data['XMLpackage'] .= $this->_createPackage($data, $product, $rate, $order, true);
                             $data['weight'] = round($caracs['weight'], 2);
                             $data['height'] = $current_package['y'];
                             $data['length'] = $current_package['z'];
                             $data['width'] = $current_package['x'];
                             $data['price'] = $product->prices[0]->unit_price->price_value_with_tax;
                         } else {
                             $data['weight'] += round($caracs['weight'], 2);
                             $data['height'] = max($data['height'], $current_package['y']);
                             $data['length'] = max($data['length'], $current_package['z']);
                             $data['width'] += $current_package['x'];
                             $data['price'] += $product->prices[0]->unit_price->price_value_with_tax;
                         }
                     }
                 }
             }
         }
         if ($data['weight'] + $data['height'] + $data['length'] + $data['width'] > 0) {
             $this->nbpackage++;
             $data['XMLpackage'] .= $this->_createPackage($data, $product, $rate, $order, true);
         }
         if (!empty($rate->shipping_params->negotiated_rate)) {
             $data['negotiated_rate'] = '<RateInformation><NegotiatedRatesIndicator/></RateInformation>';
         }
         $usableMethods = $this->_UPSrequestMethods($data);
     } else {
         foreach ($order->products as $product) {
             $data['weight'] = 0;
             $data['height'] = 0;
             $data['length'] = 0;
             $data['width'] = 0;
             if (isset($product->prices[0])) {
                 if (!isset($product->prices[0]->unit_price->price_value_with_tax)) {
                     $data['price'] = $product->prices[0]->price_value_with_tax;
                 } else {
                     $data['price'] = $product->prices[0]->unit_price->price_value_with_tax;
                 }
             }
             if ($product->product_parent_id == 0) {
                 if (isset($product->variants)) {
                     foreach ($product->variants as $variant) {
                         $data['price'] = $variant->prices[0]->unit_price->price_value_with_tax;
                         for ($i = 0; $i < $variant->cart_product_quantity; $i++) {
                             $data['XMLpackage'] .= $this->_createPackage($data, $variant, $rate, $order, true);
                         }
                     }
                 } else {
                     if (isset($product->prices[0])) {
                         if (!isset($product->prices[0]->unit_price->price_value_with_tax)) {
                             $data['price'] = $product->prices[0]->price_value_with_tax;
                         } else {
                             $data['price'] = $product->prices[0]->unit_price->price_value_with_tax;
                         }
                     }
                     for ($i = 0; $i < $product->cart_product_quantity; $i++) {
                         $data['XMLpackage'] .= $this->_createPackage($data, $product, $rate, $order, true);
                     }
                 }
             }
         }
         if (!empty($rate->shipping_params->negotiated_rate)) {
             $data['negotiated_rate'] = '<RateInformation><NegotiatedRatesIndicator/></RateInformation>';
         }
         $usableMethods = $this->_UPSrequestMethods($data);
     }
     if (empty($usableMethods)) {
         return false;
     }
     $currencies = array();
     foreach ($usableMethods as $method) {
         $currencies[$method['currency_code']] = '"' . $method['currency_code'] . '"';
     }
     $db = JFactory::getDBO();
     $query = 'SELECT currency_code, currency_id FROM ' . hikashop_table('currency') . ' WHERE currency_code IN (' . implode(',', $currencies) . ')';
     $db->setQuery($query);
     $currencyList = $db->loadObjectList();
     $currencyList = reset($currencyList);
     foreach ($usableMethods as $i => $method) {
         $usableMethods[$i]['currency_id'] = $currencyList->currency_id;
     }
     $usableMethods = parent::_currencyConversion($usableMethods, $order);
     return $usableMethods;
 }