Jump to content
greasemonkey

FedEx - Web Services v9

Recommended Posts

Beow is my code..Please have a look where signature service is added and where Residential array is.

';

<?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!

 //Modified July 2012 to handle unusual characters in address.

 Support: http://forums.oscommerce.com/topic/375063-fedex-web-services-v9/page__view__findpost__p__1636568

*/

 //added by Roland
 function cleanFedexAddress($string){ 
$string = preg_replace('/[^(\x20-\x7F)\x0A]*/','', $string); 
return $string;
 }





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;

   @[member='definedmedia']('MODULE_SHIPPING_FEDEX_WEB_SERVICES_INSURE', 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;
   $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;
   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;
   }
   if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_FEDEX_WEB_SERVICES_ZONE > 0) ) {
     $check_flag = false;
     $check_query = tep_db_query ("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_FEDEX_WEB_SERVICES_ZONE . "' 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;
     }
   }
 }

 //Class Methods

 function quote($method = '') {
   /* 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 (MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_PRIORITY == 'true') {
     $this->types['INTERNATIONAL_PRIORITY'] = array('icon' => '', 'handling_fee' => MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_EXPRESS_HANDLING_FEE);
    // $this->types['EUROPE_FIRST_INTERNATIONAL_PRIORITY'] = array('icon' => '', 'handling_fee' => MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_EXPRESS_HANDLING_FEE);
   }
   if (MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_ECONOMY == 'true') {
     $this->types['INTERNATIONAL_ECONOMY'] = array('icon' => '', 'handling_fee' => MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_EXPRESS_HANDLING_FEE);
   }  
   if (MODULE_SHIPPING_FEDEX_WEB_SERVICES_STANDARD_OVERNIGHT == 'true') {
     $this->types['STANDARD_OVERNIGHT'] = array('icon' => '', 'handling_fee' => MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE);
   }
   if (MODULE_SHIPPING_FEDEX_WEB_SERVICES_FIRST_OVERNIGHT == 'true') {
     $this->types['FIRST_OVERNIGHT'] = array('icon' => '', 'handling_fee' => MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE);
   }
   if (MODULE_SHIPPING_FEDEX_WEB_SERVICES_PRIORITY_OVERNIGHT == 'true') {
     $this->types['PRIORITY_OVERNIGHT'] = array('icon' => '', 'handling_fee' => MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE);
   }
   if (MODULE_SHIPPING_FEDEX_WEB_SERVICES_2DAY == 'true') {
     $this->types['FEDEX_2_DAY'] = array('icon' => '', 'handling_fee' => MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE);
   }
   // 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 ((MODULE_SHIPPING_FEDEX_WEB_SERVICES_GROUND == 'true' && $order->delivery['country']['id'] == STORE_COUNTRY) || (MODULE_SHIPPING_FEDEX_WEB_SERVICES_GROUND == 'true' && ($order->delivery['country']['id'] != STORE_COUNTRY) && MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_GROUND == 'true')) {
     $this->types['FEDEX_GROUND'] = array('icon' => '', 'handling_fee' => ($order->delivery['country']['id'] == STORE_COUNTRY ? MODULE_SHIPPING_FEDEX_WEB_SERVICES_HANDLING_FEE : MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_HANDLING_FEE));
     $this->types['GROUND_HOME_DELIVERY'] = array('icon' => '', 'handling_fee' => ($order->delivery['country']['id'] == STORE_COUNTRY ? MODULE_SHIPPING_FEDEX_WEB_SERVICES_HOME_DELIVERY_HANDLING_FEE : MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_HANDLING_FEE));
   }
   if (MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_GROUND == 'true') {
     $this->types['INTERNATIONAL_GROUND'] = array('icon' => '', 'handling_fee' => MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_HANDLING_FEE);
   }
   if (MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_SAVER == 'true') {
     $this->types['FEDEX_EXPRESS_SAVER'] = array('icon' => '', 'handling_fee' => MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE);
   }
   if (MODULE_SHIPPING_FEDEX_WEB_SERVICES_FREIGHT == 'true') {
     $this->types['FEDEX_FREIGHT'] = array('icon' => '', 'handling_fee' => MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE);
     $this->types['FEDEX_NATIONAL_FREIGHT'] = array('icon' => '', 'handling_fee' => MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE);
     $this->types['FEDEX_1_DAY_FREIGHT'] = array('icon' => '', 'handling_fee' => MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE);
     $this->types['FEDEX_2_DAY_FREIGHT'] = array('icon' => '', 'handling_fee' => MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE);
     $this->types['FEDEX_3_DAY_FREIGHT'] = array('icon' => '', 'handling_fee' => MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE);
     $this->types['INTERNATIONAL_ECONOMY_FREIGHT'] = array('icon' => '', 'handling_fee' => MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_EXPRESS_HANDLING_FEE);
     $this->types['INTERNATIONAL_PRIORITY_FREIGHT'] = array('icon' => '', 'handling_fee' => MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_EXPRESS_HANDLING_FEE);
   }

//     $this->types[] = 'SMART_POST';

   // customer details
   $street_address = cleanFedexAddress($order->delivery['street_address']);
   $street_address2 = cleanFedexAddress($order->delivery['suburb']);
   $city = cleanFedexAddress($order->delivery['city']);
   $state = tep_get_zone_code($order->delivery['country']['id'], $order->delivery['zone_id'], '');
   if ($state == "QC") $state = "PQ";
   $postcode = cleanFedexAddress(str_replace(array(' ', '-'), '', $order->delivery['postcode']));
   $country_id = $order->delivery['country']['iso_code_2'];

  if(!empty($_SESSION['cart'])){

$totals = $order->info['subtotal'] = $_SESSION['cart']->show_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['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(MODULE_SHIPPING_FEDEX_WEB_SERVICES_ADDRESS_1, 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));  
/*$resi=1;

if($order->delivery['company'] != '')
{
$resi=FALSE;
}
elseif($order->delivery['company'] != '' && $_REQUEST['type']=='residential')
{
$resi=1;
}
else{
$resi=1;
}
*/
if($order->delivery['company'] != '' && $_REQUEST['type']=='residential')
{
   $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' => true)); // Sets commercial vs residential (Home)
}
if($order->delivery['company'] != '' || $_REQUEST['type']=='business')
{
   $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' => false)); // Sets commercial vs residential (Home)
}

   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 (MODULE_SHIPPING_FEDEX_WEB_SERVICES_READY_TO_SHIP == '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 (MODULE_SHIPPING_FEDEX_WEB_SERVICES_SATURDAY == 'true') {
     $request['RequestedShipment']['ServiceOptionType'] = 'SATURDAY_DELIVERY';
   }
   if ((MODULE_SHIPPING_FEDEX_WEB_SERVICES_SIGNATURE_OPTION >= 0 && $totals >= MODULE_SHIPPING_FEDEX_WEB_SERVICES_SIGNATURE_OPTION && $_REQUEST['type'] != 'business') || $_REQUEST['type'] == 'residential') { 
    // $request['RequestedShipment']['SpecialServicesRequested'] = 'SIGNATURE_OPTION'; 
 $request['RequestedShipment']['RequestedPackageLineItems']['0']['SpecialServicesRequested'] = array(
            'SpecialServiceTypes' => 'SIGNATURE_OPTION',
            'SignatureOptionDetail' => array(
            'OptionType'=>'DIRECT'
            ),
            );

   }

  // 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>';

// echo '<pre>'.print_r($this->types,true).'</pre>';

     foreach ($response->RateReplyDetails as $rateReply)
     {


//echo '<pre>'.print_r($rateReply->CommitMessages,true).'</pre>';

// echo '00';
       //if (array_key_exists($rateReply->ServiceType, $this->types) && ($method == '' || str_replace('_', '', $rateReply->ServiceType) == $method))
//if (array_key_exists($rateReply->ServiceType, $this->types) && ($method == '' || str_replace('_', '', $rateReply->ServiceType) == $method) && ($rateReply->DocumentContent != "DOCUMENTS_ONLY"))
       if (array_key_exists($rateReply->ServiceType, $this->types) && ($method == '' || str_replace('_', '', $rateReply->ServiceType) == $method) && (empty($rateReply->CommitMessages)))
{
//echo '<!-- TEST<pre>'.print_r($rateReply,true).'</pre>-->';
//echo '<!-- DEBUG: '.$rateReply->CommitMessages.'-->';

         if(MODULE_SHIPPING_FEDEX_WEB_SERVICES_RATES=='LIST')
         {
// echo '02';
           foreach($rateReply->RatedShipmentDetails as $ShipmentRateDetail)
           {
             if($ShipmentRateDetail->ShipmentRateDetail->RateType=='PAYOR_LIST_PACKAGE'||$ShipmentRateDetail->ShipmentRateDetail->RateType=='PAYOR_LIST_SHIPMENT')
             {

               $cost = $ShipmentRateDetail->ShipmentRateDetail->TotalNetCharge->Amount;
               /*foreach($ShipmentRateDetail->ShipmentRateDetail->Surcharges as $surcharge){
               $cost += $surcharge->Amount->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);
         }

//echo '>>'.$rateReply->RatedShipmentDetails[0]->ShipmentRateDetail->TotalNetCharge->Amount.'<<';
// echo '<pre>'.print_r($rateReply,true).'</pre>';
//die();


         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);

       }
     }

//echo '<pre>'.print_r($methods,true).'</pre>';
//die();


// usort($methods, 'cmp');
     $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);
   }
// 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 ' -->';

if (empty($methods)){
       $this->quotes = array('module' => $this->title,
                             'error' => 'Please contact us for a shipping quote.'); 
}

   return $this->quotes;
 }





 function cmp($a, $B) {
   if ($a['cost'] == $b['cost']) {
       return 0;
   }
   return ($a['cost'] < $b['cost']) ? -1 : 1;
 }

 // method added for expanded info in FEAC
 function info() {
   return MODULE_SHIPPING_FEDEX_WEB_SERVICES_INFO; // add a description here or leave blank to disable
 }

 function _setInsuranceValue($order_amount){
   if ($order_amount > (float)MODULE_SHIPPING_FEDEX_WEB_SERVICES_INSURE) {
     $this->insurance = sprintf("%01.2f", $order_amount);
   } else {
     $this->insurance = 0;
   }
 }

 function objectToArray($object) {
   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() {
   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;
   }
 }

 function check(){
   if(!isset($this->_check)){
     $check_query  = tep_db_query("SELECT configuration_value FROM ". TABLE_CONFIGURATION ." WHERE configuration_key = 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_STATUS'");
     $this->_check = tep_db_num_rows ($check_query);
   }
   return $this->_check;
 }

 function install() {

   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Enable FedEx Web Services','MODULE_SHIPPING_FEDEX_WEB_SERVICES_STATUS','true','Do you want to offer FedEx shipping?','6','0','tep_cfg_select_option(array(\'true\',\'false\'),',now())");
   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('FedEx Web Services Key', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_KEY', '', 'Enter FedEx Web Services Key', '6', '3', now())");
   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('FedEx Web Services Password', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_PWD', '', 'Enter FedEx Web Services Password', '6', '3', now())");
   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('FedEx Account Number', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_ACT_NUM', '', 'Enter FedEx Account Number', '6', '3', now())");
   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('FedEx Meter Number', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_METER_NUM', '', 'Enter FedEx Meter Number', '6', '4', now())");
   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Weight Units', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_WEIGHT', 'LB', 'Weight Units:', '6', '10', 'tep_cfg_select_option(array(\'LB\', \'KG\'), ', now())");
   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('First line of street address', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_ADDRESS_1', '', 'Enter the first line of your ship-from street address, required', '6', '20', now())");
   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Second line of street address', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_ADDRESS_2', '', '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())");
   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('City name', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_CITY', '', 'Enter the city name for the ship-from street address, required', '6', '22', now())");
   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('State or Province name', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_STATE', '', 'Enter the 2 letter state or province name for the ship-from street address, required for Canada and US', '6', '23', now())");
   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Postal code', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_POSTAL', '', 'Enter the postal code for the ship-from street address, required', '6', '24', now())");
   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Phone number', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_PHONE', '', 'Enter a contact phone number for your company, required', '6', '25', now())");
   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Drop off type', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_DROPOFF', '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())");
   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Express Saver', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_SAVER', 'true', 'Enable FedEx Express Saver', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now())");
   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Standard Overnight', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_STANDARD_OVERNIGHT', 'true', 'Enable FedEx Express Standard Overnight', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now())");
   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable First Overnight', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_FIRST_OVERNIGHT', 'true', 'Enable FedEx Express First Overnight', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now())");
   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Priority Overnight', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_PRIORITY_OVERNIGHT', 'true', 'Enable FedEx Express Priority Overnight', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now())");
   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable 2 Day', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_2DAY', 'true', 'Enable FedEx Express 2 Day', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now())");
   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable International Priority', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_PRIORITY', 'true', 'Enable FedEx Express International Priority', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now())");
   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable International Economy', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_ECONOMY', 'true', 'Enable FedEx Express International Economy', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now())");
   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Ground', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_GROUND', 'true', 'Enable FedEx Ground', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now())");
   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable International Ground', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_GROUND', 'true', 'Enable FedEx International Ground', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now())");
   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Freight', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_FREIGHT', 'true', 'Enable FedEx Freight', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now())");
   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Saturday Delivery', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_SATURDAY', 'false', 'Enable Saturday Delivery', '6', '10', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now())");
   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Domestic Ground Handling Fee', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_HANDLING_FEE', '', 'Add a domestic handling fee or leave blank (example: 15 or 15%)', '6', '25', now())");
   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Home Delivery Handling Fee', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_HOME_DELIVERY_HANDLING_FEE', '', 'Add a home delivery handling fee or leave blank (example: 15 or 15%)', '6', '25', now())");
   tep_db_query ("insert into " . TABLE_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', '', 'Add a domestic handling fee or leave blank (example: 15 or 15%)', '6', '25', now())");
   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('International Ground Handling Fee', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_HANDLING_FEE', '', 'Add an international handling fee or leave blank (example: 15 or 15%)', '6', '25', now())");
   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('International Express Handling Fee', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_EXPRESS_HANDLING_FEE', '', 'Add an international handling fee or leave blank (example: 15 or 15%)', '6', '25', now())");
   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('FedEx Rates','MODULE_SHIPPING_FEDEX_WEB_SERVICES_RATES','LIST','FedEx Rates','6','0','tep_cfg_select_option(array(\'LIST\',\'ACCOUNT\'),',now())");
   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Signature Option', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_SIGNATURE_OPTION', '-1', 'Require a signature on orders greater than or equal to (set to -1 to disable):', '6', '25', now())");
   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Ready to Ship', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_READY_TO_SHIP', '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())");    
   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Shipping Zone', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_ZONE', '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())");
   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '25', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())");
   tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_SORT_ORDER', '0', 'Sort order of display.', '6', '99', now())");
 }

 function remove() {
   tep_db_query ("DELETE FROM ". TABLE_CONFIGURATION ." WHERE configuration_key in ('". implode("','",$this->keys()). "')");
 }

 function keys() {
   return array('MODULE_SHIPPING_FEDEX_WEB_SERVICES_STATUS',
                'MODULE_SHIPPING_FEDEX_WEB_SERVICES_KEY',
                'MODULE_SHIPPING_FEDEX_WEB_SERVICES_PWD',
                'MODULE_SHIPPING_FEDEX_WEB_SERVICES_ACT_NUM',
                'MODULE_SHIPPING_FEDEX_WEB_SERVICES_METER_NUM',
                'MODULE_SHIPPING_FEDEX_WEB_SERVICES_WEIGHT',
                'MODULE_SHIPPING_FEDEX_WEB_SERVICES_ADDRESS_1',
                'MODULE_SHIPPING_FEDEX_WEB_SERVICES_ADDRESS_2',
                'MODULE_SHIPPING_FEDEX_WEB_SERVICES_CITY',
                'MODULE_SHIPPING_FEDEX_WEB_SERVICES_STATE',
                'MODULE_SHIPPING_FEDEX_WEB_SERVICES_POSTAL',
                'MODULE_SHIPPING_FEDEX_WEB_SERVICES_PHONE',
                'MODULE_SHIPPING_FEDEX_WEB_SERVICES_DROPOFF',
                'MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_SAVER',
                'MODULE_SHIPPING_FEDEX_WEB_SERVICES_STANDARD_OVERNIGHT',
                'MODULE_SHIPPING_FEDEX_WEB_SERVICES_FIRST_OVERNIGHT',
                'MODULE_SHIPPING_FEDEX_WEB_SERVICES_PRIORITY_OVERNIGHT',
                'MODULE_SHIPPING_FEDEX_WEB_SERVICES_2DAY',
                'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_PRIORITY',
                'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_ECONOMY',
                'MODULE_SHIPPING_FEDEX_WEB_SERVICES_GROUND',
                'MODULE_SHIPPING_FEDEX_WEB_SERVICES_FREIGHT',
                'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INTERNATIONAL_GROUND',
                'MODULE_SHIPPING_FEDEX_WEB_SERVICES_SATURDAY',
                'MODULE_SHIPPING_FEDEX_WEB_SERVICES_TAX_CLASS',
                'MODULE_SHIPPING_FEDEX_WEB_SERVICES_HANDLING_FEE',
       'MODULE_SHIPPING_FEDEX_WEB_SERVICES_HOME_DELIVERY_HANDLING_FEE',
                'MODULE_SHIPPING_FEDEX_WEB_SERVICES_EXPRESS_HANDLING_FEE',
                'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_HANDLING_FEE',
                'MODULE_SHIPPING_FEDEX_WEB_SERVICES_INT_EXPRESS_HANDLING_FEE',
                'MODULE_SHIPPING_FEDEX_WEB_SERVICES_RATES',
                'MODULE_SHIPPING_FEDEX_WEB_SERVICES_SIGNATURE_OPTION',
                'MODULE_SHIPPING_FEDEX_WEB_SERVICES_READY_TO_SHIP',
                'MODULE_SHIPPING_FEDEX_WEB_SERVICES_ZONE',
                'MODULE_SHIPPING_FEDEX_WEB_SERVICES_SORT_ORDER'
                );
 }

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;
}
}

[/b][/b]

Edited by tota

Share this post


Link to post
Share on other sites

@@Roaddoctor

If the Company name is given then it will ship to business but if a company name is present and the requirement is to ship to residential. This is not happening. I want to paste my all code here just as you pasted above. How to paste my code

 

And How to safely upgrade to 9.4.3.1. I am very new to oscommerce.

 

If a Company Name is present in the ship to address a Commercial rate is shown, if Company Name is blank it should give Residential Home rates...

 

Thats how it works.

 

Your using some modified version of old code that I cant really help you with. This module does not do direct address verification with fedex which is what I think you are wanting/needing to achieve your goal. You could hire a developer to incorporate address verification which would then ignore store settings and give rates based on what fedex considers residential or commercial. Both ways have their faults.

 

Upgrade to 9.4.3.1 should be failrly easy - download 9.4.3 and follow the upgrade instructions. then quick patch to 9.4.3.1. With your custom coding in your file though, you may wish to do a merge rather than a straight up replace of fedexwebservices.php.


-Dave

Share this post


Link to post
Share on other sites

is that address yours or the customers?

Make sure your send-from address is correctly capitalized, Verify your account and password is correct.

if still no luck you could call fedex and ask if they are getting/sending data...

next would be to start debugiing fedexwebservices.php to see where your failing.

There are also a couple of documented lines in the file itself that can be experimented with...

What version of osc are you using?

Are upgrading from fedex direct? or new install?

Did you remove and reinstall the module as the previous person did?

 

Please continue this support to the main fedex thread

 

 

I am using osc 2.3.1

that is my address

and it is a new install

 

i have talked to fedex they said they are getting a request but it is really short and different then most of what they get

 

also can you tell me if this is setup to run on there test or production server as i dont have an option to pick what one

Edited by shorty883

Share this post


Link to post
Share on other sites

I've never had anyone confirm that this works with 2.3.1. It should though. Did the instructions code changes outside of fedexwebservices.php match up with 2.3.1?

 

Fix your address in the module admin...

First line of street address

1403 Poplar

 

City name

Round Lake Beach

 

State or Province name

IL

 

Do you have this in checkout_shipping.php?

 

// BOF changes for adding class packing
 if (defined('SHIPPING_DIMENSIONS_SUPPORT') && SHIPPING_DIMENSIONS_SUPPORT == 'Ready-to-ship only') {
   $dimensions_support = 1;
 } elseif (defined('SHIPPING_DIMENSIONS_SUPPORT') && SHIPPING_DIMENSIONS_SUPPORT == 'With product dimensions') {
   $dimensions_support = 2;
 } else {
   $dimensions_support = 0;
 }

 if ($dimensions_support > 0) {
   require(DIR_WS_CLASSES . 'packing.php');
   $packing = new packing;
 }
// EOF changes for adding class packing


-Dave

Share this post


Link to post
Share on other sites

I only have a couple minutes to post this. The dimesional support doesn't work correctly with the existing verstion in that it DOES NOT use the packing program correctly. I tried combining what I have working for FedEx webservices with the the current version and it fails. But, it works on the existing reduced fuction version I emailed to Roaddoctor a while back. I've been working on some modifications but been busy with other things so I'm not done.

 

One thing worth noting is that the utf8_encode function is meant for ISO-8859-1 and if using utf-8 already it can corrupt characters. Search Stack overflow

http://stackoverflow.com/search?q=

+utf8_encode

 

I gotta run but I'll try to post more later, but will be having some beer or many:)


I'm not really a dog.

Share this post


Link to post
Share on other sites

Newbie using 2.2. Shipping process fine with ups and usps. Installed this mod, copied file to modules/shipping folder and went through install selections. Put all other rates, ups usps, at false. Hit checkout button and nothing but blank page from checkout_shipping.php. Fedex just sent me meter id etc so is it possible just needs some time to update?

 

Thanks

Share this post


Link to post
Share on other sites

Try uncommenting this line in fedexwebservices.php - for some it matters, some not. There are also a few other commented lines in that file that can be tested.

 

//	    $check->MoveNext();  // an old Zen Cart remnant - probably not required in OSC

 

double check your install? sql, etc...

Sometimes removing, then reinstalling the module helps.

lastly, you will then need to debug the ship file to see where its failing.


-Dave

Share this post


Link to post
Share on other sites

OK, here we go with exactly how much of a noob I am... Assume you remove the slashes to uncomment. Tried and no change. Also, tried removing and reinstalling without luck. The mother of all stupid questions, how to debug? I understand, I think, that I need to make sure the php.ini file has error tracking on and think I've found code I can paste in but should errors be saved in a particular log file or do I need to run this through something else? Please understand I'm the business owner, somewhat tech comfortable, and we had to get rid of programmer because this has been such a mess. Now trying to fix all the things he left messed up. While I'm at it, thread hijack, how do I change landing page text? The *.php page has a bunch of placeholder gibberish where our text is supposed to be. If html understand just open the file and copy/paste but the text isn't in the php file though it does show when I do a view source. Sorry for the hijack and if it isn't a quick easy answer no problem. Thanks for the help so far.

Share this post


Link to post
Share on other sites

Ok, tried debugging in PHP Console with Chrome. Nothing shows for errors, warnings, etc... Just WSD, White Screen of Death.

Share this post


Link to post
Share on other sites

OK, think I got it. Turns out I'm not a noob I'm a tard. A newbie would have taken the time to go slowly through the process and make sure he download the full package not just the update. The tard on the other hand....

 

Still looking for any help in finding thee &^*%$*^(&^ text in the files.

Share this post


Link to post
Share on other sites

OK, think I got it. Turns out I'm not a noob I'm a tard. A newbie would have taken the time to go slowly through the process and make sure he download the full package not just the update. The tard on the other hand....

 

Still looking for any help in finding thee &^*%$*^(&^ text in the files.

 

If you mean - where do you change the text that shows on your site.... look to

 

/catalog/includes/languages/...


-Dave

Share this post


Link to post
Share on other sites

Looks like I'm 2 for 2 on the knucklehead list. Clicked on CMS and what do you know...

Share this post


Link to post
Share on other sites

I've never had anyone confirm that this works with 2.3.1. It should though. Did the instructions code changes outside of fedexwebservices.php match up with 2.3.1?

 

Fix your address in the module admin...

First line of street address

1403 Poplar

 

City name

Round Lake Beach

 

State or Province name

IL

 

Do you have this in checkout_shipping.php?

 

// BOF changes for adding class packing
if (defined('SHIPPING_DIMENSIONS_SUPPORT') && SHIPPING_DIMENSIONS_SUPPORT == 'Ready-to-ship only') {
$dimensions_support = 1;
} elseif (defined('SHIPPING_DIMENSIONS_SUPPORT') && SHIPPING_DIMENSIONS_SUPPORT == 'With product dimensions') {
$dimensions_support = 2;
} else {
$dimensions_support = 0;
}

if ($dimensions_support > 0) {
require(DIR_WS_CLASSES . 'packing.php');
$packing = new packing;
}
// EOF changes for adding class packing

 

 

 

I cant find this in my checkout_shipping file

Share this post


Link to post
Share on other sites

I cant find this in my checkout_shipping file

 

That code is installed with UPSXML. But because the fedex module was made to be compatible with upsxml's basic ready to ship function (not advanced dimensional ), that code is needed).

 

Add it to checkout_shipping:

 

FIND

 

// load all enabled shipping modules

 

REPLACE WITH

 

// BOF changes for adding class packing
 if (defined('SHIPPING_DIMENSIONS_SUPPORT') && SHIPPING_DIMENSIONS_SUPPORT == 'Ready-to-ship only') {
   $dimensions_support = 1;
 } elseif (defined('SHIPPING_DIMENSIONS_SUPPORT') && SHIPPING_DIMENSIONS_SUPPORT == 'With product dimensions') {
   $dimensions_support = 2;
 } else {
   $dimensions_support = 0;
 }

 if ($dimensions_support > 0) {
   require(DIR_WS_CLASSES . 'packing.php');
   $packing = new packing;
 }
// EOF changes for adding class packing
// load all enabled shipping modules


-Dave

Share this post


Link to post
Share on other sites

It was asked in an earlier message but never answered - does the add-on work with the FedEx Test system?

 

I'm asking because we do not have an actual FedEx account, but need to test the add-on.

 

I've signed up and jumped though all the FedEx hoops resulting in a developer test key, test account number, test meter number and a test password, which I've entered into the admin page, but am receiving:

 

Error in processing transaction.

 

 

Authentication Failed

 

 

when testing the cart.

Share this post


Link to post
Share on other sites

I dont believe there is any reason it should not work.

 

From the developer guide:

FedEx supplies a complete online operating environment with which to test

 

your applications against live FedEx servers. To execute test interactions, you

 

must first include a test account number, test meter number, authentication

 

key, and password in your code. These credentials are provided to registered

Requirements and Resources for Corporate Developers

developers.

 

just checking - did you test that SOAP is working?


-Dave

Share this post


Link to post
Share on other sites

Just a wild guess, in the wsdl you see this

 <service name="RateService">
   <port name="RateServicePort" binding="ns:RateServiceSoapBinding">
  <s1:address location="https://gateway.fedex.com/web-services/"/>
   </port>
 </service>

 

Maybe ask fedex if that has to change for testing. I don't think so though.


-Dave

Share this post


Link to post
Share on other sites

That code is installed with UPSXML. But because the fedex module was made to be compatible with upsxml's basic ready to ship function (not advanced dimensional ), that code is needed).

 

Add it to checkout_shipping:

 

FIND

 

// load all enabled shipping modules

 

REPLACE WITH

 

// BOF changes for adding class packing
if (defined('SHIPPING_DIMENSIONS_SUPPORT') && SHIPPING_DIMENSIONS_SUPPORT == 'Ready-to-ship only') {
$dimensions_support = 1;
} elseif (defined('SHIPPING_DIMENSIONS_SUPPORT') && SHIPPING_DIMENSIONS_SUPPORT == 'With product dimensions') {
$dimensions_support = 2;
} else {
$dimensions_support = 0;
}

if ($dimensions_support > 0) {
require(DIR_WS_CLASSES . 'packing.php');
$packing = new packing;
}
// EOF changes for adding class packing
// load all enabled shipping modules

 

 

 

 

ok i added this and tried again still the same thing no quote tellimg me

Shipping Method

 

This is currently the only shipping method available to use on this order. FedEx shipping_fedex.gifPlease enter a ZIP Code to obtain your shipping quote.

Or possibly:

If no rate is shown, the heavy weight of the item(s) in your Shopping Cart suggests a Request for Freight Quote, rather than FedEx Ground service, is recommended.

Share this post


Link to post
Share on other sites

ok i installed that and it is not giving me any errors at all that i can see

 

You've installed the entire module (9.4.3)? and not just the fedexwebservices.php update file(9.4.3.1)?

 

Look back to posts 387 and 388 in this thread. There are some debug examples you can place directly into fedexwebservices.php to hopefully find the issue


-Dave

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×