j-variety Posted April 25, 2012 Share Posted April 25, 2012 Hi Jim, I went ahead and deleted all the shipping modules except the "Federal Express" and "Per Item"; however, I still received the following error message: Shipping Method Fatal error: Call to a member function enabled() on a non-object in /home/content/93/8907593/html/includes/classes/vendor_shipping.php on line 117 I also went ahead and removed the "Per Item" module, and the error message is gone. It was working fine on the RC2, but my OSC version now is 2.3.1. The MVS version i'm using is 1.2.3. Do you think there might be some sort of coding error on the site or some file is causing the Item module to have problem? Thanks, Johnny It could be a shipping module with a coding error. First, check the vendors_shipping directory and remove anything that is not a shipping module. If that isn't the problem, remove all modules that you are not using. You might also try removing the Per Item module if it's causing errors. Regards Jim It could be a shipping module with a coding error. First, check the vendors_shipping directory and remove anything that is not a shipping module. If that isn't the problem, remove all modules that you are not using. You might also try removing the Per Item module if it's causing errors. Regards Jim Hi Jim, I went ahead and deleted all the shipping modules except the "Federal Express" and "Per Item"; however, I still received the following error message: Shipping Method Fatal error: Call to a member function enabled() on a non-object in /home/content/93/8907593/html/includes/classes/vendor_shipping.php on line 117 I also went ahead and removed the "Per Item" module, and the error message is gone. It was working fine on the RC2, but my OSC version now is 2.3.1. The MVS version i'm using is 1.2.3. Do you think there might be some sort of coding error on the site or some file is causing the Item module to have problem? Thanks, Johnny Quote Link to comment Share on other sites More sharing options...
♥kymation Posted April 25, 2012 Share Posted April 25, 2012 If that is the First Item Plus module (firstitemplus.php) then there has been a fix released -- see the MVS downloads and download the 3 March 2010 package. If it's the stock Item module, there haven't been any changes made to that. I haven't used either of those modules with MVS so I'm not going to be a lot of help here. Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
montana_girl Posted May 2, 2012 Share Posted May 2, 2012 Hi I have an active store did the uinstall, made the changes instead of getting the error in processing message at check out the usps option does not show at all. if someone has already answered this i apologize, but would really like some help. Quote Link to comment Share on other sites More sharing options...
♥kymation Posted May 2, 2012 Share Posted May 2, 2012 Check that you have MVS turned on in your Admin. Then check that the products in your test order are assigned to a vendor that uses USPS. You also need to set the vendor info that USPS needs (the zip code and tare functions.) Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
montana_girl Posted May 3, 2012 Share Posted May 3, 2012 Thank you for the reply so swiftly. All of those factos were set up correctly with the original mvs usps contribution i had. I did the uninstall reinstall as directed. I reregisted with usps and received a new id. I know originally we had to input the user name and passwork and now its just the user name. Do i need to let usps know that the site is osc so that a password is not requested? Lost on why it is not there, please let me know what else may be wrong. allison Quote Link to comment Share on other sites More sharing options...
♥kymation Posted May 3, 2012 Share Posted May 3, 2012 USPS has changed their API. The new API does not require a password if you are only going to get rate quotes. To debug, find this line in includes/modules/vendor_shipping/usps.php and uncomment the line. Change you@yourdomain.com to your email address (two places). Then run a test order and examine the email response. Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
forest03 Posted June 14, 2012 Share Posted June 14, 2012 (edited) Hi, I've tried installing the latest FedEx API (source: http://addons.oscommerce.com/info/7977), and I can enable it on its own through Modules - Shipping admin, but I need a version I can install via the MVS Vendor Manager. Is there some way to do that with this package, or do I need to wait for an MVS port? Also, if I manually place the new fedexwebservices files into their respective "vendors_shipping" folders (similar to the way it's done for "shipping"), I get the following error in the MVS vendor manager: Call to undefined method fedexwebservices::sort_order() in ../admin/vendor_modules.php line 154 if ($module->check($vendors_id) > 0) { if ($module->sort_order($vendors_id) > 0) { // this is line 154 $installed_modules[$module->sort_order($vendors_id)] = $file; Thank you Edited June 14, 2012 by forest03 Quote Link to comment Share on other sites More sharing options...
♥kymation Posted June 15, 2012 Share Posted June 15, 2012 Shipping modules must be modified to work with MVS. There are instructions in the MVS package for this. It does require some knowledge of PHP to make the changes successfully. Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
Guest Posted June 23, 2012 Share Posted June 23, 2012 Hi Jim, I followed the directions in the module text to port the new FEDEX webservices for MVS. I got the module file done but ran into an issue in the admin. I get an error Fatal error: Call to undefined method fedexwebservices::zones() in /home/xxxx/public_html/admin/vendor_modules.php on line 144 I searched and compared the new module shipping file to the old fedex file and cannot find the error. Can I comment out the zone coding since I don't use it? Quote Link to comment Share on other sites More sharing options...
♥kymation Posted June 23, 2012 Share Posted June 23, 2012 You can, provided you remove all of it. Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
Guest Posted June 23, 2012 Share Posted June 23, 2012 I've run into a wall and can't get this to work. Here is what I have so far with the includes/modules/vendors_shipping/ <?php /* FedEx Webservice Version 9.4.2 for osCommerce 2.2rc2a and later(?) -by Roaddoctor 5/20/2012 New contributed code and the hard work credit to Jeff Lew. Thanks Jeff and Numinex! Support: http://www.oscommerce.com/forums/topic/375063-fedex-web-services-v9/page__view__findpost__p__1636568 */ class fedexwebservices { var $code, $title, $description, $icon, $sort_order, $enabled, $tax_class, $fedex_key, $fedex_pwd, $fedex_act_num, $fedex_meter_num, $country; //Class Constructor function fedexwebservices() { global $order, $vendors_id; @[member='definedmedia']('MODULE_SHIPPING_FEDEX_WEB_SERVICES_INSURE_' . $vendors_id, 0); $this->code = "fedexwebservices"; $this->title = MODULE_SHIPPING_FEDEX_WEB_SERVICES_TEXT_TITLE; $this->description = MODULE_SHIPPING_FEDEX_WEB_SERVICES_TEXT_DESCRIPTION; // $this->sort_order = MODULE_SHIPPING_FEDEX_WEB_SERVICES_SORT_ORDER_ . $vendors_id; // $this->handling_fee = MODULE_SHIPPING_FEDEX_WEB_SERVICES_HANDLING_FEE; $this->icon = DIR_WS_ICONS . 'shipping_fedex.gif'; // $this->enabled = ((MODULE_SHIPPING_FEDEX_WEB_SERVICES_STATUS == 'true') ? true : false); // $this->tax_class = MODULE_SHIPPING_FEDEX_WEB_SERVICES_TAX_CLASS; // $this->fedex_key = MODULE_SHIPPING_FEDEX_WEB_SERVICES_KEY; // $this->fedex_pwd = MODULE_SHIPPING_FEDEX_WEB_SERVICES_PWD; // $this->fedex_act_num = MODULE_SHIPPING_FEDEX_WEB_SERVICES_ACT_NUM; // $this->fedex_meter_num = MODULE_SHIPPING_FEDEX_WEB_SERVICES_METER_NUM; $vendors_data_query = tep_db_query("select handling_charge, handling_per_box, vendor_country, vendors_zipcode from " . TABLE_VENDORS . " where vendors_id = '" . (int)$vendors_id . "'" ); $vendors_data = tep_db_fetch_array($vendors_data_query); $country_name = tep_get_countries($vendors_data['vendor_country'], true); if (isset($vendors_data['vendor_country']) && $vendors_data['vendor_country'] != '') { $countries_array = tep_get_countries($vendors_data['vendor_country'], true); $this->country = $countries_array['countries_iso_code_2']; } else { $countries_array = tep_get_countries(SHIPPING_ORIGIN_COUNTRY, true); $this->country = STORE_ORIGIN_COUNTRY; } if ( ($this->enabled == true) && ((int)constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_ZONE_' . $vendors_id > 0) ) { $check_flag = false; $check_query = tep_db_query ("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . (int)constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_ZONE_' . $vendors_id) . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id"); while( $check = tep_db_fetch_array($check_query)) { if ($check ['zone_id'] < 1) { $check_flag = true; break; } elseif ($check ['zone_id'] == $order->delivery['zone_id']) { $check_flag = true; break; } $check->MoveNext(); } if ($check_flag == false) { $this->enabled = false; } } } function sort_order($vendors_id='1') { if (defined (@[member='constant'] ('MODULE_SHIPPING_FEDEX_WEB_SERVICES_TABLE_SORT_ORDER_' . $vendors_id))) { $this->sort_order = @[member='constant']('MODULE_SHIPPING_FEDEX_WEB_SERVICES_TABLE_SORT_ORDER_' . $vendors_id); } else { $this->sort_order = '0'; } return $this->sort_order; } function handling_fee($vendors_id='1') { $this->handling_fee = constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_HANDLING_FEE_' . $vendors_id); return $this->handling_fee; } function tax_class($vendors_id='1') { $this->tax_class = constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_TABLE_TAX_CLASS_' . $vendors_id); return $this->tax_class; } function enabled($vendors_id='1') { $this->enabled = false; $status = @[member='constant']('MODULE_SHIPPING_FEDEX_WEB_SERVICES_TABLE_STATUS_' . $vendors_id); if (isset ($status) && $status != '') { $this->enabled = (($status == 'True') ? true : false); } if ( ($this->enabled == true) && ((int)constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_ZONE_' . $vendors_id) > 0) ) { $check_flag = false; $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . (int)constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_ZONE_' . $vendors_id) . "' and zone_country_id = '" . $this->delivery_country_id . "' order by zone_id"); while ($check = tep_db_fetch_array($check_query)) { if ($check['zone_id'] < 1) { $check_flag = true; break; } elseif ($check['zone_id'] == $this->delivery_zone_id) { $check_flag = true; break; } } if ($check_flag == false) { $this->enabled = false; }//if }//if return $this->enabled; } function fedex_key($vendors_id='1') { $this->fedex_key = constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_KEY_' . $vendors_id); return $this->fedex_key; } function fedex_pwd($vendors_id='1') { $this->fedex_pwd = constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_PWD_' . $vendors_id); return $this->fedex_pwd; } function fedex_act_num($vendors_id='1') { $this->fedex_act_num = constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_ACT_NUM_' . $vendors_id); return $this->fedex_act_num; } function fedex_meter_num($vendors_id='1') { $this->fedex_meter_num = constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_METER_NUM_' . $vendors_id); return $this->fedex_meter_num; } function zones($vendors_id='1') { if ( ($this->enabled == true) && ((int)constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_TABLE_ZONE_' . $vendors_id) > 0) ) { $check_flag = false; $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . (int)constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_TABLE_ZONE_' . $vendors_id) . "' and zone_country_id = '" . $this->delivery_country_id . "' order by zone_id"); while ($check = tep_db_fetch_array($check_query)) { if ($check['zone_id'] < 1) { $check_flag = true; break; // } elseif ($check['zone_id'] == $order->delivery['zone_id']) { } elseif ($check['zone_id'] == $this->delivery_zone_id) { $check_flag = true; break; } //if }//while if ($check_flag == false) { $this->enabled = false; }//if }//if return $this->enabled; }//function // class methods function quote($method = '',$vendors_id = '1') { /* FedEx integration starts */ global $shipping_weight, $shipping_num_boxes, $cart, $order; require_once(DIR_FS_CATALOG . DIR_WS_INCLUDES . 'library/fedex-common.php5'); //if (MODULE_SHIPPING_FEDEX_WEB_SERVICES_SERVER == 'test') { //$request['Version'] = array('ServiceId' => 'crs', 'Major' => '7', 'Intermediate' => '0', 'Minor' => '0'); //$path_to_wsdl = DIR_WS_INCLUDES . "wsdl/RateService_v7_test.wsdl"; //} else { $path_to_wsdl = DIR_FS_CATALOG . DIR_WS_INCLUDES . "wsdl/RateService_v9.wsdl"; //} ini_set("soap.wsdl_cache_enabled", "0"); $client = new SoapClient($path_to_wsdl, array('trace' => 1)); $this->types = array(); if constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_PRIORITY_' . $vendors_id) == 'true') { $this->types['INTERNATIONAL_PRIORITY'] = array('icon' => '', 'handling_fee' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_EXPRESS_HANDLING_FEE_' . $vendors_id); $this->types['EUROPE_FIRST_INTERNATIONAL_PRIORITY'] = array('icon' => '', 'handling_fee' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_EXPRESS_HANDLING_FEE_' . $vendors_id); } if constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_ECONOMY_' . $vendors_id) == 'true') { $this->types['INTERNATIONAL_ECONOMY'] = array('icon' => '', 'handling_fee' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_EXPRESS_HANDLING_FEE_' . $vendors_id); } if constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_STANDARD_OVERNIGHT_' . $vendors_id) == 'true') { $this->types['STANDARD_OVERNIGHT'] = array('icon' => '', 'handling_fee' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_' . $vendors_id); } if constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_FIRST_OVERNIGHT_' . $vendors_id) == 'true') { $this->types['FIRST_OVERNIGHT'] = array('icon' => '', 'handling_fee' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_' . $vendors_id); } if constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_PRIORITY_OVERNIGHT_' . $vendors_id) == 'true') { $this->types['PRIORITY_OVERNIGHT'] = array('icon' => '', 'handling_fee' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_' . $vendors_id); } if constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_2DAY_' . $vendors_id) == 'true') { $this->types['FEDEX_2_DAY'] = array('icon' => '', 'handling_fee' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_' . $vendors_id); } // because FEDEX_GROUND also is returned for Canadian Addresses, we need to check if the country matches the store country and whether international ground is enabled if ((constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_GROUND_' . $vendors_id) == 'true' && $order->delivery['country']['id'] == STORE_COUNTRY) || (constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_GROUND_' . $vendors_id) == 'true') && ($order->delivery['country']['id'] != STORE_COUNTRY) && (constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_GROUND_' . $vendors_id) == 'true')) { $this->types['FEDEX_GROUND'] = array('icon' => '', 'handling_fee' => ($order->delivery['country']['id'] == STORE_COUNTRY ? constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_HANDLING_FEE_' . $vendors_id : constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_HANDLING_FEE_' . $vendors_id)); $this->types['GROUND_HOME_DELIVERY'] = array('icon' => '', 'handling_fee' => ($order->delivery['country']['id'] == STORE_COUNTRY ? constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_HOME_DELIVERY_HANDLING_FEE_' . $vendors_id : constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_HANDLING_FEE_' . $vendors_id)); } if (constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_GROUND_' . $vendors_id) == 'true') { $this->types['INTERNATIONAL_GROUND'] = array('icon' => '', 'handling_fee' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_HANDLING_FEE_' . $vendors_id); } if (constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_SAVER_' . $vendors_id) == 'true') { $this->types['FEDEX_EXPRESS_SAVER'] = array('icon' => '', 'handling_fee' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_' . $vendors_id); } if (constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_FREIGHT_' . $vendors_id) == 'true') { $this->types['FEDEX_FREIGHT'] = array('icon' => '', 'handling_fee' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_' . $vendors_id); $this->types['FEDEX_NATIONAL_FREIGHT'] = array('icon' => '', 'handling_fee' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_' . $vendors_id); $this->types['FEDEX_1_DAY_FREIGHT'] = array('icon' => '', 'handling_fee' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_' . $vendors_id); $this->types['FEDEX_2_DAY_FREIGHT'] = array('icon' => '', 'handling_fee' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_' . $vendors_id); $this->types['FEDEX_3_DAY_FREIGHT'] = array('icon' => '', 'handling_fee' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_' . $vendors_id); $this->types['INTERNATIONAL_ECONOMY_FREIGHT'] = array('icon' => '', 'handling_fee' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_EXPRESS_HANDLING_FEE_' . $vendors_id); $this->types['INTERNATIONAL_PRIORITY_FREIGHT'] = array('icon' => '', 'handling_fee' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_EXPRESS_HANDLING_FEE_' . $vendors_id); } // $this->types[] = 'SMART_POST'; // customer details $street_address = $order->delivery['street_address']; $street_address2 = $order->delivery['suburb']; $city = $order->delivery['city']; $state = tep_get_zone_code($order->delivery['country']['id'], $order->delivery['zone_id'], ''); if ($state == "QC") $state = "PQ"; $postcode = str_replace(array(' ', '-'), '', $order->delivery['postcode']); $country_id = $order->delivery['country']['iso_code_2']; $totals = $cart->vendor_shipping[$vendors_id]['subtotal']; $this->_setInsuranceValue($totals / $shipping_num_boxes, $vendors_id); $request['WebAuthenticationDetail'] = array('UserCredential' => array('Key' => $this->fedex_key, 'Password' => $this->fedex_pwd)); $request['ClientDetail'] = array('AccountNumber' => $this->fedex_act_num, 'MeterNumber' => $this->fedex_meter_num); $request['TransactionDetail'] = array('CustomerTransactionId' => ' *** Rate Request v9 using PHP ***'); // $request['RequestedShipment']['SmartPostDetail'] = array( // 'Indicia' => 'MEDIA_MAIL', // 'AncillaryEndorsement' => 'CARRIER_LEAVE_IF_NO_RESPONSE', // 'SpecialServices' => 'USPS_DELIVERY_CONFIRMATION', // 'HubId' => '5254', // 'CustomerManifestId' => 1101); // $request['RequestedShipment']['ServiceType'] = 'SMART_POST'; $request['Version'] = array('ServiceId' => 'crs', 'Major' => '9', 'Intermediate' => '0', 'Minor' => '0'); $request['ReturnTransitAndCommit'] = true; $request['RequestedShipment']['DropoffType'] = $this->_setDropOff(); // valid values REGULAR_PICKUP, REQUEST_COURIER, ... $request['RequestedShipment']['ShipTimestamp'] = date('c'); $request['RequestedShipment']['PackagingType'] = 'YOUR_PACKAGING'; // valid values FEDEX_BOX, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ... $request['RequestedShipment']['TotalInsuredValue']=array('Ammount'=> $this->insurance, 'Currency' => $_SESSION['currency']); $request['WebAuthenticationDetail'] = array('UserCredential' => array('Key' => $this->fedex_key, 'Password' => $this->fedex_pwd)); $request['ClientDetail'] = array('AccountNumber' => $this->fedex_act_num, 'MeterNumber' => $this->fedex_meter_num); // print_r($request['WebAuthenticationDetail']); // print_r($request['ClientDetail']); // exit; $request['RequestedShipment']['Shipper'] = array('Address' => array( 'StreetLines' => array constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_ADDRESS_1, constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_ADDRESS_2), // Origin details 'City' => MODULE_SHIPPING_FEDEX_WEB_SERVICES_CITY, 'StateOrProvinceCode' => MODULE_SHIPPING_FEDEX_WEB_SERVICES_STATE, 'PostalCode' => MODULE_SHIPPING_FEDEX_WEB_SERVICES_POSTAL, 'CountryCode' => $this->country)); $request['RequestedShipment']['Recipient'] = array('Address' => array ( 'StreetLines' => array($street_address, $street_address2), // customer street address 'City' => $city, //customer city // 'StateOrProvinceCode' => $state, //customer state 'PostalCode' => $postcode, //customer postcode 'CountryCode' => $country_id, 'Residential' => ($order->delivery['company'] != '' ? false : true))); //customer county code if (in_array($country_id, array('US', 'CA'))) { $request['RequestedShipment']['Recipient']['StateOrProvinceCode'] = $state; } // print_r($request['RequestedShipment']['Recipient']) ; // exit; $request['RequestedShipment']['ShippingChargesPayment'] = array('PaymentType' => 'SENDER', 'Payor' => array('AccountNumber' => $this->fedex_act_num, // payor's account number 'CountryCode' => $this->country)); $request['RequestedShipment']['RateRequestTypes'] = 'LIST'; $request['RequestedShipment']['PackageDetail'] = 'INDIVIDUAL_PACKAGES'; $request['RequestedShipment']['RequestedPackageLineItems'] = array(); $dimensions_failed = false; // check for ready to ship field if (constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_READY_TO_SHIP_' . $vendors_id) == 'true') { $products = $_SESSION['cart']->get_products(); $packages = array('default' => 0); $product_dim_type = 'in'; $new_shipping_num_boxes = 0; foreach ($products as $product) { $dimensions_query = "SELECT products_ready_to_ship, products_ship_sep FROM " . TABLE_PRODUCTS . " WHERE products_id = " . (int)$product['id'] . " LIMIT 1;"; $dimensions = tep_db_query($dimensions_query); if ($product_dimensions = tep_db_fetch_array($dimensions)) { if ($product_dimensions['products_ready_to_ship'] == 1 || $product_dimensions['products_ship_sep'] == 1) { for ($i = 1; $i <= $product['quantity']; $i++) { $packages[] = array('weight' => $product['weight']); } } else { $packages['default'] += $product['weight'] * $product['quantity']; } } } if (count($packages) > 1) { $za_tare_array = preg_split("/[:,]/" , SHIPPING_BOX_WEIGHT); $zc_tare_percent= $za_tare_array[0]; $zc_tare_weight= $za_tare_array[1]; $za_large_array = preg_split("/[:,]/" , SHIPPING_BOX_PADDING); $zc_large_percent= $za_large_array[0]; $zc_large_weight= $za_large_array[1]; } foreach ($packages as $id => $values) { if ($id === 'default') { // divide the weight by the max amount to be shipped (can be done inside loop as this occurance should only ever happen once // note $values is not an array if ($values == 0) continue; $shipping_num_boxes = ceil((float)$values / (float)SHIPPING_MAX_WEIGHT); if ($shipping_num_boxes < 1) $shipping_num_boxes = 1; $shipping_weight = round((float)$values / $shipping_num_boxes, 2); // 2 decimal places max for ($i=0; $i<$shipping_num_boxes; $i++) { $new_shipping_num_boxes++; if (SHIPPING_MAX_WEIGHT <= $shipping_weight) { $shipping_weight = $shipping_weight + ($shipping_weight*($zc_large_percent/100)) + $zc_large_weight; } else { $shipping_weight = $shipping_weight + ($shipping_weight*($zc_tare_percent/100)) + $zc_tare_weight; } if ($shipping_weight <= 0) $shipping_weight = 0.1; $new_shipping_weight += $shipping_weight; $request['RequestedShipment']['RequestedPackageLineItems'][] = array('Weight' => array('Value' => $shipping_weight, 'Units' => MODULE_SHIPPING_FEDEX_WEB_SERVICES_WEIGHT ) ); } } else { // note $values is an array $new_shipping_num_boxes++; if ($values['weight'] <= 0) $values['weight'] = 0.1; $new_shipping_weight += $values['weight']; $request['RequestedShipment']['RequestedPackageLineItems'][] = array('Weight' => array('Value' => $values['weight'], 'Units' => MODULE_SHIPPING_FEDEX_WEB_SERVICES_WEIGHT) ); } } $shipping_num_boxes = $new_shipping_num_boxes; If (!$shipping_num_boxes || $shipping_num_boxes == 0) { $shipping_num_boxes = 1; } $shipping_weight = round($new_shipping_weight / $shipping_num_boxes, 2); } else { // Zen Cart default method for calculating number of packages if ($shipping_weight == 0) $shipping_weight = 0.1; for ($i=0; $i<$shipping_num_boxes; $i++) { $request['RequestedShipment']['RequestedPackageLineItems'][] = array('Weight' => array('Value' => $shipping_weight, 'Units' => MODULE_SHIPPING_FEDEX_WEB_SERVICES_WEIGHT)); } } $request['RequestedShipment']['PackageCount'] = $shipping_num_boxes; if (constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_SATURDAY_' . $vendors_id) == 'true') { $request['RequestedShipment']['ServiceOptionType'] = 'SATURDAY_DELIVERY'; } if (constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_SIGNATURE_OPTION _' . $vendors_id)>= 0 && $totals >= MODULE_SHIPPING_FEDEX_WEB_SERVICES_SIGNATURE_OPTION) { $request['RequestedShipment']['SpecialServicesRequested'] = 'SIGNATURE_OPTION'; } // echo '<!-- shippingWeight: ' . $shipping_weight . ' ' . $shipping_num_boxes . ' -->'; // echo '<!-- '; // echo '<pre>'; // print_r($request); // echo '</pre>'; // echo ' -->'; $response = $client->getRates($request); // echo '<!-- '; // echo '<pre>'; // print_r($response); // echo '</pre>'; // echo ' -->'; if ($response->HighestSeverity != 'FAILURE' && $response->HighestSeverity != 'ERROR' && is_array($response->RateReplyDetails) || is_object($response->RateReplyDetails)) { if (is_object($response->RateReplyDetails)) { $response->RateReplyDetails = get_object_vars($response->RateReplyDetails); } // echo '<pre>'; // print_r($response->RateReplyDetails); // echo '</pre>'; $show_box_weight = " (Total items: " . $shipping_num_boxes . ' pcs. Total weight: '.number_format($shipping_weight * $shipping_num_boxes,2).' '.strtolower(MODULE_SHIPPING_FEDEX_WEB_SERVICES_WEIGHT).'s.)'; $this->quotes = array('id' => $this->code, 'module' => $this->title . $show_box_weight, 'info' => $this->info()); // echo '<pre>'; // print_r($response->RateReplyDetails); // echo '</pre>'; // EXIT(); $methods = array(); // echo '<pre>'; // print_r($this->types); // echo '</pre>'; foreach ($response->RateReplyDetails as $rateReply) { if (array_key_exists($rateReply->ServiceType, $this->types) && ($method == '' || str_replace('_', '', $rateReply->ServiceType) == $method)) { if (constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_RATES_' . $vendors_id)=='LIST') { foreach($rateReply->RatedShipmentDetails as $ShipmentRateDetail) { if($ShipmentRateDetail->ShipmentRateDetail->RateType=='PAYOR_LIST_PACKAGE') { $cost = $ShipmentRateDetail->ShipmentRateDetail->TotalNetCharge->Amount; $cost = (float)round(preg_replace('/[^0-9.]/', '', $cost), 2); } } } else { $cost = $rateReply->RatedShipmentDetails[0]->ShipmentRateDetail->TotalNetCharge->Amount; $cost = (float)round(preg_replace('/[^0-9.]/', '', $cost), 2); } if (in_array($rateReply->ServiceType, array('GROUND_HOME_DELIVERY', 'FEDEX_GROUND', 'INTERNATIONAL_GROUND'))) { // print_r($rateReply); $transitTime = ' (' . str_replace(array('_', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteeen'), array(' ', 1,2,3,4,5,6,7,8,9,10,11,12,13,14), strtolower($rateReply->TransitTime)) . ')'; } $methods[] = array('id' => str_replace('_', '', $rateReply->ServiceType), 'title' => ucwords(strtolower(str_replace('_', ' ', $rateReply->ServiceType))) . $transitTime, 'cost' => $cost + (strpos($this->types[$rateReply->ServiceType]['handling_fee'], '%') ? ($cost * (float)$this->types[$rateReply->ServiceType]['handling_fee'] / 100) : (float)$this->types[$rateReply->ServiceType]['handling_fee'])); } } // usort($methods, 'cmp'); $this->quotes['methods'] = $methods; if ($this->tax_class($vendors_id) > 0) { $this->quotes['tax'] = tep_get_tax_rate($this->tax_class($vendors_id), $order->delivery['country']['id'], $order->delivery['zone_id']); } } else { $message = 'Error in processing transaction.<br /><br />'; foreach ($response -> Notifications as $notification) { if(is_array($response -> Notifications)) { $message .= $notification->Severity; $message .= ': '; $message .= $notification->Message . '<br />'; } else { $message .= $notification->Message . '<br />'; } } $vendors_data_query = tep_db_query("select handling_charge, handling_per_box, vendor_country, vendors_zipcode from " . TABLE_VENDORS . " where vendors_id = '" . (int)$vendors_id . "'" ); $vendors_data = tep_db_fetch_array($vendors_data_query); $country_name = tep_get_countries($vendors_data['vendor_country'], true); if (isset($vendors_data['vendor_country']) && $vendors_data['vendor_country'] != '') { $countries_array = tep_get_countries($vendors_data['vendor_country'], true); $this->country = $countries_array['countries_iso_code_2']; } else { $countries_array = tep_get_countries(SHIPPING_ORIGIN_COUNTRY, true); $this->country = STORE_ORIGIN_COUNTRY; } // $vendors_data = tep_db_fetch_array($vendors_data_query); $handling_charge = $vendors_data['handling_charge']; $handling_per_box = $vendors_data['handling_per_box']; if ($handling_charge > $handling_per_box * $shipping_num_boxes) { $handling = $handling_charge; } else { $handling = $handling_per_box * $shipping_num_boxes; } $this->quotes = array('module' => $this->title, 'error' => $message); } // po box hack by JD if (eregi("^P(.+)O(.+)BOX",$order->delivery['street_address']) ||eregi("^PO BOX",$order->delivery['street_address']) || eregi("^P(.+)O(.+)BOX",$order->delivery['suburb']) || eregi("^[A-Z]PO",$order->delivery['street_address']) || eregi("^[A-Z]PO",$order->delivery['suburb'])) { $this->quotes = array('module' => $this->title, 'error' => '<font size=+2 color=red><b>Federal Express cannot ship to Post Office Boxes.<b></font><br>Use the Change Address button above to use a FedEx accepted street address.'); } // end po box hack by JD if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title); // echo '<!-- Quotes: '; // print_r($this->quotes); // print_r($_SESSION['shipping']); // echo ' -->'; return $this->quotes; } function cmp($a, $b, $vendors_id) { if ($a['cost'] == $b['cost']) { return 0; } return ($a['cost'] < $b['cost']) ? -1 : 1; } // method added for expanded info in FEAC function info($vendors_id) { return MODULE_SHIPPING_FEDEX_WEB_SERVICES_INFO; // add a description here or leave blank to disable } function _setInsuranceValue($order_amount, $vendors_id = '1') { } if ($order_amount > constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_INSURE_' . $vendors_id)) { $this->insurance = sprintf("%01.2f", $order_amount); } else { $this->insurance = 0; } } function objectToArray($object, $vendors_id) { if( !is_object( $object ) && !is_array( $object ) ) { return $object; } if( is_object( $object ) ) { $object = get_object_vars( $object ); } return array_map( 'objectToArray', $object ); } function _setDropOff($vendors_id) { switch(MODULE_SHIPPING_FEDEX_WEB_SERVICES_DROPOFF) { case '1': return 'REGULAR_PICKUP'; break; case '2': return 'REQUEST_COURIER'; break; case '3': return 'DROP_BOX'; break; case '4': return 'BUSINESS_SERVICE_CENTER'; break; case '5': return 'STATION'; break; } } //MVS function check($vendors_id='1') { if (!isset($this->_check)) { //multi vendor add "vendors_id = '". $vendors_id ."' and" $check_query = tep_db_query("select configuration_value from " . TABLE_VENDOR_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_STATUS_" . $vendors_id . "' and vendors_id = '" . $vendors_id . "'"); $this->_check = tep_db_num_rows($check_query); } return $this->_check; } function install($vendors_id='1') { tep_db_query("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) VALUES ('Enable FedEx Web Services','MODULE_SHIPPING_FEDEX_WEB_SERVICES_STATUS_" . $vendors_id . "', 'True', 'Do you want to offer Fedex shipping?', '6', '10', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('FedEx Web Services Key', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_KEY_" . $vendors_id . "', '', 'Enter FedEx Web Services Key', '6', '3', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('FedEx Web Services Password', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_PWD_" . $vendors_id . "', '', 'Enter FedEx Web Services Password', '6', '3', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('FedEx Account Number', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_ACT_NUM_" . $vendors_id . "', '', 'Enter FedEx Account Number', '6', '3', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('FedEx Meter Number', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_METER_NUM_" . $vendors_id . "', '', 'Enter FedEx Meter Number', '6', '4', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Weight Units', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_WEIGHT_" . $vendors_id . "', 'LB', 'Weight Units:', '6', '10', 'tep_cfg_select_option(array(\'LB\', \'KG\'), ', now())"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('First line of street address', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_ADDRESS_1_" . $vendors_id . "', '', 'Enter the first line of your ship-from street address, required', '6', '20', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Second line of street address', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_ADDRESS_2_" . $vendors_id . "', '', 'Enter the second line of your ship-from street address, leave blank if you do not need to specify a second line', '6', '21', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('City name', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_CITY_" . $vendors_id . "', '', 'Enter the city name for the ship-from street address, required', '6', '22', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('State or Province name', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_STATE_" . $vendors_id . "', '', 'Enter the 2 letter state or province name for the ship-from street address, required for Canada and US', '6', '23', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Postal code', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_POSTAL_" . $vendors_id . "', '', 'Enter the postal code for the ship-from street address, required', '6', '24', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Phone number', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_PHONE_" . $vendors_id . "', '', 'Enter a contact phone number for your company, required', '6', '25', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Drop off type', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_DROPOFF_" . $vendors_id . "', '1', 'Dropoff type (1 = Regular pickup, 2 = request courier, 3 = drop box, 4 = drop at BSC, 5 = drop at station)?', '6', '30', 'tep_cfg_select_option(array(\'1\',\'2\',\'3\',\'4\',\'5\'),', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable Express Saver', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_SAVER_" . $vendors_id . "', 'true', 'Enable FedEx Express Saver', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable Standard Overnight', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_STANDARD_OVERNIGHT_" . $vendors_id . "', 'true', 'Enable FedEx Express Standard Overnight', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable First Overnight', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_FIRST_OVERNIGHT_" . $vendors_id . "', 'true', 'Enable FedEx Express First Overnight', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable Priority Overnight', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_PRIORITY_OVERNIGHT_" . $vendors_id . "', 'true', 'Enable FedEx Express Priority Overnight', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable 2 Day', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_2DAY_" . $vendors_id . "', 'true', 'Enable FedEx Express 2 Day', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(), '" . $vendors_id . "')"); tep_db_query("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Insurance?', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INSURE_" . $vendors_id . "', 'NONE', 'Insure packages over what dollar amount?', '6', '22', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable International Priority', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_PRIORITY_" . $vendors_id . "', 'true', 'Enable FedEx Express International Priority', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable International Economy', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_ECONOMY_" . $vendors_id . "', 'true', 'Enable FedEx Express International Economy', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable Ground', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_GROUND_" . $vendors_id . "', 'true', 'Enable FedEx Ground', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable International Ground', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_GROUND_" . $vendors_id . "', 'true', 'Enable FedEx International Ground', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable Freight', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_FREIGHT_" . $vendors_id . "', 'true', 'Enable FedEx Freight', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable Saturday Delivery', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_SATURDAY_" . $vendors_id . "', 'false', 'Enable Saturday Delivery', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Domestic Ground Handling Fee', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_HANDLING_FEE_" . $vendors_id . "', '', 'Add a domestic handling fee or leave blank (example: 15 or 15%)', '6', '25', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Home Delivery Handling Fee', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_HOME_DELIVERY_HANDLING_FEE_" . $vendors_id . "', '', 'Add a home delivery handling fee or leave blank (example: 15 or 15%)', '6', '25', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Domestic Express Handling Fee', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_" . $vendors_id . "', '', 'Add a domestic handling fee or leave blank (example: 15 or 15%)', '6', '25', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('International Ground Handling Fee', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_HANDLING_FEE_" . $vendors_id . "', '', 'Add an international handling fee or leave blank (example: 15 or 15%)', '6', '25', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('International Express Handling Fee', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_EXPRESS_HANDLING_FEE_" . $vendors_id . "', '', 'Add an international handling fee or leave blank (example: 15 or 15%)', '6', '25', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) VALUES ('FedEx Rates','MODULE_SHIPPING_FEDEX_WEB_SERVICES_RATES_" . $vendors_id . "','LIST','FedEx Rates','6','0','tep_cfg_select_option(array(\'LIST\',\'ACCOUNT\'),',now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Signature Option', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_SIGNATURE_OPTION_" . $vendors_id . "', '-1', 'Require a signature on orders greater than or equal to (set to -1 to disable):', '6', '25', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable Ready to Ship', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_READY_TO_SHIP_" . $vendors_id . "', 'false', 'Enable products_ship_sep or products_ready_to_ship field (required to identify products which ship separately', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added, vendors_id) values ('Shipping Zone', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_ZONE_" . $vendors_id . "', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '98', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added, vendors_id) values ('Tax Class', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_TAX_CLASS_" . $vendors_id . "', '0', 'Use the following tax class on the shipping fee.', '6', '25', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Sort Order', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_SORT_ORDER_" . $vendors_id . "', '0', 'Sort order of display.', '6', '99', now(), '" . $vendors_id . "')"); } function remove($vendors_id) { tep_db_query("delete from " . TABLE_VENDOR_CONFIGURATION . " where vendors_id = '". $vendors_id ."' and configuration_key in ('" . implode("', '", $this->keys($vendors_id)) . "')"); } function keys($vendors_id) { return array('MODULE_SHIPPING_FEDEX_WEB_SERVICES_STATUS_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_KEY_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_PWD_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_ACT_NUM_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_METER_NUM_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_WEIGHT_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_ADDRESS_1_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_ADDRESS_2_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_CITY_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_STATE_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_POSTAL_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_PHONE_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_DROPOFF_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_SAVER_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_STANDARD_OVERNIGHT_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_FIRST_OVERNIGHT_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_PRIORITY_OVERNIGHT_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_2DAY_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_PRIORITY_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_ECONOMY_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_GROUND_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_FREIGHT_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_GROUND_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_SATURDAY_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_TAX_CLASS_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_HANDLING_FEE_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_HOME_DELIVERY_HANDLING_FEE_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_HANDLING_FEE_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INSURE_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_EXPRESS_HANDLING_FEE_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_RATES_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_SIGNATURE_OPTION_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_READY_TO_SHIP_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_ZONE_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_SORT_ORDER_' . $vendors_id); } function get_countries($countries_id = '', $vendors_id, $with_iso_codes = false) { $countries_array = array(); if (tep_not_null($countries_id)) { if ($with_iso_codes == true) { $countries = tep_db_query("select countries_name, countries_iso_code_2, countries_iso_code_3 from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$countries_id . "' order by countries_name"); $countries_values = tep_db_fetch_array($countries); $countries_array = array('countries_name' => $countries_values['countries_name'], 'countries_iso_code_2' => $countries_values['countries_iso_code_2'], 'countries_iso_code_3' => $countries_values['countries_iso_code_3']); } else { $countries = tep_db_query("select countries_name from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$countries_id . "'"); $countries_values = tep_db_fetch_array($countries); $countries_array = array('countries_name' => $countries_values['countries_name']); } } else { $countries = tep_db_query("select countries_id, countries_name from " . TABLE_COUNTRIES . " order by countries_name"); while ($countries_values = tep_db_fetch_array($countries)) { $countries_array[] = array('countries_id' => $countries_values['countries_id'], 'countries_name' => $countries_values['countries_name']); } } return $countries_array; } } Any help most appreciated Quote Link to comment Share on other sites More sharing options...
Guest Posted June 25, 2012 Share Posted June 25, 2012 Made some more changes but still not working <?php /* FedEx Webservice Version 9.4.2 for osCommerce 2.2rc2a and later(?) -by Roaddoctor 5/20/2012 New contributed code and the hard work credit to Jeff Lew. Thanks Jeff and Numinex! Support: http://www.oscommerce.com/forums/topic/375063-fedex-web-services-v9/page__view__findpost__p__1636568 */ class fedexwebservices { var $code, $title, $description, $icon, $sort_order, $enabled, $tax_class, $fedex_key, $fedex_pwd, $fedex_act_num, $fedex_meter_num, $country; //Class Constructor function fedexwebservices() { global $order, $vendors_id; @[member='definedmedia']('MODULE_SHIPPING_FEDEX_WEB_SERVICES_INSURE_' . $vendors_id, 0); $this->code = "fedexwebservices"; $this->title = MODULE_SHIPPING_FEDEX_WEB_SERVICES_TEXT_TITLE; $this->description = MODULE_SHIPPING_FEDEX_WEB_SERVICES_TEXT_DESCRIPTION; // $this->sort_order = MODULE_SHIPPING_FEDEX_WEB_SERVICES_SORT_ORDER_ . $vendors_id; // $this->handling_fee = MODULE_SHIPPING_FEDEX_WEB_SERVICES_HANDLING_FEE; $this->icon = DIR_WS_ICONS . 'shipping_fedex.gif'; // $this->enabled = ((MODULE_SHIPPING_FEDEX_WEB_SERVICES_STATUS == 'true') ? true : false); // $this->tax_class = MODULE_SHIPPING_FEDEX_WEB_SERVICES_TAX_CLASS; // $this->fedex_key = MODULE_SHIPPING_FEDEX_WEB_SERVICES_KEY; // $this->fedex_pwd = MODULE_SHIPPING_FEDEX_WEB_SERVICES_PWD; // $this->fedex_act_num = MODULE_SHIPPING_FEDEX_WEB_SERVICES_ACT_NUM; // $this->fedex_meter_num = MODULE_SHIPPING_FEDEX_WEB_SERVICES_METER_NUM; $vendors_data_query = tep_db_query("select handling_charge, handling_per_box, vendor_country, vendors_zipcode from " . TABLE_VENDORS . " where vendors_id = '" . (int)$vendors_id . "'" ); $vendors_data = tep_db_fetch_array($vendors_data_query); $country_name = tep_get_countries($vendors_data['vendor_country'], true); if (isset($vendors_data['vendor_country']) && $vendors_data['vendor_country'] != '') { $countries_array = tep_get_countries($vendors_data['vendor_country'], true); $this->country = $countries_array['countries_iso_code_2']; } else { $countries_array = tep_get_countries(SHIPPING_ORIGIN_COUNTRY, true); $this->country = STORE_ORIGIN_COUNTRY; } if ( ($this->enabled == true) && (int)constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_ZONE_' . $vendors_id > 0) ) { $check_flag = false; $check_query = tep_db_query ("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . (int)constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_ZONE_' . $vendors_id) . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id"); while( $check = tep_db_fetch_array($check_query)) { if ($check ['zone_id'] < 1) { $check_flag = true; break; } elseif ($check ['zone_id'] == $order->delivery['zone_id']) { $check_flag = true; break; } } } if ($check_flag == false) { $this->enabled = false; } } } function handling_fee($vendors_id='1') { $this->handling_fee = constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_HANDLING_FEE_' . $vendors_id); return $this->handling_fee; } function enabled($vendors_id='1') { $this->enabled = false; $status = @[member='constant']('MODULE_SHIPPING_FEDEX_WEB_SERVICES_TABLE_STATUS_' . $vendors_id); if (isset ($status) && $status != '') { $this->enabled = (($status == 'True') ? true : false); } if ( ($this->enabled == true) && ((int)constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_ZONE_' . $vendors_id) > 0) ) { $check_flag = false; $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . (int)constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_ZONE_' . $vendors_id) . "' and zone_country_id = '" . $this->delivery_country_id . "' order by zone_id"); while ($check = tep_db_fetch_array($check_query)) { if ($check['zone_id'] < 1) { $check_flag = true; break; } elseif ($check['zone_id'] == $this->delivery_zone_id) { $check_flag = true; break; } } if ($check_flag == false) { $this->enabled = false; }//if }//if return $this->enabled; } function tax_class($vendors_id='1') { $this->tax_class = constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_TABLE_TAX_CLASS_' . $vendors_id); return $this->tax_class; } function fedex_key($vendors_id='1') { $this->fedex_key = constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_KEY_' . $vendors_id); return $this->fedex_key; } function fedex_pwd($vendors_id='1') { $this->fedex_pwd = constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_PWD_' . $vendors_id); return $this->fedex_pwd; } function fedex_act_num($vendors_id='1') { $this->fedex_act_num = constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_ACT_NUM_' . $vendors_id); return $this->fedex_act_num; } function fedex_meter_num($vendors_id='1') { $this->fedex_meter_num = constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_METER_NUM_' . $vendors_id); return $this->fedex_meter_num; } function zones($vendors_id='1') { if ( ($this->enabled == true) && ((int)constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_TABLE_ZONE_' . $vendors_id) > 0) ) { $check_flag = false; $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . (int)constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_TABLE_ZONE_' . $vendors_id) . "' and zone_country_id = '" . $this->delivery_country_id . "' order by zone_id"); while ($check = tep_db_fetch_array($check_query)) { if ($check['zone_id'] < 1) { $check_flag = true; break; // } elseif ($check['zone_id'] == $order->delivery['zone_id']) { } elseif ($check['zone_id'] == $this->delivery_zone_id) { $check_flag = true; break; } //if }//while if ($check_flag == false) { $this->enabled = false; }//if }//if return $this->enabled; }//function function sort_order($vendors_id='1') { $sort_order = @[member='constant'] ('MODULE_SHIPPING_FEDEX_WEB_SERVICES_TABLE_SORT_ORDER_' . $vendors_id); if (tep_not_null($sort_order)) { $this->sort_order = $sort_order; } else { $this->sort_order = '-'; } return $this->sort_order; } // class methods function quote($method = '', $module = '', $vendors_id = '1') { /* FedEx integration starts */ global $shipping_weight, $shipping_num_boxes, $cart, $order; require_once(DIR_FS_CATALOG . DIR_WS_INCLUDES . 'library/fedex-common.php5'); //if (MODULE_SHIPPING_FEDEX_WEB_SERVICES_SERVER == 'test') { //$request['Version'] = array('ServiceId' => 'crs', 'Major' => '7', 'Intermediate' => '0', 'Minor' => '0'); //$path_to_wsdl = DIR_WS_INCLUDES . "wsdl/RateService_v7_test.wsdl"; //} else { $path_to_wsdl = DIR_FS_CATALOG . DIR_WS_INCLUDES . "wsdl/RateService_v9.wsdl"; //} ini_set("soap.wsdl_cache_enabled", "0"); $client = new SoapClient($path_to_wsdl, array('trace' => 1)); $this->types = array(); if (constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_PRIORITY_' . $vendors_id) == 'true') { $this->types['INTERNATIONAL_PRIORITY'] = array('icon' => '', 'handling_fee' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_EXPRESS_HANDLING_FEE_' . $vendors_id)); $this->types['EUROPE_FIRST_INTERNATIONAL_PRIORITY'] = array('icon' => '', 'handling_fee' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_EXPRESS_HANDLING_FEE_' . $vendors_id)); } if (constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_ECONOMY_' . $vendors_id) == 'true') { $this->types['INTERNATIONAL_ECONOMY'] = array('icon' => '', 'handling_fee' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_EXPRESS_HANDLING_FEE_' . $vendors_id)); } if (constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_STANDARD_OVERNIGHT_' . $vendors_id) == 'true') { $this->types['STANDARD_OVERNIGHT'] = array('icon' => '', 'handling_fee' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_' . $vendors_id)); } if (constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_FIRST_OVERNIGHT_' . $vendors_id) == 'true') { $this->types['FIRST_OVERNIGHT'] = array('icon' => '', 'handling_fee' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_' . $vendors_id)); } if (constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_PRIORITY_OVERNIGHT_' . $vendors_id) == 'true') { $this->types['PRIORITY_OVERNIGHT'] = array('icon' => '', 'handling_fee' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_' . $vendors_id)); } if (constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_2DAY_' . $vendors_id) == 'true') { $this->types['FEDEX_2_DAY'] = array('icon' => '', 'handling_fee' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_' . $vendors_id)); } // because FEDEX_GROUND also is returned for Canadian Addresses, we need to check if the country matches the store country and whether international ground is enabled if (constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_GROUND_' . $vendors_id) == 'true' && ($order->delivery['country']['id'] == STORE_COUNTRY) || constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_GROUND_' . $vendors_id) == 'true' && ($order->delivery['country']['id'] != STORE_COUNTRY) && (constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_GROUND_' . $vendors_id) == 'true')) { $this->types['FEDEX_GROUND'] = array('icon' => '', 'handling_fee' => ($order->delivery['country']['id'] == STORE_COUNTRY ? constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_HANDLING_FEE_' . $vendors_id) : constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_HANDLING_FEE_' . $vendors_id))); $this->types['GROUND_HOME_DELIVERY'] = array('icon' => '', 'handling_fee' => ($order->delivery['country']['id'] == STORE_COUNTRY ? constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_HOME_DELIVERY_HANDLING_FEE_' . $vendors_id) : constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_HANDLING_FEE_' . $vendors_id))); } if (constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_GROUND_' . $vendors_id) == 'true') { $this->types['INTERNATIONAL_GROUND'] = array('icon' => '', 'handling_fee' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_HANDLING_FEE_' . $vendors_id)); } if (constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_SAVER_' . $vendors_id) == 'true') { $this->types['FEDEX_EXPRESS_SAVER'] = array('icon' => '', 'handling_fee' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_' . $vendors_id)); } if (constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_FREIGHT_' . $vendors_id) == 'true') { $this->types['FEDEX_FREIGHT'] = array('icon' => '', 'handling_fee' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_' . $vendors_id)); $this->types['FEDEX_NATIONAL_FREIGHT'] = array('icon' => '', 'handling_fee' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_' . $vendors_id)); $this->types['FEDEX_1_DAY_FREIGHT'] = array('icon' => '', 'handling_fee' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_' . $vendors_id)); $this->types['FEDEX_2_DAY_FREIGHT'] = array('icon' => '', 'handling_fee' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_' . $vendors_id)); $this->types['FEDEX_3_DAY_FREIGHT'] = array('icon' => '', 'handling_fee' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_' . $vendors_id)); $this->types['INTERNATIONAL_ECONOMY_FREIGHT'] = array('icon' => '', 'handling_fee' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_EXPRESS_HANDLING_FEE_' . $vendors_id)); $this->types['INTERNATIONAL_PRIORITY_FREIGHT'] = array('icon' => '', 'handling_fee' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_EXPRESS_HANDLING_FEE_' . $vendors_id)); } // $this->types[] = 'SMART_POST'; // customer details $street_address = $order->delivery['street_address']; $street_address2 = $order->delivery['suburb']; $city = $order->delivery['city']; $state = tep_get_zone_code($order->delivery['country']['id'], $order->delivery['zone_id'], ''); if ($state == "QC") $state = "PQ"; $postcode = str_replace(array(' ', '-'), '', $order->delivery['postcode']); $country_id = $order->delivery['country']['iso_code_2']; $totals = $cart->show_total(); $totals = $cart->vendor_shipping[$vendors_id]['subtotal']; $this->_setInsuranceValue($totals / $shipping_num_boxes, $vendors_id); $request['WebAuthenticationDetail'] = array('UserCredential' => array('Key' => $this->fedex_key, 'Password' => $this->fedex_pwd)); $request['ClientDetail'] = array('AccountNumber' => $this->fedex_act_num, 'MeterNumber' => $this->fedex_meter_num); $request['TransactionDetail'] = array('CustomerTransactionId' => ' *** Rate Request v9 using PHP ***'); // $request['RequestedShipment']['SmartPostDetail'] = array( // 'Indicia' => 'MEDIA_MAIL', // 'AncillaryEndorsement' => 'CARRIER_LEAVE_IF_NO_RESPONSE', // 'SpecialServices' => 'USPS_DELIVERY_CONFIRMATION', // 'HubId' => '5254', // 'CustomerManifestId' => 1101); // $request['RequestedShipment']['ServiceType'] = 'SMART_POST'; $request['Version'] = array('ServiceId' => 'crs', 'Major' => '9', 'Intermediate' => '0', 'Minor' => '0'); $request['ReturnTransitAndCommit'] = true; $request['RequestedShipment']['DropoffType'] = $this->_setDropOff(); // valid values REGULAR_PICKUP, REQUEST_COURIER, ... $request['RequestedShipment']['ShipTimestamp'] = date('c'); $request['RequestedShipment']['PackagingType'] = 'YOUR_PACKAGING'; // valid values FEDEX_BOX, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ... $request['RequestedShipment']['TotalInsuredValue']=array('Ammount'=> $this->insurance, 'Currency' => $_SESSION['currency']); $request['WebAuthenticationDetail'] = array('UserCredential' => array('Key' => $this->fedex_key, 'Password' => $this->fedex_pwd)); $request['ClientDetail'] = array('AccountNumber' => $this->fedex_act_num, 'MeterNumber' => $this->fedex_meter_num); // print_r($request['WebAuthenticationDetail']); // print_r($request['ClientDetail']); // exit; $request['RequestedShipment']['Shipper'] = array('Address' => array( 'StreetLines' => array (constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_ADDRESS_1_' . $vendors_id), constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_ADDRESS_2_' . $vendors_id))), // Origin details 'City' => MODULE_SHIPPING_FEDEX_WEB_SERVICES_CITY, 'StateOrProvinceCode' => MODULE_SHIPPING_FEDEX_WEB_SERVICES_STATE, 'PostalCode' => MODULE_SHIPPING_FEDEX_WEB_SERVICES_POSTAL, 'CountryCode' => $this->country); $request['RequestedShipment']['Recipient'] = array('Address' => array ( 'StreetLines' => array($street_address, $street_address2), // customer street address 'City' => $city, //customer city // 'StateOrProvinceCode' => $state, //customer state 'PostalCode' => $postcode, //customer postcode 'CountryCode' => $country_id, 'Residential' => ($order->delivery['company'] != '' ? false : true))); //customer county code if (in_array($country_id, array('US', 'CA'))) { $request['RequestedShipment']['Recipient']['StateOrProvinceCode'] = $state; } // print_r($request['RequestedShipment']['Recipient']) ; // exit; $request['RequestedShipment']['ShippingChargesPayment'] = array('PaymentType' => 'SENDER', 'Payor' => array('AccountNumber' => $this->fedex_act_num, // payor's account number 'CountryCode' => $this->country)); $request['RequestedShipment']['RateRequestTypes'] = 'LIST'; $request['RequestedShipment']['PackageDetail'] = 'INDIVIDUAL_PACKAGES'; $request['RequestedShipment']['RequestedPackageLineItems'] = array(); $dimensions_failed = false; if (count($packages) > 1) { $za_tare_array = preg_split("/[:,]/" , SHIPPING_BOX_WEIGHT); $zc_tare_percent= $za_tare_array[0]; $zc_tare_weight= $za_tare_array[1]; $za_large_array = preg_split("/[:,]/" , SHIPPING_BOX_PADDING); $zc_large_percent= $za_large_array[0]; $zc_large_weight= $za_large_array[1]; } foreach ($packages as $id => $values) { if ($id === 'default') { // divide the weight by the max amount to be shipped (can be done inside loop as this occurance should only ever happen once // note $values is not an array if ($values == 0) continue; $shipping_num_boxes = ceil((float)$values / (float)SHIPPING_MAX_WEIGHT); if ($shipping_num_boxes < 1) $shipping_num_boxes = 1; $shipping_weight = round((float)$values / $shipping_num_boxes, 2); // 2 decimal places max for ($i=0; $i<$shipping_num_boxes; $i++) { $new_shipping_num_boxes++; if (SHIPPING_MAX_WEIGHT <= $shipping_weight) { $shipping_weight = $shipping_weight + ($shipping_weight*($zc_large_percent/100)) + $zc_large_weight; } else { $shipping_weight = $shipping_weight + ($shipping_weight*($zc_tare_percent/100)) + $zc_tare_weight; } if ($shipping_weight <= 0) $shipping_weight = 0.1; $new_shipping_weight += $shipping_weight; $request['RequestedShipment']['RequestedPackageLineItems'][] = array('Weight' => array('Value' => $shipping_weight, 'Units' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_WEIGHT_' . $vendors_id)) ); } } else { // note $values is an array $new_shipping_num_boxes++; if ($values['weight'] <= 0) $values['weight'] = 0.1; $new_shipping_weight += $values['weight']; $request['RequestedShipment']['RequestedPackageLineItems'][] = array('Weight' => array('Value' => $values['weight'], 'Units' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_WEIGHT_' . $vendors_id)) ); } } $shipping_num_boxes = $new_shipping_num_boxes; If (!$shipping_num_boxes || $shipping_num_boxes == 0) { $shipping_num_boxes = 1; } $shipping_weight = round($new_shipping_weight / $shipping_num_boxes, 2); $request['RequestedShipment']['RequestedPackageLineItems'][] = array('Weight' => array('Value' => $shipping_weight, 'Units' => constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_WEIGHT_' . $vendors_id))); } $request['RequestedShipment']['PackageCount'] = $shipping_num_boxes; if (constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_SATURDAY_' . $vendors_id) == 'true') { $request['RequestedShipment']['ServiceOptionType'] = 'SATURDAY_DELIVERY'; } if (constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_SIGNATURE_OPTION_' . $vendors_id)>= 0 && $totals >= MODULE_SHIPPING_FEDEX_WEB_SERVICES_SIGNATURE_OPTION) { $request['RequestedShipment']['SpecialServicesRequested'] = 'SIGNATURE_OPTION'; } // echo '<!-- shippingWeight: ' . $shipping_weight . ' ' . $shipping_num_boxes . ' -->'; // echo '<!-- '; // echo '<pre>'; // print_r($request); // echo '</pre>'; // echo ' -->'; $response = $client->getRates($request); // echo '<!-- '; // echo '<pre>'; // print_r($response); // echo '</pre>'; // echo ' -->'; if ($response->HighestSeverity != 'FAILURE' && $response->HighestSeverity != 'ERROR' && is_array($response->RateReplyDetails) || is_object($response->RateReplyDetails)) { if (is_object($response->RateReplyDetails)) { $response->RateReplyDetails = get_object_vars($response->RateReplyDetails); } // echo '<pre>'; // print_r($response->RateReplyDetails); // echo '</pre>'; $show_box_weight = " (Total items: " . $shipping_num_boxes . ' pcs. Total weight: '.number_format($shipping_weight * $shipping_num_boxes,2).' '.strtolower ('MODULE_SHIPPING_FEDEX_WEB_SERVICES_WEIGHT_' . $vendors_id).'s.)'; $this->quotes = array('id' => $this->code, 'module' => $this->title . $show_box_weight, 'info' => $this->info($vendors_id)); // echo '<pre>'; // print_r($response->RateReplyDetails); // echo '</pre>'; // EXIT(); $methods = array(); // echo '<pre>'; // print_r($this->types); // echo '</pre>'; foreach ($response->RateReplyDetails as $rateReply) { if (array_key_exists($rateReply->ServiceType, $this->types) && ($method == '' || str_replace('_', '', $rateReply->ServiceType) == $method)) { if (constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_RATES_' . $vendors_id)=='LIST') { foreach($rateReply->RatedShipmentDetails as $ShipmentRateDetail) { if($ShipmentRateDetail->ShipmentRateDetail->RateType=='PAYOR_LIST_PACKAGE') { $cost = $ShipmentRateDetail->ShipmentRateDetail->TotalNetCharge->Amount; $cost = (float)round(preg_replace('/[^0-9.]/', '', $cost), 2); } } } else { $cost = $rateReply->RatedShipmentDetails[0]->ShipmentRateDetail->TotalNetCharge->Amount; $cost = (float)round(preg_replace('/[^0-9.]/', '', $cost), 2); } if (in_array($rateReply->ServiceType, array('GROUND_HOME_DELIVERY', 'FEDEX_GROUND', 'INTERNATIONAL_GROUND'))) { // print_r($rateReply); $transitTime = ' (' . str_replace(array('_', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteeen'), array(' ', 1,2,3,4,5,6,7,8,9,10,11,12,13,14), strtolower($rateReply->TransitTime)) . ')'; } $methods[] = array('id' => str_replace('_', '', $rateReply->ServiceType), 'title' => ucwords(strtolower(str_replace('_', ' ', $rateReply->ServiceType))) . $transitTime, 'cost' => $cost + (strpos($this->types[$rateReply->ServiceType]['handling_fee'], '%') ? ($cost * (float)$this->types[$rateReply->ServiceType]['handling_fee'] / 100) : (float)$this->types[$rateReply->ServiceType]['handling_fee'])); } } // usort($methods, 'cmp'); $this->quotes['methods'] = $methods; if ($this->tax_class($vendors_id) > 0) { $this->quotes['tax'] = tep_get_tax_rate($this->tax_class($vendors_id), $order->delivery['country']['id'], $order->delivery['zone_id']); } } else { $message = 'Error in processing transaction.<br /><br />'; foreach ($response -> Notifications as $notification) { if(is_array($response -> Notifications)) { $message .= $notification->Severity; $message .= ': '; $message .= $notification->Message . '<br />'; } else { $message .= $notification->Message . '<br />'; } } $vendors_data_query = tep_db_query("select handling_charge, handling_per_box, vendor_country, vendors_zipcode from " . TABLE_VENDORS . " where vendors_id = '" . (int)$vendors_id . "'" ); $vendors_data = tep_db_fetch_array($vendors_data_query); $country_name = tep_get_countries($vendors_data['vendor_country'], true); if (isset($vendors_data['vendor_country']) && $vendors_data['vendor_country'] != '') { $countries_array = tep_get_countries($vendors_data['vendor_country'], true); $this->country = $countries_array['countries_iso_code_2']; } else { $countries_array = tep_get_countries(SHIPPING_ORIGIN_COUNTRY, true); $this->country = STORE_ORIGIN_COUNTRY; } // $vendors_data = tep_db_fetch_array($vendors_data_query); $handling_charge = $vendors_data['handling_charge']; $handling_per_box = $vendors_data['handling_per_box']; if ($handling_charge > $handling_per_box * $shipping_num_boxes) { $handling = $handling_charge; } else { $handling = $handling_per_box * $shipping_num_boxes; } $this->quotes = array('module' => $this->title, 'error' => $message); // po box hack by JD if (eregi("^P(.+)O(.+)BOX",$order->delivery['street_address']) ||eregi("^PO BOX",$order->delivery['street_address']) || eregi("^P(.+)O(.+)BOX",$order->delivery['suburb']) || eregi("^[A-Z]PO",$order->delivery['street_address']) || eregi("^[A-Z]PO",$order->delivery['suburb'])) { $this->quotes = array('module' => $this->title, 'error' => '<font size=+2 color=red><b>Federal Express cannot ship to Post Office Boxes.<b></font><br>Use the Change Address button above to use a FedEx accepted street address.'); } // end po box hack by JD if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title); // echo '<!-- Quotes: '; // print_r($this->quotes); // print_r($_SESSION['shipping']); // echo ' -->'; return $this->quotes; } function cmp($a, $b, $vendors_id) { if ($a['cost'] == $b['cost']) { return 0; } return ($a['cost'] < $b['cost']) ? -1 : 1; } // method added for expanded info in FEAC function info($vendors_id) { return MODULE_SHIPPING_FEDEX_WEB_SERVICES_INFO; // add a description here or leave blank to disable } function _setInsuranceValue($order_amount, $vendors_id = '1'){ if ($order_amount > constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_INSURE_' . $vendors_id)) { $this->insurance = sprintf("%01.2f", $order_amount); } else { $this->insurance = 0; } } function objectToArray($object, $vendors_id) { if( !is_object( $object ) && !is_array( $object ) ) { return $object; } if( is_object( $object ) ) { $object = get_object_vars( $object ); } return array_map( 'objectToArray', $object ); } function _setDropOff($vendors_id) { switch(MODULE_SHIPPING_FEDEX_WEB_SERVICES_DROPOFF) { case '1': return 'REGULAR_PICKUP'; break; case '2': return 'REQUEST_COURIER'; break; case '3': return 'DROP_BOX'; break; case '4': return 'BUSINESS_SERVICE_CENTER'; break; case '5': return 'STATION'; break; } } //MVS function check($vendors_id='1') { if(!isset($this->_check)){ //multi vendor add "vendors_id = '". $vendors_id ."' and" $check_query = tep_db_query("SELECT configuration_value FROM ". TABLE_VENDOR_CONFIGURATION ." WHERE configuration_key = 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_STATUS_" . $vendors_id . "' and vendors_id = '" . $vendors_id . "'"); $this->_check = tep_db_num_rows ($check_query); } return $this->_check; } function install($vendors_id='1') { tep_db_query("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) VALUES ('Enable FedEx Web Services','MODULE_SHIPPING_FEDEX_WEB_SERVICES_STATUS_" . $vendors_id . "', 'true','Do you want to offer FedEx shipping?','6','0','tep_cfg_select_option(array(\'true\',\'false\'), ', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('FedEx Web Services Key', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_KEY_" . $vendors_id . "', '', 'Enter FedEx Web Services Key', '6', '3', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('FedEx Web Services Password', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_PWD_" . $vendors_id . "', '', 'Enter FedEx Web Services Password', '6', '3', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('FedEx Account Number', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_ACT_NUM_" . $vendors_id . "', '', 'Enter FedEx Account Number', '6', '3', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('FedEx Meter Number', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_METER_NUM_" . $vendors_id . "', '', 'Enter FedEx Meter Number', '6', '4', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Weight Units', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_WEIGHT_" . $vendors_id . "', 'LB', 'Weight Units:', '6', '10', 'tep_cfg_select_option(array(\'LB\', \'KG\'), ', now())"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('First line of street address', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_ADDRESS_1_" . $vendors_id . "', '', 'Enter the first line of your ship-from street address, required', '6', '20', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Second line of street address', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_ADDRESS_2_" . $vendors_id . "', '', 'Enter the second line of your ship-from street address, leave blank if you do not need to specify a second line', '6', '21', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('City name', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_CITY_" . $vendors_id . "', '', 'Enter the city name for the ship-from street address, required', '6', '22', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('State or Province name', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_STATE_" . $vendors_id . "', '', 'Enter the 2 letter state or province name for the ship-from street address, required for Canada and US', '6', '23', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Postal code', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_POSTAL_" . $vendors_id . "', '', 'Enter the postal code for the ship-from street address, required', '6', '24', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Phone number', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_PHONE_" . $vendors_id . "', '', 'Enter a contact phone number for your company, required', '6', '25', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Drop off type', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_DROPOFF_" . $vendors_id . "', '1', 'Dropoff type (1 = Regular pickup, 2 = request courier, 3 = drop box, 4 = drop at BSC, 5 = drop at station)?', '6', '30', 'tep_cfg_select_option(array(\'1\',\'2\',\'3\',\'4\',\'5\'),', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable Express Saver', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_SAVER_" . $vendors_id . "', 'true', 'Enable FedEx Express Saver', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable Standard Overnight', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_STANDARD_OVERNIGHT_" . $vendors_id . "', 'true', 'Enable FedEx Express Standard Overnight', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable First Overnight', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_FIRST_OVERNIGHT_" . $vendors_id . "', 'true', 'Enable FedEx Express First Overnight', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable Priority Overnight', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_PRIORITY_OVERNIGHT_" . $vendors_id . "', 'true', 'Enable FedEx Express Priority Overnight', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable 2 Day', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_2DAY_" . $vendors_id . "', 'true', 'Enable FedEx Express 2 Day', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable International Priority', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_PRIORITY_" . $vendors_id . "', 'true', 'Enable FedEx Express International Priority', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable International Economy', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_ECONOMY_" . $vendors_id . "', 'true', 'Enable FedEx Express International Economy', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable Ground', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_GROUND_" . $vendors_id . "', 'true', 'Enable FedEx Ground', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable International Ground', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_GROUND_" . $vendors_id . "', 'true', 'Enable FedEx International Ground', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable Freight', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_FREIGHT_" . $vendors_id . "', 'true', 'Enable FedEx Freight', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable Saturday Delivery', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_SATURDAY_" . $vendors_id . "', 'false', 'Enable Saturday Delivery', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Domestic Ground Handling Fee', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_HANDLING_FEE_" . $vendors_id . "', '', 'Add a domestic handling fee or leave blank (example: 15 or 15%)', '6', '25', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Home Delivery Handling Fee', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_HOME_DELIVERY_HANDLING_FEE_" . $vendors_id . "', '', 'Add a home delivery handling fee or leave blank (example: 15 or 15%)', '6', '25', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Domestic Express Handling Fee', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_" . $vendors_id . "', '', 'Add a domestic handling fee or leave blank (example: 15 or 15%)', '6', '25', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('International Ground Handling Fee', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_HANDLING_FEE_" . $vendors_id . "', '', 'Add an international handling fee or leave blank (example: 15 or 15%)', '6', '25', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('International Express Handling Fee', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_EXPRESS_HANDLING_FEE_" . $vendors_id . "', '', 'Add an international handling fee or leave blank (example: 15 or 15%)', '6', '25', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) VALUES ('FedEx Rates','MODULE_SHIPPING_FEDEX_WEB_SERVICES_RATES_" . $vendors_id . "','LIST','FedEx Rates','6','0','tep_cfg_select_option(array(\'LIST\',\'ACCOUNT\'),',now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Signature Option', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_SIGNATURE_OPTION_" . $vendors_id . "', '-1', 'Require a signature on orders greater than or equal to (set to -1 to disable):', '6', '25', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable Ready to Ship', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_READY_TO_SHIP_" . $vendors_id . "', 'false', 'Enable products_ship_sep or products_ready_to_ship field (required to identify products which ship separately', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added, vendors_id) values ('Shipping Zone', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_ZONE_" . $vendors_id . "', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '98', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added, vendors_id) values ('Tax Class', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_TAX_CLASS_" . $vendors_id . "', '0', 'Use the following tax class on the shipping fee.', '6', '25', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now(), '" . $vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Sort Order', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_SORT_ORDER_" . $vendors_id . "', '0', 'Sort order of display.', '6', '99', now(), '" . $vendors_id . "')"); } function remove($vendors_id) { tep_db_query("delete from " . TABLE_VENDOR_CONFIGURATION . " where vendors_id = '". $vendors_id ."' and configuration_key in ('" . implode("', '", $this->keys($vendors_id)) . "')"); } function keys($vendors_id) { return array('MODULE_SHIPPING_FEDEX_WEB_SERVICES_STATUS_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_KEY_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_PWD_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_ACT_NUM_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_METER_NUM_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_WEIGHT_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_ADDRESS_1_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_ADDRESS_2_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_CITY_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_STATE_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_POSTAL_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_PHONE_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_DROPOFF_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_SAVER_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_STANDARD_OVERNIGHT_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_FIRST_OVERNIGHT_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_PRIORITY_OVERNIGHT_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_2DAY_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_PRIORITY_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_ECONOMY_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_GROUND_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_FREIGHT_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_GROUND_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_SATURDAY_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_TAX_CLASS_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_HANDLING_FEE_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_HOME_DELIVERY_HANDLING_FEE_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_HANDLING_FEE_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INSURE_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_EXPRESS_HANDLING_FEE_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_RATES_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_SIGNATURE_OPTION_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_READY_TO_SHIP_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_ZONE_' . $vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_SORT_ORDER_' . $vendors_id); } function get_countries($countries_id = '', $vendors_id, $with_iso_codes = false) { $countries_array = array(); if (tep_not_null($countries_id)) { if ($with_iso_codes == true) { $countries = tep_db_query("select countries_name, countries_iso_code_2, countries_iso_code_3 from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$countries_id . "' order by countries_name"); $countries_values = tep_db_fetch_array($countries); $countries_array = array('countries_name' => $countries_values['countries_name'], 'countries_iso_code_2' => $countries_values['countries_iso_code_2'], 'countries_iso_code_3' => $countries_values['countries_iso_code_3']); } else { $countries = tep_db_query("select countries_name from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$countries_id . "'"); $countries_values = tep_db_fetch_array($countries); $countries_array = array('countries_name' => $countries_values['countries_name']); } } else { $countries = tep_db_query("select countries_id, countries_name from " . TABLE_COUNTRIES . " order by countries_name"); while ($countries_values = tep_db_fetch_array($countries)) { $countries_array[] = array('countries_id' => $countries_values['countries_id'], 'countries_name' => $countries_values['countries_name']); } } return $countries_array; } ?> Quote Link to comment Share on other sites More sharing options...
Guest Posted July 5, 2012 Share Posted July 5, 2012 Still haven't figured this out. Anyone get it to work? Quote Link to comment Share on other sites More sharing options...
♥kymation Posted July 5, 2012 Share Posted July 5, 2012 This line will not work: @[member='definedmedia']('MODULE_SHIPPING_FEDEX_WEB_SERVICES_INSURE_' . $vendors_id, 0); $vendors_id is not available in the class constructor. You'll need to define that in a separate method. The first part looks suspicious as well. Forum artifact? I don't have time to look at the rest. Too much code, too little time.... Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
Guest Posted July 22, 2012 Share Posted July 22, 2012 This is getting rediculous. I can't get this file to work. Did a search online and found a company that is selling the code for $185.00! Just one file! So much for open source. I can't believe more people aren't asking for this addon for fedex webservices. Quote Link to comment Share on other sites More sharing options...
Guest Posted July 22, 2012 Share Posted July 22, 2012 Heres the corrected code for fedexwebservices.php After much searching, found the mod in creloaded. I modded it to work with RC2.2a. <?php /* FedEx Webservice Version 9.4.2 for osCommerce 2.2rc2a and later(?) -by Roaddoctor 5/20/2012 New contributed code and the hard work credit to Jeff Lew. Thanks Jeff and Numinex! $Loc: catalog/includes/modules/vendors_shipping/ $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Released under the GNU General Public License */ class fedexwebservices { var $code, $title, $description, $icon, $sort_order, $enabled, $tax_class, $fedex_key, $fedex_pwd, $fedex_act_num, $fedex_meter_num, $country; //Class Constructor function fedexwebservices() { global $order, $customer_id; $this->vendors_id = (isset($_GET['vendors_id']) && !empty($_GET['vendors_id'])) ? (int)$_GET['vendors_id'] : NULL; $this->code = "fedexwebservices"; $this->title = MODULE_SHIPPING_FEDEX_WEB_SERVICES_TEXT_TITLE; $this->handling_fee = MODULE_SHIPPING_FEDEX_WEB_SERVICES_HANDLING_FEE; $this->icon = DIR_WS_ICONS . 'shipping_fedex.gif'; $this->ok_to_install = (@[member='Extension']_loaded('soap')) ? TRUE : FALSE; if ($this->ok_to_install) { $this->description = MODULE_SHIPPING_FEDEX_WEB_SERVICES_TEXT_DESCRIPTION; } else { $this->description = MODULE_SHIPPING_FEDEX_WEB_SERVICES_TEXT_NO_SOAP_DESCRIPTION; } if (defined("SHIPPING_ORIGIN_COUNTRY")) { if ((int)SHIPPING_ORIGIN_COUNTRY > 0) { $countries_array = $this->get_countries(SHIPPING_ORIGIN_COUNTRY, true); $this->country = $countries_array['countries_iso_code_2']; } else { $this->country = SHIPPING_ORIGIN_COUNTRY; } } else { $this->country = STORE_ORIGIN_COUNTRY; } $this->delivery_country_id = $order->delivery['country']['id']; $this->delivery_zone_id = $order->delivery['zone_id']; } // MVS ADD function sort_order($vendors_id = '1') { $sort_order = @[member='constant'] ('MODULE_SHIPPING_FEDEX_WEB_SERVICES_SORT_ORDER_' . $vendors_id); if (isset ($sort_order)) { $this->sort_order = $sort_order; } else { $this->sort_order = ''; } return $this->sort_order; } function tax_class($vendors_id = '1') { $this->tax_class = constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_TAX_CLASS_' . $vendors_id); return $this->tax_class; } function enabled($vendors_id = '1') { $this->enabled = false; $status = @[member='constant']('MODULE_SHIPPING_FEDEX_WEB_SERVICES_STATUS_' . $vendors_id); if (isset ($status) && $status != '') { $this->enabled = (($status == 'true') ? true : false); } if ( ($this->enabled == true) && ((int)constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_ZONE_' . $vendors_id) > 0) ) { $check_flag = false; $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . (int)constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_ZONE_' . $vendors_id) . "' and zone_country_id = '" . $this->delivery_country_id . "' order by zone_id"); while ($check = tep_db_fetch_array($check_query)) { if ($check['zone_id'] < 1) { $check_flag = true; break; } elseif ($check['zone_id'] == $this->delivery_zone_id) { $check_flag = true; break; } } if ($check_flag == false) { $this->enabled = false; } } return $this->enabled; } function zones($vendors_id = '1') { if ( ($this->enabled == true) && ((int)constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_ZONE_' . $vendors_id) > 0) ) { $check_flag = false; $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . (int)constant('MODULE_SHIPPING_FEDEX_WEB_SERVICES_ZONE_' . $vendors_id) . "' and zone_country_id = '" . $this->delivery_country_id . "' order by zone_id"); while ($check = tep_db_fetch_array($check_query)) { if ($check['zone_id'] < 1) { $check_flag = true; break; } elseif ($check['zone_id'] == $this->delivery_zone_id) { $check_flag = true; break; } } if ($check_flag == false) { $this->enabled = false; } } return $this->enabled; } // Get the quote from Fedex API function quote($method = '', $module = '', $vendors_id = '1') { global $shipping_weight, $shipping_num_boxes, $cart, $order; $this->vendors_id = $vendors_id; $this->weight_type = @[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_WEIGHT_ . $this->vendors_id); $this->fedex_key = @[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_KEY_ . $this->vendors_id); $this->fedex_pwd = @[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_PWD_ . $this->vendors_id); $this->fedex_act_num = @[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_ACT_NUM_ . $this->vendors_id); $this->fedex_meter_num = @[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_METER_NUM_ . $this->vendors_id); @[member='definedmedia']('MODULE_SHIPPING_FEDEX_WEB_SERVICES_INSURE_' . $this->vendors_id, 0); if (defined('MODULE_SHIPPING_FEDEX_WEB_SERVICES_SERVER_' . $this->vendors_id) && @[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_SERVER_ . $this->vendors_id) == 'Test') { $path_to_wsdl = DIR_FS_CATALOG . 'includes/wsdl/RateService_v9_test.wsdl'; } else { $path_to_wsdl = DIR_FS_CATALOG . 'includes/wsdl/RateService_v9.wsdl'; } ini_set("soap.wsdl_cache_enabled", "0"); $client = new SoapClient($path_to_wsdl, array('trace' => 1)); $this->types = array(); if (@[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_PRIORITY_ . $this->vendors_id) == 'true') { $this->types['INTERNATIONAL_PRIORITY'] = array('icon' => '', 'handling_fee' => @[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_EXPRESS_HANDLING_FEE_ . $this->vendors_id)); $this->types['EUROPE_FIRST_INTERNATIONAL_PRIORITY'] = array('icon' => '', 'handling_fee' => @[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_EXPRESS_HANDLING_FEE_ . $this->vendors_id)); } if (@[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_ECONOMY_ . $this->vendors_id) == 'true') { $this->types['INTERNATIONAL_ECONOMY'] = array('icon' => '', 'handling_fee' => @[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_EXPRESS_HANDLING_FEE_ . $this->vendors_id)); } if (@[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_STANDARD_OVERNIGHT_ . $this->vendors_id) == 'true') { $this->types['STANDARD_OVERNIGHT'] = array('icon' => '', 'handling_fee' => @[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_ . $this->vendors_id)); } if (@[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_FIRST_OVERNIGHT_ . $this->vendors_id) == 'true') { $this->types['FIRST_OVERNIGHT'] = array('icon' => '', 'handling_fee' => @[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_ . $this->vendors_id)); } if (@[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_PRIORITY_OVERNIGHT_ . $this->vendors_id) == 'true') { $this->types['PRIORITY_OVERNIGHT'] = array('icon' => '', 'handling_fee' => @[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_ . $this->vendors_id)); } if (@[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_2DAY_ . $this->vendors_id) == 'true') { $this->types['FEDEX_2_DAY'] = array('icon' => '', 'handling_fee' => @[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_ . $this->vendors_id)); } // because FEDEX_GROUND also is returned for Canadian Addresses, we need to check if the country matches the store country and whether international ground is enabled if ((@[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_GROUND_ . $this->vendors_id) == 'true' && $order->delivery['country']['id'] == STORE_COUNTRY) || (@[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_GROUND_ . $this->vendors_id) == 'true' && ($order->delivery['country']['id'] != STORE_COUNTRY) && @[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_GROUND_ . $this->vendors_id) == 'true')) { $this->types['FEDEX_GROUND'] = array('icon' => '', 'handling_fee' => ($order->delivery['country']['id'] == STORE_COUNTRY ? @[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_HANDLING_FEE_ . $this->vendors_id) : @[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_HANDLING_FEE_ . $this->vendors_id))); $this->types['GROUND_HOME_DELIVERY'] = array('icon' => '', 'handling_fee' => ($order->delivery['country']['id'] == STORE_COUNTRY ? @[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_HOME_DELIVERY_HANDLING_FEE_ . $this->vendors_id) : @[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_HANDLING_FEE_ . $this->vendors_id))); } if (@[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_GROUND_ . $this->vendors_id) == 'true') { $this->types['INTERNATIONAL_GROUND'] = array('icon' => '', 'handling_fee' => @[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_HANDLING_FEE_ . $this->vendors_id)); } if (@[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_SAVER_ . $this->vendors_id) == 'true') { $this->types['FEDEX_EXPRESS_SAVER'] = array('icon' => '', 'handling_fee' => @[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_ . $this->vendors_id)); } if (@[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_FREIGHT_ . $this->vendors_id) == 'true') { $this->types['FEDEX_FREIGHT'] = array('icon' => '', 'handling_fee' => @[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_ . $this->vendors_id)); $this->types['FEDEX_NATIONAL_FREIGHT'] = array('icon' => '', 'handling_fee' => @[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_ . $this->vendors_id)); $this->types['FEDEX_1_DAY_FREIGHT'] = array('icon' => '', 'handling_fee' => @[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_ . $this->vendors_id)); $this->types['FEDEX_2_DAY_FREIGHT'] = array('icon' => '', 'handling_fee' => @[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_ . $this->vendors_id)); $this->types['FEDEX_3_DAY_FREIGHT'] = array('icon' => '', 'handling_fee' => @[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_ . $this->vendors_id)); $this->types['INTERNATIONAL_ECONOMY_FREIGHT'] = array('icon' => '', 'handling_fee' => @[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_EXPRESS_HANDLING_FEE_ . $this->vendors_id)); $this->types['INTERNATIONAL_PRIORITY_FREIGHT'] = array('icon' => '', 'handling_fee' => @[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_EXPRESS_HANDLING_FEE_ . $this->vendors_id)); } // customer details $street_address = $order->delivery['street_address']; $street_address2 = $order->delivery['suburb']; $city = $order->delivery['city']; $state = tep_get_zone_code($order->delivery['country']['id'], $order->delivery['zone_id'], ''); if ($state == "QC") $state = "PQ"; $postcode = str_replace(array(' ', '-'), '', $order->delivery['postcode']); //$country_id = $order->delivery['country']['iso_code_2']; $delivery_country_arr = $this->get_countries($this->delivery_country_id, true); $country_id = $delivery_country_arr['countries_iso_code_2']; $totals = $order->info['subtotal'] = $cart->total; $this->_setInsuranceValue($totals); $request['WebAuthenticationDetail'] = array('UserCredential' => array('Key' => $this->fedex_key, 'Password' => $this->fedex_pwd)); $request['ClientDetail'] = array('AccountNumber' => $this->fedex_act_num, 'MeterNumber' => $this->fedex_meter_num); $request['TransactionDetail'] = array('CustomerTransactionId' => ' *** Rate Request v9 using PHP ***'); $request['Version'] = array('ServiceId' => 'crs', 'Major' => '9', 'Intermediate' => '0', 'Minor' => '0'); $request['ReturnTransitAndCommit'] = true; $request['RequestedShipment']['DropoffType'] = $this->_setDropOff(); // valid values REGULAR_PICKUP, REQUEST_COURIER, ... $request['RequestedShipment']['ShipTimestamp'] = date('c'); $request['RequestedShipment']['PackagingType'] = 'YOUR_PACKAGING'; // valid values FEDEX_BOX, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ... $request['RequestedShipment']['TotalInsuredValue']=array('Ammount'=> $this->insurance, 'Currency' => $_SESSION['currency']); $request['WebAuthenticationDetail'] = array('UserCredential' => array('Key' => $this->fedex_key, 'Password' => $this->fedex_pwd)); $request['ClientDetail'] = array('AccountNumber' => $this->fedex_act_num, 'MeterNumber' => $this->fedex_meter_num); $request['RequestedShipment']['Shipper'] = array('Address' => array( 'StreetLines' => array(@[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_ADDRESS_1_ . $this->vendors_id), utf8_encode(@[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_ADDRESS_2_ . $this->vendors_id))), // Origin details 'City' => utf8_encode(@[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_CITY_ . $this->vendors_id)), 'StateOrProvinceCode' => @[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_STATE_ . $this->vendors_id), 'PostalCode' => @[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_POSTAL_ . $this->vendors_id), 'CountryCode' => $this->country)); $request['RequestedShipment']['Recipient'] = array('Address' => array ( 'StreetLines' => array(utf8_encode($street_address), utf8_encode($street_address2)), // customer street address 'City' => utf8_encode($city), //customer city 'PostalCode' => $postcode, //customer postcode 'CountryCode' => $country_id, 'Residential' => ($order->delivery['company'] != '' ? false : true))); //customer county code if (in_array($country_id, array('US', 'CA'))) { $request['RequestedShipment']['Recipient']['StateOrProvinceCode'] = $state; } $request['RequestedShipment']['ShippingChargesPayment'] = array('PaymentType' => 'SENDER', 'Payor' => array('AccountNumber' => $this->fedex_act_num, // payor's account number 'CountryCode' => $this->country)); $request['RequestedShipment']['RateRequestTypes'] = 'LIST'; $request['RequestedShipment']['PackageDetail'] = 'INDIVIDUAL_PACKAGES'; $request['RequestedShipment']['RequestedPackageLineItems'] = array(); $dimensions_failed = false; // default method for calculating number of packages if ($shipping_weight == 0) $shipping_weight = 0.1; for ($i=0; $i<$shipping_num_boxes; $i++) { $request['RequestedShipment']['RequestedPackageLineItems'][] = array('Weight' => array('Value' => $shipping_weight, 'Units' => @[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_WEIGHT_ . $this->vendors_id))); } $request['RequestedShipment']['PackageCount'] = $shipping_num_boxes; if (@[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_SATURDAY_ . $this->vendors_id)== 'true') { $request['RequestedShipment']['ServiceOptionType'] = 'SATURDAY_DELIVERY'; } if (@[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_SIGNATURE_OPTION_ . $this->vendors_id) >= 0 && $totals >= @[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_SIGNATURE_OPTION_ . $this->vendors_id)) { $request['RequestedShipment']['SpecialServicesRequested'] = 'SIGNATURE_OPTION'; } $response = $client->getRates($request); if ($response->HighestSeverity != 'FAILURE' && $response->HighestSeverity != 'ERROR' && is_array($response->RateReplyDetails) || is_object($response->RateReplyDetails)) { if (is_object($response->RateReplyDetails)) { $response->RateReplyDetails = get_object_vars($response->RateReplyDetails); } $show_box_weight = " (Total items: " . $shipping_num_boxes . ' pcs. Total weight: '.number_format($shipping_weight * $shipping_num_boxes,2).' '.strtolower($this->weight_type).'s)'; $this->quotes = array('id' => $this->code, 'module' => $this->title . $show_box_weight, 'info' => $this->info()); $methods = array(); foreach ($response->RateReplyDetails as $rateReply) { if (array_key_exists($rateReply->ServiceType, $this->types) && ($method == '' || str_replace('_', '', $rateReply->ServiceType) == $method)) { if(@[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_RATES_ . $this->vendors_id) == 'LIST') { foreach($rateReply->RatedShipmentDetails as $ShipmentRateDetail) { if($ShipmentRateDetail->ShipmentRateDetail->RateType=='PAYOR_LIST_PACKAGE') { $cost = $ShipmentRateDetail->ShipmentRateDetail->TotalNetCharge->Amount; $cost = (float)round(preg_replace('/[^0-9.]/', '', $cost), 2); } } } else { $cost = $rateReply->RatedShipmentDetails[0]->ShipmentRateDetail->TotalNetCharge->Amount; $cost = (float)round(preg_replace('/[^0-9.]/', '', $cost), 2); } if (in_array($rateReply->ServiceType, array('GROUND_HOME_DELIVERY', 'FEDEX_GROUND', 'INTERNATIONAL_GROUND'))) { $transitTime = ' (' . str_replace(array('_', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteeen'), array(' ', 1,2,3,4,5,6,7,8,9,10,11,12,13,14), strtolower($rateReply->TransitTime)) . ')'; } $methods[] = array('id' => str_replace('_', '', $rateReply->ServiceType), 'title' => ucwords(strtolower(str_replace('_', ' ', $rateReply->ServiceType))) . $transitTime, 'cost' => $cost + (strpos($this->types[$rateReply->ServiceType]['handling_fee'], '%') ? ($cost * (float)$this->types[$rateReply->ServiceType]['handling_fee'] / 100) : (float)$this->types[$rateReply->ServiceType]['handling_fee'])); } } $this->quotes['methods'] = $methods; if ($this->tax_class > 0) { $this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); } } else { $message = 'Error in processing transaction.<br /><br />'; foreach ($response -> Notifications as $notification) { if(is_array($response -> Notifications)) { $message .= $notification->Severity; $message .= ': '; $message .= $notification->Message . '<br />'; } else { $message .= $notification->Message . '<br />'; } } $this->quotes = array('module' => $this->title, 'error' => $message); } // Fedex cannot ship to po box if (preg_match("/^P(.+)O(.+)BOX/i", $order->delivery['street_address']) || preg_match("/^PO BOX/i",$order->delivery['street_address']) || preg_match("/^P(.+)O(.+)BOX/i", $order->delivery['suburb']) || preg_match("/^[A-Z]PO/i", $order->delivery['street_address']) || preg_match("/^[A-Z]PO/i",$order->delivery['suburb'])) { $this->quotes = array('module' => $this->title, 'error' => '<font size=+2 color=red><b>Federal Express cannot ship to Post Office Boxes.<b></font><br>Use the Change Address button above to use a FedEx accepted street address.'); } if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title); return $this->quotes; } // Return expanded info in FEAC function info() { return @[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_INFO_ . $this->vendors_id); // add a description here or leave blank to disable } // Internal function to set insurance value function _setInsuranceValue($order_amount){ if ($order_amount > (float)@[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_INSURE_ . $this->vendors_id)) { $this->insurance = sprintf("%01.2f", $order_amount); } else { $this->insurance = 0; } } // Set the drop off type function _setDropOff() { switch(@[member='constant'](MODULE_SHIPPING_FEDEX_WEB_SERVICES_DROPOFF_ . $this->vendors_id)) { case '1': return 'REGULAR_PICKUP'; break; case '2': return 'REQUEST_COURIER'; break; case '3': return 'DROP_BOX'; break; case '4': return 'BUSINESS_SERVICE_CENTER'; break; case '5': return 'STATION'; break; } } //Check the module status function check() { if (!isset($this->_check)) { $check_query = tep_db_query("select configuration_value from " . TABLE_VENDOR_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_STATUS_" . $this->vendors_id . "' and vendors_id = '" . $this->vendors_id . "'"); $this->_check = tep_db_num_rows($check_query); } return $this->_check; } // Install the module function install($vendors_id = '1') { $this->vendors_id = $vendors_id; if ($this->ok_to_install) { tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) VALUES ('Enable FedEx Web Services','MODULE_SHIPPING_FEDEX_WEB_SERVICES_STATUS_" . $this->vendors_id . "','true','Do you want to offer FedEx shipping?','6','0','tep_cfg_select_option(array(\'true\',\'false\'),',now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('FedEx Web Services Key', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_KEY_" . $this->vendors_id . "', '', 'Enter FedEx Web Services Key', '6', '3', now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('FedEx Web Services Password', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_PWD_" . $this->vendors_id . "', '', 'Enter FedEx Web Services Password', '6', '3', now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('FedEx Account Number', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_ACT_NUM_" . $this->vendors_id . "', '', 'Enter FedEx Account Number', '6', '3', now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('FedEx Meter Number', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_METER_NUM_" . $this->vendors_id . "', '', 'Enter FedEx Meter Number', '6', '4', now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Weight Units', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_WEIGHT_" . $this->vendors_id . "', 'LB', 'Weight Units:', '6', '10', 'tep_cfg_select_option(array(\'LB\', \'KG\'), ', now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('First line of street address', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_ADDRESS_1_" . $this->vendors_id . "', '', 'Enter the first line of your ship-from street address, required', '6', '20', now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Second line of street address', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_ADDRESS_2_" . $this->vendors_id . "', '', 'Enter the second line of your ship-from street address, leave blank if you do not need to specify a second line', '6', '21', now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('City name', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_CITY_" . $this->vendors_id . "', '', 'Enter the city name for the ship-from street address, required', '6', '22', now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('State or Province name', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_STATE_" . $this->vendors_id . "', '', 'Enter the 2 letter state or province name for the ship-from street address, required for Canada and US', '6', '23', now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Postal code', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_POSTAL_" . $this->vendors_id . "', '', 'Enter the postal code for the ship-from street address, required', '6', '24', now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Phone number', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_PHONE_" . $this->vendors_id . "', '', 'Enter a contact phone number for your company, required', '6', '25', now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Drop off type', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_DROPOFF_" . $this->vendors_id . "', '1', 'Dropoff type (1 = Regular pickup, 2 = request courier, 3 = drop box, 4 = drop at BSC, 5 = drop at station)?', '6', '30', 'tep_cfg_select_option(array(\'1\',\'2\',\'3\',\'4\',\'5\'),', now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable Express Saver', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_SAVER_" . $this->vendors_id . "', 'true', 'Enable FedEx Express Saver', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable Standard Overnight', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_STANDARD_OVERNIGHT_" . $this->vendors_id . "', 'true', 'Enable FedEx Express Standard Overnight', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable First Overnight', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_FIRST_OVERNIGHT_" . $this->vendors_id . "', 'true', 'Enable FedEx Express First Overnight', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable Priority Overnight', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_PRIORITY_OVERNIGHT_" . $this->vendors_id . "', 'true', 'Enable FedEx Express Priority Overnight', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable 2 Day', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_2DAY_" . $this->vendors_id . "', 'true', 'Enable FedEx Express 2 Day', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable International Priority', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_PRIORITY_" . $this->vendors_id . "', 'true', 'Enable FedEx Express International Priority', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable International Economy', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_ECONOMY_" . $this->vendors_id . "', 'true', 'Enable FedEx Express International Economy', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable Ground', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_GROUND_" . $this->vendors_id . "', 'true', 'Enable FedEx Ground', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable International Ground', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_GROUND_" . $this->vendors_id . "', 'true', 'Enable FedEx International Ground', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable Freight', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_FREIGHT_" . $this->vendors_id . "', 'true', 'Enable FedEx Freight', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable Saturday Delivery', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_SATURDAY_" . $this->vendors_id . "', 'false', 'Enable Saturday Delivery', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Domestic Ground Handling Fee', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_HANDLING_FEE_" . $this->vendors_id . "', '', 'Add a domestic handling fee or leave blank (example: 15 or 15%)', '6', '25', now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Home Delivery Handling Fee', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_HOME_DELIVERY_HANDLING_FEE_" . $this->vendors_id . "', '', 'Add a home delivery handling fee or leave blank (example: 15 or 15%)', '6', '25', now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Domestic Express Handling Fee', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_" . $this->vendors_id . "', '', 'Add a domestic handling fee or leave blank (example: 15 or 15%)', '6', '25', now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('International Ground Handling Fee', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_HANDLING_FEE_" . $this->vendors_id . "', '', 'Add an international handling fee or leave blank (example: 15 or 15%)', '6', '25', now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('International Express Handling Fee', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_EXPRESS_HANDLING_FEE_" . $this->vendors_id . "', '', 'Add an international handling fee or leave blank (example: 15 or 15%)', '6', '25', now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) VALUES ('FedEx Rates','MODULE_SHIPPING_FEDEX_WEB_SERVICES_RATES_" . $this->vendors_id . "','LIST','FedEx Rates','6','0','tep_cfg_select_option(array(\'LIST\',\'ACCOUNT\'),',now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Signature Option', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_SIGNATURE_OPTION_" . $this->vendors_id . "', '-1', 'Require a signature on orders greater than or equal to (set to -1 to disable):', '6', '25', now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added, vendors_id) values ('Shipping Zone', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_ZONE_" . $this->vendors_id . "', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '98', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added, vendors_id) values ('Tax Class', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_TAX_CLASS_" . $this->vendors_id . "', '0', 'Use the following tax class on the shipping fee.', '6', '25', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Web Services Mode', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_SERVER_" . $this->vendors_id . "', 'Production', 'For testing using a developer key set to \"Test\". Otherwise set to \"Production\".', '6', '10', 'tep_cfg_select_option(array(\'Test\', \'Production\'), ', now(),'" . $this->vendors_id . "')"); tep_db_query ("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Sort Order', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_SORT_ORDER_" . $this->vendors_id . "', '0', 'Sort order of display.', '6', '99', now(),'" . $this->vendors_id . "')"); } } // Remove the module function remove($vendors_id = '1') { $this->vendors_id = $vendors_id; tep_db_query("delete from " . TABLE_VENDOR_CONFIGURATION . " where vendors_id = '". $this->vendors_id ."' and configuration_key in ('" . implode("', '", $this->keys($this->vendors_id)) . "')"); } // Return the module configuration values function keys($vendors_id = '1') { $this->vendors_id = $vendors_id; return array('MODULE_SHIPPING_FEDEX_WEB_SERVICES_STATUS_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_KEY_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_PWD_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_ACT_NUM_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_METER_NUM_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_WEIGHT_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_ADDRESS_1_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_ADDRESS_2_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_CITY_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_STATE_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_POSTAL_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_PHONE_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_DROPOFF_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_SAVER_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_STANDARD_OVERNIGHT_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_FIRST_OVERNIGHT_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_PRIORITY_OVERNIGHT_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_2DAY_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_PRIORITY_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_ECONOMY_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_GROUND_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_FREIGHT_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_GROUND_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_SATURDAY_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_TAX_CLASS_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_HANDLING_FEE_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_HOME_DELIVERY_HANDLING_FEE_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_HANDLING_FEE_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_EXPRESS_HANDLING_FEE_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_RATES_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_SIGNATURE_OPTION_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_ZONE_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_SERVER_' . $this->vendors_id, 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_SORT_ORDER_' . $this->vendors_id ); } // Get country info function get_countries($countries_id = '', $with_iso_codes = false) { $countries_array = array(); if (tep_not_null($countries_id)) { if ($with_iso_codes == true) { $countries = tep_db_query("select countries_name, countries_iso_code_2, countries_iso_code_3 from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$countries_id . "' order by countries_name"); $countries_values = tep_db_fetch_array($countries); $countries_array = array('countries_name' => $countries_values['countries_name'], 'countries_iso_code_2' => $countries_values['countries_iso_code_2'], 'countries_iso_code_3' => $countries_values['countries_iso_code_3']); } else { $countries = tep_db_query("select countries_name from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$countries_id . "'"); $countries_values = tep_db_fetch_array($countries); $countries_array = array('countries_name' => $countries_values['countries_name']); } } else { $countries = tep_db_query("select countries_id, countries_name from " . TABLE_COUNTRIES . " order by countries_name"); while ($countries_values = tep_db_fetch_array($countries)) { $countries_array[] = array('countries_id' => $countries_values['countries_id'], 'countries_name' => $countries_values['countries_name']); } } return $countries_array; } } Quote Link to comment Share on other sites More sharing options...
♥kymation Posted July 22, 2012 Share Posted July 22, 2012 I appreciate you posting the code here, but that code seems to be incomplete. Could you post the file as an attachment? If you don't want to do that, contact me by PM and I'll give you a way of sending it to me. I'd really like to add it to the distribution for others to use. Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
Guest Posted July 22, 2012 Share Posted July 22, 2012 Here is the file attachment. You will also need the wsdl folder from fedex webservices contribution as well as the language/english/modules/shipping/fedexwebservices.php file. fedexwebservices.php Quote Link to comment Share on other sites More sharing options...
♥kymation Posted July 22, 2012 Share Posted July 22, 2012 Thanks for the file. I'm sure other users who want to offer Fedex will appreciate this as well. Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
EJR914 Posted August 17, 2012 Share Posted August 17, 2012 I just installed the MVS 1.2.3 to my host site, and the website is still up and its all good, but when I tried to sign into my admin console to see what was different it would not let me access it and gave me the follow error message: 1146 - Table 'hom1222103375085.vendor_configuration' doesn't exist select configuration_key as cfgKey, configuration_value as cfgValue from vendor_configuration [TEP STOP] I'm a complete NEWBIE at building website, OSCommerce, and messing with PHP CODE. Can any one please HELP me? I need to get my store up and running soon. Its all ready to go besides handling the shipping portion, I believe, so this is the last step. I also have some work to do with my CC/Debit Card processer as well, but after that, the site is ready to go live. So please HELP! I need a ton of it. LOL Good for me, though, I was smart enough to make multiple back ups, because I was afraid this would happen. Quote Link to comment Share on other sites More sharing options...
♥kymation Posted August 17, 2012 Share Posted August 17, 2012 You did not complete the installation. You need to run the mvs.sql to complete the database updates. Please read the readme.txt for instructions. Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
EJR914 Posted August 17, 2012 Share Posted August 17, 2012 You did not complete the installation. You need to run the mvs.sql to complete the database updates. Please read the readme.txt for instructions. Regards Jim Thank you so much, Jim. That is indeed where I messed up, I don't know how I missed it. One question just to be sure, do I upload mvs.sql to my hosting site and then run it? Quote Link to comment Share on other sites More sharing options...
♥kymation Posted August 17, 2012 Share Posted August 17, 2012 No, you need to follow the instructions in the readme.txt. For more information see How to run SQL in phpMyAdmin. Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
EJR914 Posted August 17, 2012 Share Posted August 17, 2012 No, you need to follow the instructions in the readme.txt. For more information see How to run SQL in phpMyAdmin. Regards Jim When I try to run mvs.sql on phpMyAdmin I get this message: Error SQL query: # # Table structure for new table `orders_shipping` # CREATE TABLE `orders_shipping` ( `orders_shipping_id` INT( 11 ) NOT NULL AUTO_INCREMENT , `orders_id` INT( 11 ) NOT NULL DEFAULT '0', `vendors_id` INT( 11 ) NOT NULL DEFAULT '1', `shipping_module` VARCHAR( 16 ) NOT NULL DEFAULT '', `shipping_method` VARCHAR( 128 ) NOT NULL DEFAULT '', `shipping_cost` DECIMAL( 15, 4 ) NOT NULL DEFAULT '0.000', `shipping_tax` DECIMAL( 15, 4 ) NOT NULL DEFAULT '0.000', `vendors_name` VARCHAR( 64 ) NOT NULL DEFAULT '', `vendor_order_sent` VARCHAR( 3 ) NOT NULL DEFAULT 'no', PRIMARY KEY ( `orders_shipping_id` ) ) TYPE = MYISAM AUTO_INCREMENT =0; MySQL said: #1050 - Table 'orders_shipping' already exists I've restored the website 3 times already, and its still not working. Its needless to say I need a lot of help. I'm following the "ReadMe.txt" file as closely as I can. I don't know what else to do. I need this site up fairly soon. I'd hate to just scratch it and start all over after I've spent weeks trying to make it. I've come so far just to quit now. Quote Link to comment Share on other sites More sharing options...
EJR914 Posted August 17, 2012 Share Posted August 17, 2012 Am I having all this trouble because I changed the ext/jquery/ui and template_top.php files first, while I was trying to change the theme and colors of my OSCommerce site? Do I have to delete all my catalogue work and the entire site, and start all over to be able to install MVSv1.2.3. I'm trying to use MVSv1.2.3 to do this install. Is it that I just used 2.3 OSC, instead of the 2.2 OSC? Is that possibly the problem? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.