Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

fedex smartpost shipping method


puri

Recommended Posts

Hi All,

 

I have to use fedex smartpost shipping service in my oscommerce website.Can anybody tell me ,how can i customize this shipping method.beacuse i have no idea about it.

If anybody knows about customization of this shipping method please let me know .

Link to comment
Share on other sites

i have a script for fedex smart post in oscommerce . but its not working .

getting an error that soap class is not found.

can any body tell me what can i use in the place of Soap .

or wht can i do ??

<?php

 

class fedex_smartpost {

var $code, $title, $description, $icon, $enabled;

 

//Class Constructor

function fedex_smartpost() {

global $order, $customer_id, $db;

 

$this->code = "fedex_smartpost";

$this->title = MODULE_SHIPPING_FEDEX_SMARTPOST_TEXT_TITLE;

$this->description = MODULE_SHIPPING_FEDEX_SMARTPOST_TEXT_DESCRIPTION;

$this->sort_order = MODULE_SHIPPING_FEDEX_SMARTPOST_SORT_ORDER;

$this->icon = DIR_WS_ICONS . 'SMARTPOST.gif';

 

 

$this->enabled = ((MODULE_SHIPPING_FEDEX_SMARTPOST_STATUS == 'true') ? true : false);

 

$this->fedex_key = MODULE_SHIPPING_FEDEX_SMARTPOST_KEY;

$this->fedex_pwd = MODULE_SHIPPING_FEDEX_SMARTPOST_PWD;

$this->fedex_act_num = MODULE_SHIPPING_FEDEX_SMARTPOST_ACT_NUM;

$this->fedex_meter_num = MODULE_SHIPPING_FEDEX_SMARTPOST_METER_NUM;

if (defined("SHIPPING_ORIGIN_COUNTRY")) {

$countries_array = tep_get_countries(SHIPPING_ORIGIN_COUNTRY, true);

$this->country = $countries_array['countries_iso_code_2'];

} else {

$this->country = STORE_ORIGIN_COUNTRY;

}

if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_FEDEX_SMARTPOST_ZONE > 0) ) {

$check_flag = false;

$check =tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_FEDEX_SMARTPOST_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");

while (!$check->EOF) {

if ($check->fields['zone_id'] < 1) {

$check_flag = true;

break;

} elseif ($check->fields['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 $db, $shipping_weight, $shipping_num_boxes, $cart, $order;

 

require_once(DIR_WS_INCLUDES . 'library/fedex-common.php5');

// require_once(DIR_WS_INCLUDES . 'classes/nusoap.php');

$path_to_wsdl = DIR_WS_INCLUDES . "wsdl/RateService_v9.wsdl";

 

ini_set("soap.wsdl_cache_enabled", "0");

// new nusoap_client(MODULE_BUYSAFE_BUYSAFE_API_URL, false);

$client = new SoapClient($path_to_wsdl, array('trace' => 1));

 

// customer details

$street_address = $order->delivery['street_address'];

$street_address2 = $order->delivery['suburb'];

$city = $order->delivery['postcode'];

$state= tep_get_zone_code($order->delivery['country']['id'], $order->delivery['zone_id'], '');

// $state = zen_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 = $order->info['subtotal'] = $_SESSION['cart']->show_total();

$this->_setInsuranceValue($totals);

 

$request['WebAuthenticationDetail'] = array('UserCredential' =>

array('Key' => $this->fedex_key, 'Password' => $this->fedex_pwd)); // Replace 'XXX' and 'YYY' with FedEx provided credentials

$request['ClientDetail'] = array('AccountNumber' => $this->fedex_act_num, 'MeterNumber' => $this->fedex_meter_num);// Replace 'XXX' with your account and meter number

$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']['ServiceType'] = 'SMART_POST'; // valid values STANDARD_OVERNIGHT, PRIORITY_OVERNIGHT, FEDEX_GROUND, ...

$request['RequestedShipment']['SmartPostDetail']['Indicia'] = MODULE_SHIPPING_FEDEX_SMARTPOST_INDICIA;

if (MODULE_SHIPPING_FEDEX_SMARTPOST_ENDORSEMENT != 'NONE') {

$request['RequestedShipment']['SmartPostDetail']['AncillaryEndorsement'] = MODULE_SHIPPING_FEDEX_SMARTPOST_ENDORSEMENT;

}

if (MODULE_SHIPPING_FEDEX_SMARTPOST_SPECIALSERVICES == 'true') {

$request['RequestedShipment']['SmartPostDetail']['SpecialServices'] = MODULE_SHIPPING_FEDEX_SMARTPOST_SPECIALSERVICES;

}

$request['RequestedShipment']['SmartPostDetail']['HubId'] = (int)MODULE_SHIPPING_FEDEX_SMARTPOST_HUBID;

$request['RequestedShipment']['PackagingType'] = 'YOUR_PACKAGING'; // valid values FEDEX_BOX, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ...

 

$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_SMARTPOST_ADDRESS_1, MODULE_SHIPPING_FEDEX_SMARTPOST_ADDRESS_2), // Origin details

'City' => MODULE_SHIPPING_FEDEX_SMARTPOST_CITY,

'StateOrProvinceCode' => MODULE_SHIPPING_FEDEX_SMARTPOST_STATE,

'PostalCode' => MODULE_SHIPPING_FEDEX_GROUND_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)); //customer county code

//print_r($request['RequestedShipment']['Recipient']) ;

//exit;

$request['RequestedShipment']['ShippingChargesPayment'] = array('PaymentType' => 'SENDER',

'Payor' => array('AccountNumber' => $this->fedex_act_num, // Replace 'XXX' with payor's account number

'CountryCode' => $this->country));

$request['RequestedShipment']['RateRequestTypes'] = 'ACCOUNT';

$request['RequestedShipment']['RateRequestTypes'] = 'LIST';

$request['RequestedShipment']['PackageCount'] = '1';

$request['RequestedShipment']['PackageDetail'] = 'INDIVIDUAL_PACKAGES';

$request['RequestedShipment']['RequestedPackageLineItems'] = array('0' => array('Weight' => array('Value' => $shipping_weight,

'Units' => MODULE_SHIPPING_FEDEX_SMARTPOST_WEIGHT)));

//print_r($request);

//exit;

$code = $rateReply -> ServiceType;

$response = $client->getRates($request);

if ($response -> HighestSeverity != 'FAILURE' && $response -> HighestSeverity != 'ERROR') {

//echo '<pre>';

//print_r($response);

//echo '</pre>';

$methods[]=array('id' => $rateReply -> ServiceType,

'title' =>'SmartPost',

'cost' => $rateReply->RatedShipmentDetails[0]->ShipmentRateDetail->TotalNetCharge->Amount);

 

//$methods[] = array('id' => $code,

// 'title' =>'SmartPost',

// 'cost' => $response->RateReplyDetails->RatedShipmentDetails[0]->ShipmentRateDetail->TotalNetCharge->Amount);

$this->quotes=array('id' => $this->code,

'module' => MODULE_SHIPPING_FEDEX_SMARTPOST_TEXT_TITLE,

'methods' =>$methods);

} 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 . '<br />';

}

}

