This is my poor man's solution to this problem I had. (usps.php)
class usps {
var $code, $title, $description, $icon, $enabled, $countries;
// class constructor
function usps($method = '') {
global $order, $shipping_weight;
$this->code = 'usps';
$this->weightflat = 13;
$this->weightflat5 = 2.1;
$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);
$this->GlobalTest;
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->handling = explode( ", ", MODULE_SHIPPING_USPS_HANDLING_DOMESTIC);
//Listed in the order below:
$this->types = array('Express Mail' => 'Express Mail',
'Priority Mail' => 'Priority Mail',
'Priority Mail Flat-Rate Envelope' => 'Priority Mail Flat-Rate Envelope',
'Priority Mail Flat-Rate Box' => 'Priority Mail Flat-Rate Box',
'First-Class Mail' => 'First Class Mail',
'Parcel Post' => 'Parcel Post',
'Bound Printed Matter' => 'Bound Printed Matter',
'Media Mail' => 'Media Mail');
/******************************************************************* */
//Added by Greg Deeth on May 12th, 2008
//INTERNATIONAL MAIL OPTIONS
//Change the values to the option you would like
//FIRST CLASS MAIL INTERNATIONAL OPTION:
$this->FirstClassIntType = 'Letters'; //OPTIONS: 'Letters', 'Large Envelope', 'Package'
//PRIORITY FLAT-RATE BOX INTERNATIONAL OPTION:
$this->countries = $this->country_list();
$this->countryinsure = $this->country_maxinsure();
}
// class methods
function quote($method = '') {
global $order, $shipping_weight, $shipping_num_boxes, $transittime;
if ($shipping_weight > $this->weightflat5 && $shipping_weight < $this->weightflat) {
$this->PriorityFlatRateBoxType = 'Large Flat-Rate Box';
} else {
$this->PriorityFlatRateBoxType = '';
}
if ($shipping_weight < $this->weightflat5) {
$this->PriorityFlatRateEnv = 'Priority Mail International Flat-Rate Envelope';
} else {
$this->PriorityFlatRateEnv = '';
}
//OPTIONS: 'Flat-Rate Box', 'Large Flat-Rate Box'
/****************************************************************** */
$this->intl_types = array('GLBL EX' => 'Global Express Guaranteed',
'GLBL EX NONDOC RECT' => 'Global Express Guaranteed Non-Document Rectangular',
'GLBL EX NONDOC NON-RECT' => 'Global Express Guaranteed Non-Document Non-Rectangular',
'EXPRESS INT' => 'Express Mail International (EMS)',
'EXPRESS INT FLAT RATE ENV' => 'Express Mail International (EMS) Flat-Rate Envelope',
'PRIORITY INT' => 'Priority Mail International',
'PRIORITY INT FLAT RATE ENV' => $this->PriorityFlatRateEnv,
'PRIORITY INT FLAT RATE BOX' => 'Priority Mail International ' . $this->PriorityFlatRateBoxType,
'FIRST-CLASS INT' => 'First Class Mail International ' . $this->FirstClassIntType);
if ( tep_not_null($method) && (isset($this->types[$method]) || in_array($method, $this->intl_types)) ) {
$this->_setService($method);
}