Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

USPS International Shipping Options


AussieFan

Recommended Posts

Hi all

 

Ok Ive been at this allllll day and Im starting to get a little ticked off.

 

I want to limit the shipping options for my customers using USPS. I was able to do this for my domestic shipping by adding the // in front of the ones I didnt want.

 

Now when I try and do that for my international options it just simply doesnt want to work!!! Ive been banging my head against the wall allll day. Ive even removed the options from the code itself and it still shows up. So right now my code look like this on my upsp.php page

 

$this->types = array(//'Express' => 'Express Mail',

//'First Class' => 'First-Class Mail',

//'Priority' => 'Priority Mail',

'Parcel' => 'Parcel Post');

 

$this->intl_types = array('Airmail Parcel' => 'Airmail Parcel Post');

 

Ive also tried installing USPS Methods which promised me a section on my admin page that would let me simply select which options I want my customers to see...but it simply doesnt show up. So that it currently looks like this:

 

Enable USPS Shipping

True

 

Enter the USPS User ID

************

 

Enter the USPS Password

************

 

Which server to use

production

 

Handling Fee

0

 

Tax Class

--none--

 

Shipping Zone

--none--

 

Sort Order

1

 

Can someone PLEASE help me solve this...I need to get my store up and running...

 

Oz

Link to comment
Share on other sites

Ok so I found an old BUG report with the same thing thats happening to me...the solution suggested there was as follows:

 

You'll only notice this bug if you try to limit available types in usps module by changing $this->types and $this->intl_types arrays in

catalog/includes/modules/shipping/usps.php line about 40.

 

You'll still get all the types. The problem lies in function quote :

 

CODE

 

if( in_array($type, $this->types) || in_array($type, $this->intl_types))

if ($type == "Parcel") $type = "USPS Parcel";

$methods[] = array('id' => $type,

'title' => ((isset($this->types[$type])) ? $this->types[$type] : $type),

'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);

}

 

 

and should be

 

CODE

 

if( in_array($type, $this->types) || in_array($type, $this->intl_types)) {

if ($type == "Parcel") $type = "USPS Parcel";

$methods[] = array('id' => $type,

'title' => ((isset($this->types[$type])) ? $this->types[$type] : $type),

'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);

}

}

 

 

so the first if function controls adding types to $methods array.

 

Now my only problem is that I must have a newer version than what is being talked about here, because my code looks like this:

 