$this->quotes = array('module' => $this->title,

'error' => $message);

}

 

 

if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title);

return $this->quotes;

 

 

 

 

}

 

function _setInsuranceValue($order_amount){

if ($order_amount > MODULE_SHIPPING_FEDEX_SMARTPOST_INSURE) {

$this->insurance = sprintf("%01.2f", $order_amount);

} else {

$this->insurance = 0;

}

}

 

function _setDropOff() {

switch(MODULE_SHIPPING_FEDEX_SMARTPOST_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_SMARTPOST_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 SmartPost','MODULE_SHIPPING_FEDEX_SMARTPOST_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 Key', 'MODULE_SHIPPING_FEDEX_SMARTPOST_KEY', 'CC9uiY62KI10mPGn', 'Enter FedEx Web Services Key', '6', '1', 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 Password', 'MODULE_SHIPPING_FEDEX_SMARTPOST_PWD', 'xJK8dnC5PCJzrWETEBtIovDLC', 'Enter FedEx Web Services Password', '6', '2', 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_SMARTPOST_ACT_NUM', '510087402', '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_SMARTPOST_METER_NUM', '118503951', '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_SMARTPOST_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_SMARTPOST_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_SMARTPOST_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_SMARTPOST_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_SMARTPOST_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_SMARTPOST_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_SMARTPOST_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, date_added) values ('HubId', 'MODULE_SHIPPING_FEDEX_SMARTPOST_HUBID', '5531', 'Enter the HubId for SmartPost (Use 5531 for testing)', '6', '30', 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 ('Indicia', 'MODULE_SHIPPING_FEDEX_SMARTPOST_INDICIA', 'PARCEL_SELECT', 'Specify the Indicia Type', '6', '30', 'tep_cfg_select_option(array(\'MEDIA_MAIL\',\'PARCEL_SELECT\',\'PRESORTED_BOUND_PRINTED_MATTER\',\'PRESORTED_STANDARD\'),', 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 ('Ancillary Endorsement', 'MODULE_SHIPPING_FEDEX_SMARTPOST_ENDORSEMENT', 'NONE', 'Specify an endorsement type', '6', '30', 'tep_cfg_select_option(array(\'NONE\',\'ADDRESS_CORRECTION\',\'CARRIER_LEAVE_IF_NO_RESPONSE\',\'CHANGE_SERVICE\',\'FORWARDING_SERVICE\',\'RETURN_SERVICE\'),', 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 ('Special Services', 'MODULE_SHIPPING_FEDEX_SMARTPOST_SPECIALSERVICES', 'false', 'Add delivery confirmation?', '6', '30', '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 ('Drop off type', 'MODULE_SHIPPING_FEDEX_SMARTPOST_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, date_added) values ('Currency Code', 'MODULE_SHIPPING_FEDEX_SMARTPOST_CURRENCY', 'USD', 'Enter 3 digit currency code (default = USD)', '6', '30', 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_SMARTPOST_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, date_added) values ('Sort Order', 'MODULE_SHIPPING_FEDEX_SMARTPOST_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_SMARTPOST_STATUS',

'MODULE_SHIPPING_FEDEX_SMARTPOST_KEY',

'MODULE_SHIPPING_FEDEX_SMARTPOST_PWD',

'MODULE_SHIPPING_FEDEX_SMARTPOST_ACT_NUM',

'MODULE_SHIPPING_FEDEX_SMARTPOST_METER_NUM',

'MODULE_SHIPPING_FEDEX_SMARTPOST_WEIGHT',

'MODULE_SHIPPING_FEDEX_SMARTPOST_ADDRESS_1',

'MODULE_SHIPPING_FEDEX_SMARTPOST_ADDRESS_2',

'MODULE_SHIPPING_FEDEX_SMARTPOST_CITY',

'MODULE_SHIPPING_FEDEX_SMARTPOST_STATE',

'MODULE_SHIPPING_FEDEX_SMARTPOST_POSTAL',

'MODULE_SHIPPING_FEDEX_SMARTPOST_PHONE',

'MODULE_SHIPPING_FEDEX_SMARTPOST_DROPOFF',

'MODULE_SHIPPING_FEDEX_SMARTPOST_CURRENCY',

'MODULE_SHIPPING_FEDEX_SMARTPOST_HUBID',

'MODULE_SHIPPING_FEDEX_SMARTPOST_INDICIA',

'MODULE_SHIPPING_FEDEX_SMARTPOST_SPECIALSERVICES',

'MODULE_SHIPPING_FEDEX_SMARTPOST_ENDORSEMENT',

'MODULE_SHIPPING_FEDEX_SMARTPOST_SORT_ORDER',

'MODULE_SHIPPING_FEDEX_SMARTPOST_ZONE'

);

}

}

?>

Link to comment
Share on other sites

  • 3 years later...

Just curious, where did you get this module?

Peter McGrath

-----------------------------

See my Profile (click here) for more information and to contact me for professional osCommerce support that includes SEO development, custom development and security implementation

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...