Question

I am looking to add FedEx SmartPost as a shipping option. Any idea what I need to do to accomplish this? The only information I have found on it is here https://drupal.org/node/793124, but it seems no one has solved this issue. I am willing to modify the ubercart fedex module if needed.

So far what I have done:

  • Changed RateService_v10.wsdl to RateService_v14.wsdl
  • Added code to the uc_fedex_rate_request function:

    $request['RequestedShipment']['SmartPostDetail'] = addSmartPostDetail();
    function addSmartPostDetail(){
      $smartPostDetail = array( 
         'Indicia' => 'PARCEL_SELECT',
         'AncillaryEndorsement' => 'CARRIER_LEAVE_IF_NO_RESPONSE',
         'SpecialServices' => 'USPS_DELIVERY_CONFIRMATION',
         'HubId' => 5087,
         'CustomerManifestID' => myid, 
       );
      return $smartPostDetail;
    }
    

In the uc_fedex_quote function, I have added a debug statement right after:

  $response = uc_fedex_rate_request($packages, $origin, $destination);
  drupal_set_message('<pre>'. print_r($response, TRUE) .'</pre>');

In the response I do not get SmartPost returned as an option.

Was it helpful?

Solution

This is what I had to do (note: I edited the uc_fedex.module directly):

  • You must get SmartPost approved for your account first
  • Get the updated wsdl file from https://www.fedex.com/us/developer/web-services/process.html?tab=tab1 and upload them to your server
  • Get a HubId from customer support (mine was 5185)
  • Get a CustomerManifestID from customer support
  • Change to RateService_v14.wsdl in the code (near $client = new SoapClient...)
  • Change the version to 14

    $request['Version'] = array( 'ServiceId' => 'crs', 'Major' => '14', 'Intermediate' => '0', 'Minor' => '0', );

  • Add the following code:

    $request['RequestedShipment']['SmartPostDetail'] = addSmartPostDetail(); function addSmartPostDetail(){ $smartPostDetail = array( 'Indicia' => 'PARCEL_SELECT', 'AncillaryEndorsement' => 'CARRIER_LEAVE_IF_NO_RESPONSE', 'SpecialServices' => 'USPS_DELIVERY_CONFIRMATION', 'HubId' => yourhubid, 'CustomerManifestID' => yourmanifestid, ); return $smartPostDetail; }

  • Add the following to _uc_fedex_ground_services(): 'SMART_POST' => t('FedEx Smart Post'),

  • Go to admin/store/settings/quotes/methods/fedex and check 'FedEx Smart Post'

OTHER TIPS

AllisonC's answer was very helpful. For anyone setting up SmartPost API calls with Drupal + Ubercart, here's how I built on her solution using FedEx Shipping 7.x-2.0+23-dev.

  • Download an updated RateService_vXX.wsdl file from http://www.fedex.com/us/developer/web-services/process.html?tab=tab1 (current version is v18). Open the wsdl file in a text editor and make sure it is connecting to the FedEx production server (currently ws.fedex.com:443/web-services/). Upload this file to /uc_fedex/wsdl-production/.

  • Edit the uc_fedex.module as follows (line numbers may vary, depending on how you edit the file):

    1. Consider disable caching of SOAP WSDL while testing (line 19).
    2. Define the addSmartPostDetail function as follows, outside the uc_fedex_quote function (I used line 248):

      function addSmartPostDetail(){ $smartPostDetail = array( 'Indicia' => 'PARCEL_SELECT', 'HubId' => '5185', // use 5531 for testing only ); return $smartPostDetail; }

    3. Inside the uc_fedex_quote function (line 271), call the addSmartPostDetail function.

      $request['RequestedShipment']['SmartPostDetail'] = addSmartPostDetail();

    4. Add the following to the _uc_fedex_ground_services() array (line 857):

      'SMART_POST' => t('FedEx Smart Post'),

    5. Define package dimensions (line 544). SmartPost has minimum container sizes of 6" L, 4" W, 1" H, and the module's hardwired settings are not adequate.

      'Dimensions' => array( 'Length' => 6, 'Width' => 4, 'Height' => 1, 'Units' => 'IN', ),

    6. I also manually patched the .module file using the patch at https://www.drupal.org/node/1782298 to avoid an unhelpful "Recoverable fatal error" notice if the request didn't work correctly.
  • Go to admin/store/settings/quotes/methods/fedex and check "FedEx Smart Post'.

My client needed to set conditions separately for Home Delivery and Smart Post, and didn't use any Express services, so I moved the 'SMART_POST' => t('FedEx Smart Post'), snippet to the _uc_fedex_express_services() array, enabled the FedEx Express method, and then set conditions accordingly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top