<?php
/*
 $Id: usps.php,v 1.47 2003/04/08 23:23:42 dgw_ Exp $
 ++++ modified as USPS Methods 2.7 03/26/04 by Brad Waite and Fritz Clapp ++++
 ++++ incorporating USPS revisions to service names ++++
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 class usps {
   var $code, $title, $description, $icon, $enabled, $countries;

// class constructor
   function usps() {
     global $order;

     $this->code = 'usps';
     $this->title = MODULE_SHIPPING_USPS_TEXT_TITLE;
     $this->description = MODULE_SHIPPING_USPS_TEXT_DESCRIPTION;
     $this->sort_order = MODULE_SHIPPING_USPS_SORT_ORDER;
     $this->icon = DIR_WS_ICONS . 'shipping_usps.gif';
     $this->tax_class = MODULE_SHIPPING_USPS_TAX_CLASS;
     $this->enabled = ((MODULE_SHIPPING_USPS_STATUS == 'True') ? true : false);

     if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_USPS_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_USPS_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;
         }
       }

       if ($check_flag == false) {
         $this->enabled = false;
       }
     }

     $this->types = array('Express' => 'EXPRESS', 'First Class' => 'First-Class Mail', 'Priority' => 'Priority', 'Parcel' => 'Parcel', 'BPM' => 'Bound Printed Material', 'Library' => 'Library', 'Media' => 'Media Mail');

     $this->intl_types = array('GXG Document' => 'Global Express Guaranteed Document Service',
                               'GXG Non-Document' => 'Global Express Guaranteed Non-Document Service',
                               'Express' => 'Global Express Mail (EMS)',
                               'Priority Lg' => 'Global Priority Mail - Flat-rate Envelope (Large)',
                               'Priority Sm' => 'Global Priority Mail - Flat-rate Envelope (Small)',
                               'Priority Var' => 'Global Priority Mail - Variable Weight Envelope (Single)',
                               'Airmail Letter' => 'Airmail Letter-post',
                               'Airmail Parcel' => 'Airmail Parcel Post',
                               //'Surface Letter' => 'Economy (Surface) Letter-post',
                               'Surface Post' => 'Economy (Surface) Parcel Post');

     $this->countries = $this->country_list();
   }

// class methods
   function quote($method = '') {
     global $order, $shipping_weight, $shipping_num_boxes, $transittime;

     if ( tep_not_null($method) && (isset($this->types[$method]) || in_array($method, $this->intl_types)) ) {
       $this->_setService($method);
     }

     $this->_setMachinable('False');
     $this->_setContainer('None');
     $this->_setSize('REGULAR');

// usps doesnt accept zero weight
     $shipping_weight = ($shipping_weight < 0.1 ? 0.1 : $shipping_weight);
     $shipping_pounds = floor ($shipping_weight);
     $shipping_ounces = round(16 * ($shipping_weight - floor($shipping_weight)));
     $this->_setWeight($shipping_pounds, $shipping_ounces);
      
     if (in_array('Display weight', explode(', ', MODULE_SHIPPING_USPS_OPTIONS))) {
       $shiptitle = ' (' . $shipping_num_boxes . ' x ' . $shipping_weight . 'lbs)';
     } else {
       $shiptitle = '';
     }

     $uspsQuote = $this->_getQuote();

     if (is_array($uspsQuote)) {
       if (isset($uspsQuote['error'])) {
         $this->quotes = array('module' => $this->title,
                               'error' => $uspsQuote['error']);
       } else {
         $this->quotes = array('id' => $this->code,
                               'module' => $this->title . $shiptitle);

         $methods = array();
         $size = sizeof($uspsQuote);
         for ($i=0; $i<$size; $i++) {
           list($type, $cost) = each($uspsQuote[$i]);

           $title = ((isset($this->types[$type])) ? $this->types[$type] : $type);
           if(in_array('Display transit time', explode(', ', MODULE_SHIPPING_USPS_OPTIONS)))    $title .= $transittime[$type];

           $methods[] = array('id' => $type,
                              'title' => $title,
                              'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);
         }

         $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 {
       $this->quotes = array('module' => $this->title,
                             'error' => MODULE_SHIPPING_USPS_TEXT_ERROR);
     }

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

     return $this->quotes;
   }

   function check() {
     if (!isset($this->_check)) {
       $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_USPS_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 USPS Shipping', 'MODULE_SHIPPING_USPS_STATUS', 'True', 'Do you want to offer USPS 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 ('Enter the USPS User ID', 'MODULE_SHIPPING_USPS_USERID', 'NONE', 'Enter the USPS USERID assigned to you.', '6', '0', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Enter the USPS Password', 'MODULE_SHIPPING_USPS_PASSWORD', 'NONE', 'See USERID, above.', '6', '0', 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 ('Which server to use', 'MODULE_SHIPPING_USPS_SERVER', 'production', 'An account at USPS is needed to use the Production server', '6', '0', 'tep_cfg_select_option(array(\'test\', \'production\'), ', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Handling Fee', 'MODULE_SHIPPING_USPS_HANDLING', '0', 'Handling fee for this shipping method.', '6', '0', 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_USPS_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', '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, use_function, set_function, date_added) values ('Shipping Zone', 'MODULE_SHIPPING_USPS_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', '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_USPS_SORT_ORDER', '0', 'Sort order of display.', '6', '0', 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 ('Domestic Shipping Methods', 'MODULE_SHIPPING_USPS_TYPES', 'Express, Priority, First Class, Parcel, BPM, Library, Media,', 'Select the domestic services to be offered:', '6', '14', 'tep_cfg_select_multioption(array(\'Express\', \'Priority\', \'First Class\', \'Parcel\',\'BPM\',\'Library\',\'Media\'), ',  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 ('Int\'l Shipping Methods', 'MODULE_SHIPPING_USPS_TYPES_INTL', 'GXG Document, GXG Non-Document, Express, Priority Lg, Priority Sm, Priority Var, Airmail Letter, Airmail Parcel, Surface Letter, Surface Post', 'Select the international services to be offered:', '6', '15', 'tep_cfg_select_multioption(array(\'GXG Document\', \'GXG Non-Document\', \'Express\', \'Priority Lg\', \'Priority Sm\', \'Priority Var\', \'Airmail Letter\', \'Airmail Parcel\', \'Surface Letter\', \'Surface Post\'), ',  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 ('USPS Options', 'MODULE_SHIPPING_USPS_OPTIONS', 'Display weight, Display transit time', 'Select from the following the USPS options.', '6', '16', 'tep_cfg_select_multioption(array(\'Display weight\', \'Display transit time\'), ',  now())");
   }

   function remove() {
     tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
   }

   function keys() {
     return array('MODULE_SHIPPING_USPS_STATUS', 'MODULE_SHIPPING_USPS_USERID', 'MODULE_SHIPPING_USPS_PASSWORD', 'MODULE_SHIPPING_USPS_SERVER', 'MODULE_SHIPPING_USPS_HANDLING', 'MODULE_SHIPPING_USPS_TAX_CLASS', 'MODULE_SHIPPING_USPS_ZONE', 'MODULE_SHIPPING_USPS_SORT_ORDER', 'MODULE_SHIPPING_USPS_OPTIONS', 'MODULE_SHIPPING_USPS_TYPES', 'MODULE_SHIPPING_USPS_TYPES_INTL');
   }

   function _setService($service) {
     $this->service = $service;
   }

   function _setWeight($pounds, $ounces=0) {
     $this->pounds = $pounds;
     $this->ounces = $ounces;
   }

   function _setContainer($container) {
     $this->container = $container;
   }

   function _setSize($size) {
     $this->size = $size;
   }

   function _setMachinable($machinable) {
     $this->machinable = $machinable;
   }

   function _getQuote() {
     global $order, $transittime;

     if(in_array('Display transit time', explode(', ', MODULE_SHIPPING_USPS_OPTIONS))) $transit = TRUE;

     if ($order->delivery['country']['id'] == SHIPPING_ORIGIN_COUNTRY) {
       $request  = '<RateRequest USERID="' . MODULE_SHIPPING_USPS_USERID . '" PASSWORD="' . MODULE_SHIPPING_USPS_PASSWORD . '">';
       $services_count = 0;

       if (isset($this->service)) {
         $this->types = array($this->service => $this->types[$this->service]);
       }

       $dest_zip = str_replace(' ', '', $order->delivery['postcode']);
       if ($order->delivery['country']['iso_code_2'] == 'US') $dest_zip = substr($dest_zip, 0, 5);

       reset($this->types);
       $allowed_types = explode(", ", MODULE_SHIPPING_USPS_TYPES);

       while (list($key, $value) = each($this->types)) {

  if ( !in_array($key, $allowed_types) ) continue;

         $request .= '<Package ID="' . $services_count . '">' .
                     '<Service>' . $key . '</Service>' .
                     '<ZipOrigination>' . SHIPPING_ORIGIN_ZIP . '</ZipOrigination>' .
                     '<ZipDestination>' . $dest_zip . '</ZipDestination>' .
                     '<Pounds>' . $this->pounds . '</Pounds>' .
                     '<Ounces>' . $this->ounces . '</Ounces>' .
                     '<Container>' . $this->container . '</Container>' .
                     '<Size>' . $this->size . '</Size>' .
                     '<Machinable>' . $this->machinable . '</Machinable>' .
                     '</Package>';

         if($transit){
           $transitreq  = 'USERID="' . MODULE_SHIPPING_USPS_USERID .
                        '" PASSWORD="' . MODULE_SHIPPING_USPS_PASSWORD . '">' .
                        '<OriginZip>' . STORE_ORIGIN_ZIP . '</OriginZip>' .
                        '<DestinationZip>' . $dest_zip . '</DestinationZip>';

           switch ($key) {
             case 'Express':  $transreq[$key] = 'API=ExpressMail&XML=' .
                              urlencode( '<ExpressMailRequest ' . $transitreq . '</ExpressMailRequest>');
                              break;
             case 'Priority': $transreq[$key] = 'API=PriorityMail&XML=' .
                              urlencode( '<PriorityMailRequest ' . $transitreq . '</PriorityMailRequest>');
                              break;
             case 'Parcel':   $transreq[$key] = 'API=StandardB&XML=' .
                              urlencode( '<StandardBRequest ' . $transitreq . '</StandardBRequest>');
                              break;
             default:         $transreq[$key] = '';
                              break;
           }
         }

         $services_count++;
       }
       $request .= '</RateRequest>';

       $request = 'API=Rate&XML=' . urlencode($request);
     } else {
       $request  = '<IntlRateRequest USERID="' . MODULE_SHIPPING_USPS_USERID . '" PASSWORD="' . MODULE_SHIPPING_USPS_PASSWORD . '">' .
                   '<Package ID="0">' .
                   '<Pounds>' . $this->pounds . '</Pounds>' .
                   '<Ounces>' . $this->ounces . '</Ounces>' .
                   '<MailType>Package</MailType>' .
                   '<Country>' . $this->countries[$order->delivery['country']['iso_code_2']] . '</Country>' .
                   '</Package>' .
                   '</IntlRateRequest>';

       $request = 'API=IntlRate&XML=' . urlencode($request);
     }

     switch (MODULE_SHIPPING_USPS_SERVER) {
       case 'production': $usps_server = 'production.shippingapis.com';
                          $api_dll = 'shippingapi.dll';
                          break;
       case 'test':
       default:           $usps_server = 'testing.shippingapis.com';
                          $api_dll = 'ShippingAPITest.dll';
                          break;
     }

     $body = '';

     $http = new httpClient();
     if ($http->Connect($usps_server, 80)) {
       $http->addHeader('Host', $usps_server);
       $http->addHeader('User-Agent', 'osCommerce');
       $http->addHeader('Connection', 'Close');

       if ($http->Get('/' . $api_dll . '?' . $request)) $body = $http->getBody();
//  mail('[email protected]','USPS rate quote response',$body,'From: <[email protected]>');
       if ($transit && is_array($transreq) && ($order->delivery['country']['id'] == STORE_COUNTRY)) {
         while (list($key, $value) = each($transreq)) {
           if ($http->Get('/' . $api_dll . '?' . $value)) $transresp[$key] = $http->getBody();
         }
       }

       $http->Disconnect();

     } else {
       return false;
     }

     $response = array();
     while (true) {
       if ($start = strpos($body, '<Package ID=')) {
         $body = substr($body, $start);
         $end = strpos($body, '</Package>');
         $response[] = substr($body, 0, $end+10);
         $body = substr($body, $end+9);
       } else {
         break;
       }
     }

     $rates = array();
     if ($order->delivery['country']['id'] == SHIPPING_ORIGIN_COUNTRY) {
       if (sizeof($response) == '1') {
         if (ereg('<Error>', $response[0])) {
           $number = ereg('<Number>(.*)</Number>', $response[0], $regs);
           $number = $regs[1];
           $description = ereg('<Description>(.*)</Description>', $response[0], $regs);
           $description = $regs[1];

           return array('error' => $number . ' - ' . $description);
         }
       }

       $n = sizeof($response);
       for ($i=0; $i<$n; $i++) {
         if (strpos($response[$i], '<Postage>')) {
           $service = ereg('<Service>(.*)</Service>', $response[$i], $regs);
           $service = $regs[1];
           $postage = ereg('<Postage>(.*)</Postage>', $response[$i], $regs);
           $postage = $regs[1];

           $rates[] = array($service => $postage);

           if ($transit) {
             switch ($service) {
               case 'Express':     $time = ereg('<MonFriCommitment>(.*)</MonFriCommitment>', $transresp[$service], $tregs);
                                   $time = $tregs[1];
                                   if ($time == '' || $time == 'No Data') {
                                     $time = '1 - 2 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
                                   } else {
                                     $time = 'Tomorrow by ' . $time;
                                   }
                                   break;
               case 'Priority':    $time = ereg('<Days>(.*)</Days>', $transresp[$service], $tregs);
                                   $time = $tregs[1];
                                   if ($time == '' || $time == 'No Data') {
                                     $time = '2 - 3 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
                                   } elseif ($time == '1') {
                                     $time .= ' ' . MODULE_SHIPPING_USPS_TEXT_DAY;
                                   } else {
                                     $time .= ' ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
                                   }
                                   break;
               case 'Parcel':      $time = ereg('<Days>(.*)</Days>', $transresp[$service], $tregs);
                                   $time = $tregs[1];
                                   if ($time == '' || $time == 'No Data') {
                                     $time = '4 - 7 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
                                   } elseif ($time == '1') {
                                     $time .= ' ' . MODULE_SHIPPING_USPS_TEXT_DAY;
                                   } else {
                                     $time .= ' ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
                                   }
                                   break;
               case 'First Class': $time = '2 - 5 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
                                   break;
               default:            $time = '';
                                   break;
             }
             if ($time != '') $transittime[$service] = ' (' . $time . ')';
           }
         }
       }
     } else {
       if (ereg('<Error>', $response[0])) {
         $number = ereg('<Number>(.*)</Number>', $response[0], $regs);
         $number = $regs[1];
         $description = ereg('<Description>(.*)</Description>', $response[0], $regs);
         $description = $regs[1];

         return array('error' => $number . ' - ' . $description);
       } else {
         $body = $response[0];
         $services = array();
         while (true) {
           if ($start = strpos($body, '<Service ID=')) {
             $body = substr($body, $start);
             $end = strpos($body, '</Service>');
             $services[] = substr($body, 0, $end+10);
             $body = substr($body, $end+9);
           } else {
             break;
           }
         }
         $allowed_types = array();
         foreach( explode(", ", MODULE_SHIPPING_USPS_TYPES_INTL) as $value ) $allowed_types[$value] = $this->intl_types[$value];

         $size = sizeof($services);
         for ($i=0, $n=$size; $i<$n; $i++) {
           if (strpos($services[$i], '<Postage>')) {
             $service = ereg('<SvcDescription>(.*)</SvcDescription>', $services[$i], $regs);
             $service = $regs[1];
             $postage = ereg('<Postage>(.*)</Postage>', $services[$i], $regs);
             $postage = $regs[1];
             $time = ereg('<SvcCommitments>(.*)</SvcCommitments>', $services[$i], $tregs);
             $time = $tregs[1];
             $time = preg_replace('/Weeks$/', MODULE_SHIPPING_USPS_TEXT_WEEKS, $time);
             $time = preg_replace('/Days$/', MODULE_SHIPPING_USPS_TEXT_DAYS, $time);
             $time = preg_replace('/Day$/', MODULE_SHIPPING_USPS_TEXT_DAY, $time);

             if( !in_array($service, $allowed_types) ) continue;
             if (isset($this->service) && ($service != $this->service) ) {
               continue;
             }

             $rates[] = array($service => $postage);
      if ($time != '') $transittime[$service] = ' (' . $time . ')';
           }
         }
       }
     }

     return ((sizeof($rates) > 0) ? $rates : false);
   }

 

Can anyone help me to decifer this?

 

Oz

? ? ? ? ? ? ? ? ? ?

Edited by AussieFan
Link to comment
Share on other sites

Ok so in my admin page the Domestic Shipping Methods, Int'l Shipping Methods and the USPS Options were not showing up. So I went into includes/modules/shipping/usps.php and added them into the function keys. So it now looks like this:

 

function keys() {

return array('MODULE_SHIPPING_USPS_STATUS', 'MODULE_SHIPPING_USPS_USERID', 'MODULE_SHIPPING_USPS_PASSWORD', 'MODULE_SHIPPING_USPS_SERVER', 'MODULE_SHIPPING_USPS_HANDLING', 'MODULE_SHIPPING_USPS_TAX_CLASS', 'MODULE_SHIPPING_USPS_ZONE', 'MODULE_SHIPPING_USPS_SORT_ORDER', 'MODULE_SHIPPING_USPS_TYPES', 'MODULE_SHIPPING_USPS_TYPES_INTL', 'MODULE_SHIPPING_USPS_OPTIONS');

}

 

The checkboxes now do show up after re-installing the module, but the options that I pick DO NOT! My customer still sees ALL the shipping options even though I have disselected them!

Link to comment
Share on other sites

  • 3 weeks later...
Ok so I found an old BUG report with the same thing thats happening to me...the solution suggested there was as follows:

 

You'll only notice this bug if you try to limit available types in usps module by changing $this->types and $this->intl_types arrays in

catalog/includes/modules/shipping/usps.php line about 40.

 

You'll still get all the types. The problem lies in function quote :

 

CODE

 

if( in_array($type, $this->types) || in_array($type, $this->intl_types))

if ($type == "Parcel") $type = "USPS Parcel";

$methods[] = array('id' => $type,

'title' => ((isset($this->types[$type])) ? $this->types[$type] : $type),

'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);

}

and should be

 

CODE

 

if( in_array($type, $this->types) || in_array($type, $this->intl_types)) {

if ($type == "Parcel") $type = "USPS Parcel";

$methods[] = array('id' => $type,

'title' => ((isset($this->types[$type])) ? $this->types[$type] : $type),

'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);

}

}

so the first if function controls adding types to $methods array.

 

Now my only problem is that I must have a newer version than what is being talked about here, because my code looks like this [...]

 

Has there been any progress on this?

 

I am having the same problem.

 

I'm a script novice, but I'll look the code over and see if anything, by some miracle, jumps out at me.

Link to comment
Share on other sites

  • 1 month later...

Has anyone come up with a solution for this yet? I also am fairly new at PHP. But, I have searched through all the oscommerce files and found no references for intl_types that proved useful. I just don't understand how even if you completely remove the entire array function from the usps.php module, it still spits back the Intl options upon checkout! Like the guy that started this thread, I am banging my head against the wall. WHAT IS UP?!

 

Please help... someone.... anyone... TIA.

 

AirGator

Link to comment
Share on other sites

Has anyone come up with a solution for this yet? I also am fairly new at PHP. But, I have searched through all the oscommerce files and found no references for intl_types that proved useful. I just don't understand how even if you completely remove the entire array function from the usps.php module, it still spits back the Intl options upon checkout! Like the guy that started this thread, I am banging my head against the wall. WHAT IS UP?!

 

Please help... someone.... anyone... TIA.

 

AirGator

 

Wow no one has found the solution to this yet?

 

I gave up and just set USPS to domestic. That stops the global options from showing up :-"

Link to comment
Share on other sites

  • 4 weeks later...

I figured it out...

 

In includes/modules/shipping/usps.php around line 307 change

 

			  
		  if (isset($this->service) && ($service != $this->service) ) {
			continue;
		  }

		  $rates[] = array($service => $postage);

 

to this

 

			  if (isset($this->service) && ($service != $this->service) ) {
			continue;
		  }

			if(!in_array($service, $this->intl_types)) {
					continue;
			}

		  $rates[] = array($service => $postage);

Link to comment
Share on other sites

  • 1 year later...
I figured it out...

 

In includes/modules/shipping/usps.php around line 307 change

 

			  
		  if (isset($this->service) && ($service != $this->service) ) {
			continue;
		  }

		  $rates[] = array($service => $postage);

 

to this

 

			  if (isset($this->service) && ($service != $this->service) ) {
			continue;
		  }

			if(!in_array($service, $this->intl_types)) {
					continue;
			}

		  $rates[] = array($service => $postage);

 

I tried this, and now the customer gets this error at checkout:

Parse error: parse error, unexpected T_IF, expecting ')' in /homepages/34/d117733483/htdocs/html/catalog/includes/modules/shipping/usps.php on line 75

What does this mean? I'm very newbie here, and need some help!

Link to comment
Share on other sites

I tried this, and now the customer gets this error at checkout:

Parse error: parse error, unexpected T_IF, expecting ')' in /homepages/34/d117733483/htdocs/html/catalog/includes/modules/shipping/usps.php on line 75

What does this mean? I'm very newbie here, and need some help!

Never mind, I figured it out! Thanks anyway!

Link to comment
Share on other sites

  • 2 weeks later...
  • 9 months later...
I tried this, and now the customer gets this error at checkout:

Parse error: parse error, unexpected T_IF, expecting ')' in /homepages/34/d117733483/htdocs/html/catalog/includes/modules/shipping/usps.php on line 75

What does this mean? I'm very newbie here, and need some help!

 

 

I also tried this, and now customers get this message:

 

Parse error: syntax error, unexpected T_STRING, expecting ')' in /home/botan2/public_html/includes/modules/shipping/usps.php on line 484

 

Could someone please tell me what I did wrong and how to fix it. Thanks, RB

Link to comment
Share on other sites

  • 5 weeks later...
I also tried this, and now customers get this message:

 

Parse error: syntax error, unexpected T_STRING, expecting ')' in /home/botan2/public_html/includes/modules/shipping/usps.php on line 484

 

Could someone please tell me what I did wrong and how to fix it. Thanks, RB

Will someone please tell me which code to change to make USPS Int'l shipping work? I have searched for hours but have found now clear answer. The above posts were the closest I have seen.

 

I got the domestic USPS to work a few months ago, but now I need Int'l. Just when they change things.

 

I have pored over the code and changed the few things I did find in forums, but to no avail. Please help.

 

Lark

Link to comment
Share on other sites

Hi,

 

There is a totally of 4 files that you must effect (change) when installing the USPS module. You will find the necessary changes to admin/modules.php and admin/includes/functions/general.php. Use installation directions from 4.1 beta but use the USPS files from version 3.0. Once you make these change in the admin files your features will show up properly in the admin section.

 

Be well,

Anna

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...