Forums / Built-in Shipping and Payment Modules / Error cloning a shipping module

Error cloning a shipping module

Locked

Views: 3,469

Results 1 to 18 of 18
This thread is locked. New replies are disabled.
30 Sep 2006, 12:56 AM
#1
brain21 avatar

brain21

New Zenner

Join Date:
Sep 2006
Posts:
42
Plugin Contributions:
0

Error cloning a shipping module

I followed the instructions here:

http://www.zen-cart.com/forum/showthread.php?t=21531&highlight=cloning+shipping+module

for cloning a module. I clone the UPS module, and renamed the 2 files to ups-canada.php

I renamed the class from ups to ups-canada and the SHIPPING_MODULE_UPS_ to SHIPPING_MODULE_UPS-CANADA in both file.

When I try to load up the shipping modules, I get the following error:

Fatal error: Cannot redeclare class ups in C:\Program Files\xampp\htdocs\connequestrian\store\includes\modules\shipping\ups.php

Line 447, btw, is a comment line.

Anyone got any clues???

Thanks,

Brain21

30 Sep 2006, 2:51 AM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Error cloning a shipping module

The naming is crossing on UPS vs UPS-blah in the keys ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

30 Sep 2006, 3:37 AM
#3
brain21 avatar

brain21

New Zenner

Join Date:
Sep 2006
Posts:
42
Plugin Contributions:
0

Re: Error cloning a shipping module

What keys, where? You just spoke greek to me. :-)
:blink:

Is there a specific line of code that you are talking about???

Thanks,

Brain21

30 Sep 2006, 3:06 PM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Error cloning a shipping module

Change the UPS-CANADA to UPSCANADA and change ups-canada to upscanada and be sure to change the two filenames to upscanada.php as well ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

1 Oct 2006, 5:26 PM
#5
brain21 avatar

brain21

New Zenner

Join Date:
Sep 2006
Posts:
42
Plugin Contributions:
0

Re: Error cloning a shipping module

Did that. Still getting the same error. It is now loading the ups module, but the error is EXACTLY like it was before, only now the module is upscanada.php rather than ups.php. Same line and everything.

Here is the line its crapping out on (this time line 447 isn't a comment line):

$body_array = explode("\n", $body);

The php file itself can be gotten from my server:

ftp turdferguson.kicks-***.org

UID: guest
Passwd: guest

upscanada.php is the only file there

And since this site is censoring bad words, the site is not
.kicks-***.org
but
. k i c k s - a s s . o r g

Thanks,

Alex F

1 Oct 2006, 7:05 PM
#6
brain21 avatar

brain21

New Zenner

Join Date:
Sep 2006
Posts:
42
Plugin Contributions:
0

Re: Error cloning a shipping module

OK, so I think maybe the error is actually on line 13 where the class ups is being called:

class ups extends base {

So I change it to this:

class upscanada extends base {

Save and reload the shipping module.

Well, now I am not getting those errors anymore. There is a new shipping module now showing.

The module title is blank. I click on it. The little window to the right has no title or text of any kind, but it does have an install button. I click on install.

Now I am getting the following error:

Warning: reset() [function.reset]: Passed variable is not an array or object in C:\Program Files\xampp\htdocs\connequestrian\store\admin\modules.php on line 279

Warning: Variable passed to each() is not an array or object in C:\Program Files\xampp\htdocs\connequestrian\store\admin\modules.php on line 280

Out of the fryingpan and into the fire.

I just don't get why this isn't easy. It is NOT uncommon for people to use different shipping rates to different countries for a single shipping method. In fact, when I was searching the forums I saw a number of posts from 2004 asking for this capability. If it's not built-in and we have to resort to manually cloning a module and then running into all sorts of cryptic errors & problems, and basically NO documentation in this crap, then why didn't the devs simply create a script & button. "Click here to clone a shipping module". Then it presents you w/ a drop down list of all of the installed modules. You select the one you want and enter in a new name for it, and viola! Done. Very frustrating....

Thanks for any help!

Brain21

1 Oct 2006, 7:08 PM
#7
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Error cloning a shipping module

This is my upscanada.php ...

Note: there is a change on weight so there is no conflict with clones or other modules:

<?php
/**
 * @package shippingMethod
 * @copyright Copyright 2003-2005 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: ups.php 4633 2006-09-30 14:53:59Z ajeh $
 */
/**
 * Enter description here...
 *
 */
class upscanada extends base {
  /**
   * Enter description here...
   *
   * @var unknown_type
   */
  var $code;
  /**
   * Enter description here...
   *
   * @var unknown_type
   */
  var $title;
  /**
   * Enter description here...
   *
   * @var unknown_type
   */
  var $description;
  /**
   * Enter description here...
   *
   * @var unknown_type
   */
  var $icon;
  /**
   * Enter description here...
   *
   * @var unknown_type
   */
  var $enabled;
  /**
   * Enter description here...
   *
   * @var unknown_type
   */
  var $types;
  /**
   * Enter description here...
   *
   * @return upscanada
   */
  function upscanada() {
    global $order, $db, $template;

    $this->code = 'upscanada';
    $this->title = MODULE_SHIPPING_UPSCANADA_TEXT_TITLE;
    $this->description = MODULE_SHIPPING_UPSCANADA_TEXT_DESCRIPTION;
    $this->sort_order = MODULE_SHIPPING_UPSCANADA_SORT_ORDER;
    $this->icon = $template->get_template_dir('shipping_ups.gif', DIR_WS_TEMPLATE, $current_page_base,'images/icons'). '/' . 'shipping_ups.gif';
    $this->tax_class = MODULE_SHIPPING_UPSCANADA_TAX_CLASS;
    $this->tax_basis = MODULE_SHIPPING_UPSCANADA_TAX_BASIS;

    // disable only when entire cart is free shipping
    if (zen_get_shipping_enabled($this->code)) {
      $this->enabled = ((MODULE_SHIPPING_UPSCANADA_STATUS == 'True') ? true : false);
    }

    if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_UPSCANADA_ZONE > 0) ) {
      $check_flag = false;
      $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_UPSCANADA_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;
      }
    }

    $this->types = array('1DM' => 'Next Day Air Early AM',
    '1DML' => 'Next Day Air Early AM Letter',
    '1DA' => 'Next Day Air',
    '1DAL' => 'Next Day Air Letter',
    '1DAPI' => 'Next Day Air Intra (Puerto Rico)',
    '1DP' => 'Next Day Air Saver',
    '1DPL' => 'Next Day Air Saver Letter',
    '2DM' => '2nd Day Air AM',
    '2DML' => '2nd Day Air AM Letter',
    '2DA' => '2nd Day Air',
    '2DAL' => '2nd Day Air Letter',
    '3DS' => '3 Day Select',
    'GND' => 'Ground',
    'GNDCOM' => 'Ground Commercial',
    'GNDRES' => 'Ground Residential',
    'STD' => 'Canada Standard',
    'XPR' => 'Worldwide Express',
    'XPRL' => 'worldwide Express Letter',
    'XDM' => 'Worldwide Express Plus',
    'XDML' => 'Worldwide Express Plus Letter',
    'XPD' => 'Worldwide Expedited');
  }
  /**
   * Enter description here...
   *
   * @param unknown_type $method
   * @return unknown
   */
  function quote($method = '') {
    global $_POST, $order, $shipping_weight, $shipping_num_boxes;

    if ( (zen_not_null($method)) && (isset($this->types[$method])) ) {
      $prod = $method;
      // BOF: UPS USPS
    } else if ($order->delivery['country']['iso_code_2'] == 'CA') {
      $prod = 'STD';
      // EOF: UPS USPS
    } else {
      $prod = 'GNDRES';
    }

    if ($method) $this->_upsAction('3'); // return a single quote

    $this->_upsProduct($prod);

    $ups_shipping_weight = ($shipping_weight < 0.1 ? 0.1 : $shipping_weight);

    $country_name = zen_get_countries(SHIPPING_ORIGIN_COUNTRY, true);
    $this->_upsOrigin(SHIPPING_ORIGIN_ZIP, $country_name['countries_iso_code_2']);
    $this->_upsDest($order->delivery['postcode'], $order->delivery['country']['iso_code_2']);
    $this->_upsRate(MODULE_SHIPPING_UPSCANADA_PICKUP);
    $this->_upsContainer(MODULE_SHIPPING_UPSCANADA_PACKAGE);
    $this->_upsWeight($ups_shipping_weight);
    $this->_upsRescom(MODULE_SHIPPING_UPSCANADA_RES);
    $upsQuote = $this->_upsGetQuote();

    if ( (is_array($upsQuote)) && (sizeof($upsQuote) > 0) ) {
      switch (SHIPPING_BOX_WEIGHT_DISPLAY) {
        case (0):
        $show_box_weight = '';
        break;
        case (1):
        $show_box_weight = ' (' . $shipping_num_boxes . ' ' . TEXT_SHIPPING_BOXES . ')';
        break;
        case (2):
        $show_box_weight = ' (' . number_format($ups_shipping_weight * $shipping_num_boxes,2) . TEXT_SHIPPING_WEIGHT . ')';
        break;
        default:
        $show_box_weight = ' (' . $shipping_num_boxes . ' x ' . number_format($ups_shipping_weight,2) . TEXT_SHIPPING_WEIGHT . ')';
        break;
      }
      $this->quotes = array('id' => $this->code,
      'module' => $this->title . $show_box_weight);

      $methods = array();
      // BOF: UPS USPS
      $allowed_methods = explode(", ", MODULE_SHIPPING_UPSCANADA_TYPES);
      $std_rcd = false;
      // EOF: UPS USPS
      $qsize = sizeof($upsQuote);
      for ($i=0; $i<$qsize; $i++) {
        list($type, $cost) = each($upsQuote[$i]);
        // BOF: UPS USPS
        if ($type=='STD') {
          if ($std_rcd) continue;
          else $std_rcd = true;
        }
        if (!in_array($type, $allowed_methods)) continue;
        // EOF: UPS USPS
        $methods[] = array('id' => $type,
        'title' => $this->types[$type],
        'cost' => ($cost + MODULE_SHIPPING_UPSCANADA_HANDLING) * $shipping_num_boxes);
      }

      $this->quotes['methods'] = $methods;

      if ($this->tax_class > 0) {
        $this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
      }
    } else {
      /* ORIGINAL
      $this->quotes = array('module' => $this->title,
      'error' => 'An error occurred with the UPS shipping calculations.<br />' . $upsQuote . '<br />If you prefer to use UPS as your shipping method, please contact the store owner.');
      */
      // BOF: UPS USPS
      $this->quotes = array('module' => $this->title,
      'error' => 'We are unable to obtain a rate quote for UPS shipping.<br />Please contact the store if no other alternative is shown.');
      // EOF: UPS USPS
    }

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

    return $this->quotes;
  }
  /**
   * Enter description here...
   *
   * @return unknown
   */
  function check() {
    global $db;
    if (!isset($this->_check)) {
      $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_UPSCANADA_STATUS'");
      $this->_check = $check_query->RecordCount();
    }
    return $this->_check;
  }
  /**
   * Enter description here...
   *
   */
  function install() {
    global $db;
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable UPSCANADA Shipping', 'MODULE_SHIPPING_UPSCANADA_STATUS', 'True', 'Do you want to offer UPSCANADA shipping?', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('UPSCANADA Pickup Method', 'MODULE_SHIPPING_UPSCANADA_PICKUP', 'CC', 'How do you give packages to UPS? CC - Customer Counter, RDP - Daily Pickup, OTP - One Time Pickup, LC - Letter Center, OCA - On Call Air', '6', '0', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('UPS Packaging?', 'MODULE_SHIPPING_UPSCANADA_PACKAGE', 'CP', 'CP - Your Packaging, ULE - UPS Letter, UT - UPS Tube, UBE - UPS Express Box', '6', '0', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Residential Delivery?', 'MODULE_SHIPPING_UPSCANADA_RES', 'RES', 'Quote for Residential (RES) or Commercial Delivery (COM)', '6', '0', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Handling Fee', 'MODULE_SHIPPING_UPSCANADA_HANDLING', '0', 'Handling fee for this shipping method.', '6', '0', now())");
    $db->Execute("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_UPSCANADA_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'zen_get_tax_class_title', 'zen_cfg_pull_down_tax_classes(', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Tax Basis', 'MODULE_SHIPPING_UPSCANADA_TAX_BASIS', 'Shipping', 'On what basis is Shipping Tax calculated. Options are<br />Shipping - Based on customers Shipping Address<br />Billing Based on customers Billing address<br />Store - Based on Store address if Billing/Shipping Zone equals Store zone', '6', '0', 'zen_cfg_select_option(array(\'Shipping\', \'Billing\', \'Store\'), ', now())");
    $db->Execute("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_UPSCANADA_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort order of display.', 'MODULE_SHIPPING_UPSCANADA_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");
    // BOF: UPS USPS
    //      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ( 'Shipping Methods', 'MODULE_SHIPPING_UPSCANADA_TYPES', 'Nxt AM,Nxt AM Ltr,Nxt,Nxt Ltr,Nxt PR,Nxt Save,Nxt Save Ltr,2nd AM,2nd AM Ltr,2nd,2nd Ltr,3 Day Select,Ground,Canada,World Xp,World Xp Ltr, World Xp Plus,World Xp Plus Ltr,World Expedite', 'Select the USPS services to be offered.', '6', '13', 'zen_cfg_select_multioption(array(\'1DM\',\'1DML\', \'1DA\', \'1DAL\', \'1DAPI\', \'1DP\', \'1DPL\', \'2DM\', \'2DML\', \'2DA\', \'2DAL\', \'3DS\',\'GND\', \'STD\', \'XPR\', \'XPRL\', \'XDM\', \'XDML\', \'XPD\'), ', now() )");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ( 'Shipping Methods: <br />Nxt AM, Nxt AM Ltr, Nxt, Nxt Ltr, Nxt PR, Nxt Save, Nxt Save Ltr, 2nd AM, 2nd AM Ltr, 2nd, 2nd Ltr, 3 Day Select, Ground, Canada,World Xp, World Xp Ltr, World Xp Plus, World Xp Plus Ltr, World Expedite', 'MODULE_SHIPPING_UPSCANADA_TYPES', '1DM, 1DML, 1DA, 1DAL, 1DAPI, 1DP, 1DPL, 2DM, 2DML, 2DA, 2DAL, 3DS, GND, STD, XPR, XPRL, XDM, XDML, XPD', 'Select the UPS services to be offered.', '6', '13', 'zen_cfg_select_multioption(array(\'1DM\',\'1DML\', \'1DA\', \'1DAL\', \'1DAPI\', \'1DP\', \'1DPL\', \'2DM\', \'2DML\', \'2DA\', \'2DAL\', \'3DS\',\'GND\', \'STD\', \'XPR\', \'XPRL\', \'XDM\', \'XDML\', \'XPD\'), ', now() )");
    // EOF: UPS USPS
  }
  /**
   * Enter description here...
   *
   */
  function remove() {
    global $db;
    $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
  }
  /**
   * Enter description here...
   *
   * @return unknown
   */
  function keys() {
    return array('MODULE_SHIPPING_UPSCANADA_STATUS', 'MODULE_SHIPPING_UPSCANADA_PICKUP', 'MODULE_SHIPPING_UPSCANADA_PACKAGE', 'MODULE_SHIPPING_UPSCANADA_RES', 'MODULE_SHIPPING_UPSCANADA_HANDLING', 'MODULE_SHIPPING_UPSCANADA_TAX_CLASS', 'MODULE_SHIPPING_UPSCANADA_TAX_BASIS', 'MODULE_SHIPPING_UPSCANADA_ZONE', 'MODULE_SHIPPING_UPSCANADA_SORT_ORDER', 'MODULE_SHIPPING_UPSCANADA_TYPES');
  }
  /**
   * Enter description here...
   *
   * @param unknown_type $prod
   */
  function _upsProduct($prod){
    $this->_upsProductCode = $prod;
  }
  /**
   * Enter description here...
   *
   * @param unknown_type $postal
   * @param unknown_type $country
   */
  function _upsOrigin($postal, $country){
    $this->_upsOriginPostalCode = $postal;
    $this->_upsOriginCountryCode = $country;
  }
  /**
   * Enter description here...
   *
   * @param unknown_type $postal
   * @param unknown_type $country
   */
  function _upsDest($postal, $country){
    $postal = str_replace(' ', '', $postal);

    if ($country == 'US') {
      $this->_upsDestPostalCode = substr($postal, 0, 5);
    } else {
      $this->_upsDestPostalCode = $postal;
    }

    $this->_upsDestCountryCode = $country;
  }
  /**
   * Enter description here...
   *
   * @param unknown_type $foo
   */
  function _upsRate($foo) {
    switch ($foo) {
      case 'RDP':
      $this->_upsRateCode = 'Regular+Daily+Pickup';
      break;
      case 'OCA':
      $this->_upsRateCode = 'On+Call+Air';
      break;
      case 'OTP':
      $this->_upsRateCode = 'One+Time+Pickup';
      break;
      case 'LC':
      $this->_upsRateCode = 'Letter+Center';
      break;
      case 'CC':
      $this->_upsRateCode = 'Customer+Counter';
      break;
    }
  }
  /**
   * Enter description here...
   *
   * @param unknown_type $foo
   */
  function _upsContainer($foo) {
    switch ($foo) {
      case 'CP': // Customer Packaging
      $this->_upsContainerCode = '00';
      break;
      case 'ULE': // UPS Letter Envelope
      $this->_upsContainerCode = '01';
      break;
      case 'UT': // UPS Tube
      $this->_upsContainerCode = '03';
      break;
      case 'UEB': // UPS Express Box
      $this->_upsContainerCode = '21';
      break;
      case 'UW25': // UPS Worldwide 25 kilo
      $this->_upsContainerCode = '24';
      break;
      case 'UW10': // UPS Worldwide 10 kilo
      $this->_upsContainerCode = '25';
      break;
    }
  }
  /**
   * Enter description here...
   *
   * @param unknown_type $foo
   */
  function _upsWeight($foo) {
    $this->_upsPackageWeight = $foo;
  }
  /**
   * Enter description here...
   *
   * @param unknown_type $foo
   */
  function _upsRescom($foo) {
    switch ($foo) {
      case 'RES': // Residential Address
      $this->_upsResComCode = '1';
      break;
      case 'COM': // Commercial Address
      $this->_upsResComCode = '0';
      break;
    }
  }
  /**
   * Enter description here...
   *
   * @param unknown_type $action
   */
  function _upsAction($action) {
    /* 3 - Single Quote
    4 - All Available Quotes */

    $this->_upsActionCode = $action;
  }
  /**
   * Enter description here...
   *
   * @return unknown
   */
  function _upsGetQuote() {
    if (!isset($this->_upsActionCode)) $this->_upsActionCode = '4';

    $request = join('&', array('accept_UPS_license_agreement=yes',
    '10_action=' . $this->_upsActionCode,
    '13_product=' . $this->_upsProductCode,
    '14_origCountry=' . $this->_upsOriginCountryCode,
    '15_origPostal=' . $this->_upsOriginPostalCode,
    '19_destPostal=' . $this->_upsDestPostalCode,
    '22_destCountry=' . $this->_upsDestCountryCode,
    '23_weight=' . $this->_upsPackageWeight,
    '47_rate_chart=' . $this->_upsRateCode,
    '48_container=' . $this->_upsContainerCode,
    '49_residential=' . $this->_upsResComCode));
    $http = new httpClient();
    if ($http->Connect('www.ups.com', 80)) {
      $http->addHeader('Host', 'www.ups.com');
      $http->addHeader('User-Agent', 'Zen Cart');
      $http->addHeader('Connection', 'Close');

      if ($http->Get('/using/services/rave/qcostcgi.cgi?' . $request)) $body = $http->getBody();

      $http->Disconnect();
    } else {
      return 'error';
    }

    // BOF: UPS USPS
    /*
    TEST by checking out in the catalog; try a variety of shipping destinations to be sure
    your customers will be properly served.  If you are not getting any quotes, try enabling
    more alternatives in admin. Make sure your store's postal code is set in Admin ->
    Configuration -> Shipping/Packaging, since you won't get any quotes unless there is
    a origin that UPS recognizes.

    If you STILL don't get any quotes, here is a way to find out exactly what UPS is sending
    back in response to rate quote request.  At line 278, you will find this statement in a
    comment block:

    mail('[email protected]','UPS response',$body,'From: <[email protected]>');
    */
    // EOF: UPS USPS

    $body_array = explode("\n", $body);

    $returnval = array();
    $errorret = 'error'; // only return error if NO rates returned

    $n = sizeof($body_array);
    for ($i=0; $i<$n; $i++) {
      $result = explode('%', $body_array[$i]);
//print_r($result);
//die();
      $errcode = substr($result[0], -1);
      switch ($errcode) {
        case 3:
        if (is_array($returnval)) $returnval[] = array($result[1] => $result[8]);
        break;
        case 4:
        if (is_array($returnval)) $returnval[] = array($result[1] => $result[8]);
        break;
        case 5:
        $errorret = $result[1];
        break;
        case 6:
        if (is_array($returnval)) $returnval[] = array($result[3] => $result[10]);
        break;
      }
    }
    if (empty($returnval)) $returnval = $errorret;

    return $returnval;
  }
}
?>

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

1 Oct 2006, 7:09 PM
#8
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Error cloning a shipping module

This is the language file ...

Note: may need to tidy up these two files I just did them quick ...

<?php
//
// +----------------------------------------------------------------------+
// |zen-cart Open Source E-commerce                                       |
// +----------------------------------------------------------------------+
// | Copyright (c) 2003 The zen-cart developers                           |
// |                                                                      |
// | http://www.zen-cart.com/index.php                                    |
// |                                                                      |
// | Portions Copyright (c) 2003 osCommerce                               |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license,       |
// | that is bundled with this package in the file LICENSE, and is        |
// | available through the world-wide-web at the following url:           |
// | http://www.zen-cart.com/license/2_0.txt.                             |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to       |
// | [email protected] so we can mail you a copy immediately.          |
// +----------------------------------------------------------------------+
// $Id: ups.php 1969 2005-09-13 06:57:21Z drbyte $
//

define('MODULE_SHIPPING_UPSCANADA_TEXT_TITLE', 'United Parcel Service');
define('MODULE_SHIPPING_UPSCANADA_TEXT_DESCRIPTION', 'United Parcel Service');
define('MODULE_SHIPPING_UPSCANADA_TEXT_OPT_GND', 'UPSCANADA Ground');
define('MODULE_SHIPPING_UPSCANADA_TEXT_OPT_1DM', 'Next Day Air Early AM');
define('MODULE_SHIPPING_UPSCANADA_TEXT_OPT_1DA', 'Next Day Air');
define('MODULE_SHIPPING_UPSCANADA_TEXT_OPT_1DP', 'Next Day Air Saver');
define('MODULE_SHIPPING_UPSCANADA_TEXT_OPT_2DM', '2nd Day Air Early AM');
define('MODULE_SHIPPING_UPSCANADA_TEXT_OPT_3DS', '3 Day Select');
define('MODULE_SHIPPING_UPSCANADA_TEXT_OPT_STD', 'Canada Standard');
define('MODULE_SHIPPING_UPSCANADA_TEXT_OPT_XPR', 'Worldwide Express');
define('MODULE_SHIPPING_UPSCANADA_TEXT_OPT_XDM', 'Worldwide Express Plus');
define('MODULE_SHIPPING_UPSCANADA_TEXT_OPT_XPD', 'Worldwide Expedited');
?>

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

1 Oct 2006, 8:31 PM
#9
brain21 avatar

brain21

New Zenner

Join Date:
Sep 2006
Posts:
42
Plugin Contributions:
0

Re: Error cloning a shipping module

Thanks for the files. OK, so I figured out from your files what my problem was. I had

function ups()

instead of

function upscanada()

THANK YOU!

OK, so now they both show up. I click on install for the Canada one.

Set up the shipping methods. For the Zone I select the one that I created:

Shp:CA. When I click on update I get the orange circle. I also get the orange circle next to the regular old UPS one as well.

I created the Shp: CA by:

Admin->Zones Definitions
insert
Zone name = Shp: CA
Descriptions = shipping to Canada
insert
Select Shp: CA
Details
Insert
Country: = Canada
Zones: = All Zones

So I save this all up. Did I do this right?

Now I searched the forums and found someone else having the same problem with the USPS module. They were told that this means that the module is installed, but it's status is set to "false" and that they should set

Enable USPS Shipping = True

ummmm... Where? IF this means when you click on "Edit" both modules are already set to True. I don't think that this is because of a conflict either because the regular OLD ups gave me the same thing when I had the UPSCanada stuff removed (& renamed the files too).

I looked through all of the .php files that I could find and the UPS and UPSCANADA statuses were all set to true. So is there somewhere else in the admin interface where I need to set this, cause I have looked and looked and not found anything.

If I set the shipping zone to Shp: The rest of the world

Then all of a sudden the status circle is green

Thanks,

Brain21

2 Oct 2006, 1:37 AM
#10
brain21 avatar

brain21

New Zenner

Join Date:
Sep 2006
Posts:
42
Plugin Contributions:
0

Re: Error cloning a shipping module

OK, the problem seems to not be with the shipping modules, but rather the zone definitions (?) If I select "none" for the shipping zone it works. If I select "The rest of the world" for the shipping zone it works. Same behavior with the other modules.

I described in my last post the manner in which I set up the shipping modules.

Also, I now have UPS and Flat Rate shipping enabled for this testing. Only the Flat Rate shipping numbers are showing.

I get "We are unable to obtain a rate quote for UPS shipping.
Please contact the store if no other alternative is shown"

on the shipping screen. :-(

My parents have a UPS account. Is there something more that needs to be done? There seems to be no way to enter in the rates (my parents wish to do it by price - is this something that is NOT possible with the UPS shipping module?).

I was thinking about using the MZMT module, but I run into the same problems in the zones...

Thanks,

Brain21

2 Oct 2006, 1:53 AM
#11
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Error cloning a shipping module

Where are you shipping from?

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

2 Oct 2006, 2:56 AM
#12
brain21 avatar

brain21

New Zenner

Join Date:
Sep 2006
Posts:
42
Plugin Contributions:
0

Re: Error cloning a shipping module

Shipping from a Maryland zip code - 20878 for test purposes

2 Oct 2006, 3:38 AM
#13
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Error cloning a shipping module

UPS gets the Real Time quotes ... there are no rates to enter ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

2 Oct 2006, 3:54 AM
#14
brain21 avatar

brain21

New Zenner

Join Date:
Sep 2006
Posts:
42
Plugin Contributions:
0

Re: Error cloning a shipping module

OK, now it's getting weird...

I decided to enable flat-rate shipping for testing purposes (this is not on a live site).

I set ups and upscanada to enabled=false.

I set MZMT on. I enabled zone 1 with shipping based on price, & zone2 as well. Both zones are identical with the following exceptions:

Zone1 = Shp: US

Zone2= Shp:CA and has a $10 handling fee.

I have price tables for the zones.

I update the MZMT. I get the orange dot (circle) next to it (if I switch those shipping zones to none or "the rest of the world" I get a green circle instead of the yellow one).

IOW, I am using the 2 pre-defined shipping zones that were/are "breaking" the UPS and UPS Canada modules.

So I put some free test items in my cart. I click on estimate shipping.

That window pops up and is interesting:

Warning: constant() [function.constant]: Couldn't find constant MODULE_SHIPPING_MZMT_GEOZONE_1_TABLE_4_TEXT_WAY in C:\Program Files\xampp\htdocs\connequestrian\store\includes\modules\shipping\mzmt.php on line 125

(I haven't really looked into the error yet)

Then below it I have my shipping table. The options shown are

Flat Rate (Best Way) - $35.00
United Parcel Service (UPS) (Ground) - $9.95
United Parcel Service (UPS) (Second Day) - $14.95
United Parcel Service (UPS) (Next Day) - $17.95
United Parcel Service (UPS) () - $22.95

WHAT?!?

OK, my UPS modules are turned OFF. MZMT, as far as I know, has no way of knowing what these rates are. These numbers MUST be coming from the ups module, but it is set to enabled=false!!!!! When I turn it on, I get nothing in this estimator!

That being said, why is the last option (3 day shipping) showing as "()" unlike the others?

The $$ amounts are all correct.

I also have the sort order for flat rate to 3 and ups is 1

Why is it (ALWAYS) showing the Flat-Rate as "Best Way" when it is obviously not?

So what exactly is going on here? It looks like shipping has just gone haywire!!!

BTW, running latest (1.3.5?) of ZenCart if that makes any difference.

This is just nuts.

And is there anyway to change the look & feel (other than stylesheets) for these pages? The reason I ask is that I would like to, per page, change the style name.

For example, if the "Home" link text on the shipping page is class="homeLink" and I use a style sheet to place it elsewhere on the page, it is very likely that on the checkout page, the same link has the same class. What if on the checkout page I want to place it somewhere else? I would like to do something like

class="shippingHomeLink" for the shipping page and
class="checkoutHomeLink" for the checkout page

What if I want to change that text to an image (button)?

Anyway, I'm hijacking my own thread!

Thanks,

Brain21

2 Oct 2006, 4:11 AM
#15
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Error cloning a shipping module

Each shipping module has a matching language module ...

You can edit that to anything you want it to read ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

2 Oct 2006, 4:14 AM
#16
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Error cloning a shipping module

/includes/modules/shipping/ups.php is also being changed to prevent the weight from being altered and to ensure at least .1 is sent to UPS for a quote ...

Use this code and see if it helps with conflicts on your shipping weights:

<?php
/**
 * @package shippingMethod
 * @copyright Copyright 2003-2005 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: ups.php 4633 2006-09-30 14:53:59Z ajeh $
 */
/**
 * Enter description here...
 *
 */
class ups extends base {
  /**
   * Enter description here...
   *
   * @var unknown_type
   */
  var $code;
  /**
   * Enter description here...
   *
   * @var unknown_type
   */
  var $title;
  /**
   * Enter description here...
   *
   * @var unknown_type
   */
  var $description;
  /**
   * Enter description here...
   *
   * @var unknown_type
   */
  var $icon;
  /**
   * Enter description here...
   *
   * @var unknown_type
   */
  var $enabled;
  /**
   * Enter description here...
   *
   * @var unknown_type
   */
  var $types;
  /**
   * Enter description here...
   *
   * @return ups
   */
  function ups() {
    global $order, $db, $template;

    $this->code = 'ups';
    $this->title = MODULE_SHIPPING_UPS_TEXT_TITLE;
    $this->description = MODULE_SHIPPING_UPS_TEXT_DESCRIPTION;
    $this->sort_order = MODULE_SHIPPING_UPS_SORT_ORDER;
    $this->icon = $template->get_template_dir('shipping_ups.gif', DIR_WS_TEMPLATE, $current_page_base,'images/icons'). '/' . 'shipping_ups.gif';
    $this->tax_class = MODULE_SHIPPING_UPS_TAX_CLASS;
    $this->tax_basis = MODULE_SHIPPING_UPS_TAX_BASIS;

    // disable only when entire cart is free shipping
    if (zen_get_shipping_enabled($this->code)) {
      $this->enabled = ((MODULE_SHIPPING_UPS_STATUS == 'True') ? true : false);
    }

    if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_UPS_ZONE > 0) ) {
      $check_flag = false;
      $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_UPS_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;
      }
    }

    $this->types = array('1DM' => 'Next Day Air Early AM',
    '1DML' => 'Next Day Air Early AM Letter',
    '1DA' => 'Next Day Air',
    '1DAL' => 'Next Day Air Letter',
    '1DAPI' => 'Next Day Air Intra (Puerto Rico)',
    '1DP' => 'Next Day Air Saver',
    '1DPL' => 'Next Day Air Saver Letter',
    '2DM' => '2nd Day Air AM',
    '2DML' => '2nd Day Air AM Letter',
    '2DA' => '2nd Day Air',
    '2DAL' => '2nd Day Air Letter',
    '3DS' => '3 Day Select',
    'GND' => 'Ground',
    'GNDCOM' => 'Ground Commercial',
    'GNDRES' => 'Ground Residential',
    'STD' => 'Canada Standard',
    'XPR' => 'Worldwide Express',
    'XPRL' => 'worldwide Express Letter',
    'XDM' => 'Worldwide Express Plus',
    'XDML' => 'Worldwide Express Plus Letter',
    'XPD' => 'Worldwide Expedited');
  }
  /**
   * Enter description here...
   *
   * @param unknown_type $method
   * @return unknown
   */
  function quote($method = '') {
    global $_POST, $order, $shipping_weight, $shipping_num_boxes;

    if ( (zen_not_null($method)) && (isset($this->types[$method])) ) {
      $prod = $method;
      // BOF: UPS USPS
    } else if ($order->delivery['country']['iso_code_2'] == 'CA') {
      $prod = 'STD';
      // EOF: UPS USPS
    } else {
      $prod = 'GNDRES';
    }

    if ($method) $this->_upsAction('3'); // return a single quote

    $this->_upsProduct($prod);

    $ups_shipping_weight = ($shipping_weight < 0.1 ? 0.1 : $shipping_weight);

    $country_name = zen_get_countries(SHIPPING_ORIGIN_COUNTRY, true);
    $this->_upsOrigin(SHIPPING_ORIGIN_ZIP, $country_name['countries_iso_code_2']);
    $this->_upsDest($order->delivery['postcode'], $order->delivery['country']['iso_code_2']);
    $this->_upsRate(MODULE_SHIPPING_UPS_PICKUP);
    $this->_upsContainer(MODULE_SHIPPING_UPS_PACKAGE);
    $this->_upsWeight($ups_shipping_weight);
    $this->_upsRescom(MODULE_SHIPPING_UPS_RES);
    $upsQuote = $this->_upsGetQuote();

    if ( (is_array($upsQuote)) && (sizeof($upsQuote) > 0) ) {
      switch (SHIPPING_BOX_WEIGHT_DISPLAY) {
        case (0):
        $show_box_weight = '';
        break;
        case (1):
        $show_box_weight = ' (' . $shipping_num_boxes . ' ' . TEXT_SHIPPING_BOXES . ')';
        break;
        case (2):
        $show_box_weight = ' (' . number_format($ups_shipping_weight * $shipping_num_boxes,2) . TEXT_SHIPPING_WEIGHT . ')';
        break;
        default:
        $show_box_weight = ' (' . $shipping_num_boxes . ' x ' . number_format($ups_shipping_weight,2) . TEXT_SHIPPING_WEIGHT . ')';
        break;
      }
      $this->quotes = array('id' => $this->code,
      'module' => $this->title . $show_box_weight);

      $methods = array();
      // BOF: UPS USPS
      $allowed_methods = explode(", ", MODULE_SHIPPING_UPS_TYPES);
      $std_rcd = false;
      // EOF: UPS USPS
      $qsize = sizeof($upsQuote);
      for ($i=0; $i<$qsize; $i++) {
        list($type, $cost) = each($upsQuote[$i]);
        // BOF: UPS USPS
        if ($type=='STD') {
          if ($std_rcd) continue;
          else $std_rcd = true;
        }
        if (!in_array($type, $allowed_methods)) continue;
        // EOF: UPS USPS
        $methods[] = array('id' => $type,
        'title' => $this->types[$type],
        'cost' => ($cost + MODULE_SHIPPING_UPS_HANDLING) * $shipping_num_boxes);
      }

      $this->quotes['methods'] = $methods;

      if ($this->tax_class > 0) {
        $this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
      }
    } else {
      /* ORIGINAL
      $this->quotes = array('module' => $this->title,
      'error' => 'An error occurred with the UPS shipping calculations.<br />' . $upsQuote . '<br />If you prefer to use UPS as your shipping method, please contact the store owner.');
      */
      // BOF: UPS USPS
      $this->quotes = array('module' => $this->title,
      'error' => 'We are unable to obtain a rate quote for UPS shipping.<br />Please contact the store if no other alternative is shown.');
      // EOF: UPS USPS
    }

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

    return $this->quotes;
  }
  /**
   * Enter description here...
   *
   * @return unknown
   */
  function check() {
    global $db;
    if (!isset($this->_check)) {
      $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_UPS_STATUS'");
      $this->_check = $check_query->RecordCount();
    }
    return $this->_check;
  }
  /**
   * Enter description here...
   *
   */
  function install() {
    global $db;
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable UPS Shipping', 'MODULE_SHIPPING_UPS_STATUS', 'True', 'Do you want to offer UPS shipping?', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('UPS Pickup Method', 'MODULE_SHIPPING_UPS_PICKUP', 'CC', 'How do you give packages to UPS? CC - Customer Counter, RDP - Daily Pickup, OTP - One Time Pickup, LC - Letter Center, OCA - On Call Air', '6', '0', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('UPS Packaging?', 'MODULE_SHIPPING_UPS_PACKAGE', 'CP', 'CP - Your Packaging, ULE - UPS Letter, UT - UPS Tube, UBE - UPS Express Box', '6', '0', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Residential Delivery?', 'MODULE_SHIPPING_UPS_RES', 'RES', 'Quote for Residential (RES) or Commercial Delivery (COM)', '6', '0', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Handling Fee', 'MODULE_SHIPPING_UPS_HANDLING', '0', 'Handling fee for this shipping method.', '6', '0', now())");
    $db->Execute("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_UPS_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'zen_get_tax_class_title', 'zen_cfg_pull_down_tax_classes(', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Tax Basis', 'MODULE_SHIPPING_UPS_TAX_BASIS', 'Shipping', 'On what basis is Shipping Tax calculated. Options are<br />Shipping - Based on customers Shipping Address<br />Billing Based on customers Billing address<br />Store - Based on Store address if Billing/Shipping Zone equals Store zone', '6', '0', 'zen_cfg_select_option(array(\'Shipping\', \'Billing\', \'Store\'), ', now())");
    $db->Execute("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_UPS_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort order of display.', 'MODULE_SHIPPING_UPS_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");
    // BOF: UPS USPS
    //      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ( 'Shipping Methods', 'MODULE_SHIPPING_UPS_TYPES', 'Nxt AM,Nxt AM Ltr,Nxt,Nxt Ltr,Nxt PR,Nxt Save,Nxt Save Ltr,2nd AM,2nd AM Ltr,2nd,2nd Ltr,3 Day Select,Ground,Canada,World Xp,World Xp Ltr, World Xp Plus,World Xp Plus Ltr,World Expedite', 'Select the USPS services to be offered.', '6', '13', 'zen_cfg_select_multioption(array(\'1DM\',\'1DML\', \'1DA\', \'1DAL\', \'1DAPI\', \'1DP\', \'1DPL\', \'2DM\', \'2DML\', \'2DA\', \'2DAL\', \'3DS\',\'GND\', \'STD\', \'XPR\', \'XPRL\', \'XDM\', \'XDML\', \'XPD\'), ', now() )");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ( 'Shipping Methods: <br />Nxt AM, Nxt AM Ltr, Nxt, Nxt Ltr, Nxt PR, Nxt Save, Nxt Save Ltr, 2nd AM, 2nd AM Ltr, 2nd, 2nd Ltr, 3 Day Select, Ground, Canada,World Xp, World Xp Ltr, World Xp Plus, World Xp Plus Ltr, World Expedite', 'MODULE_SHIPPING_UPS_TYPES', '1DM, 1DML, 1DA, 1DAL, 1DAPI, 1DP, 1DPL, 2DM, 2DML, 2DA, 2DAL, 3DS, GND, STD, XPR, XPRL, XDM, XDML, XPD', 'Select the UPS services to be offered.', '6', '13', 'zen_cfg_select_multioption(array(\'1DM\',\'1DML\', \'1DA\', \'1DAL\', \'1DAPI\', \'1DP\', \'1DPL\', \'2DM\', \'2DML\', \'2DA\', \'2DAL\', \'3DS\',\'GND\', \'STD\', \'XPR\', \'XPRL\', \'XDM\', \'XDML\', \'XPD\'), ', now() )");
    // EOF: UPS USPS
  }
  /**
   * Enter description here...
   *
   */
  function remove() {
    global $db;
    $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
  }
  /**
   * Enter description here...
   *
   * @return unknown
   */
  function keys() {
    return array('MODULE_SHIPPING_UPS_STATUS', 'MODULE_SHIPPING_UPS_PICKUP', 'MODULE_SHIPPING_UPS_PACKAGE', 'MODULE_SHIPPING_UPS_RES', 'MODULE_SHIPPING_UPS_HANDLING', 'MODULE_SHIPPING_UPS_TAX_CLASS', 'MODULE_SHIPPING_UPS_TAX_BASIS', 'MODULE_SHIPPING_UPS_ZONE', 'MODULE_SHIPPING_UPS_SORT_ORDER', 'MODULE_SHIPPING_UPS_TYPES');
  }
  /**
   * Enter description here...
   *
   * @param unknown_type $prod
   */
  function _upsProduct($prod){
    $this->_upsProductCode = $prod;
  }
  /**
   * Enter description here...
   *
   * @param unknown_type $postal
   * @param unknown_type $country
   */
  function _upsOrigin($postal, $country){
    $this->_upsOriginPostalCode = $postal;
    $this->_upsOriginCountryCode = $country;
  }
  /**
   * Enter description here...
   *
   * @param unknown_type $postal
   * @param unknown_type $country
   */
  function _upsDest($postal, $country){
    $postal = str_replace(' ', '', $postal);

    if ($country == 'US') {
      $this->_upsDestPostalCode = substr($postal, 0, 5);
    } else {
      $this->_upsDestPostalCode = $postal;
    }

    $this->_upsDestCountryCode = $country;
  }
  /**
   * Enter description here...
   *
   * @param unknown_type $foo
   */
  function _upsRate($foo) {
    switch ($foo) {
      case 'RDP':
      $this->_upsRateCode = 'Regular+Daily+Pickup';
      break;
      case 'OCA':
      $this->_upsRateCode = 'On+Call+Air';
      break;
      case 'OTP':
      $this->_upsRateCode = 'One+Time+Pickup';
      break;
      case 'LC':
      $this->_upsRateCode = 'Letter+Center';
      break;
      case 'CC':
      $this->_upsRateCode = 'Customer+Counter';
      break;
    }
  }
  /**
   * Enter description here...
   *
   * @param unknown_type $foo
   */
  function _upsContainer($foo) {
    switch ($foo) {
      case 'CP': // Customer Packaging
      $this->_upsContainerCode = '00';
      break;
      case 'ULE': // UPS Letter Envelope
      $this->_upsContainerCode = '01';
      break;
      case 'UT': // UPS Tube
      $this->_upsContainerCode = '03';
      break;
      case 'UEB': // UPS Express Box
      $this->_upsContainerCode = '21';
      break;
      case 'UW25': // UPS Worldwide 25 kilo
      $this->_upsContainerCode = '24';
      break;
      case 'UW10': // UPS Worldwide 10 kilo
      $this->_upsContainerCode = '25';
      break;
    }
  }
  /**
   * Enter description here...
   *
   * @param unknown_type $foo
   */
  function _upsWeight($foo) {
    $this->_upsPackageWeight = $foo;
  }
  /**
   * Enter description here...
   *
   * @param unknown_type $foo
   */
  function _upsRescom($foo) {
    switch ($foo) {
      case 'RES': // Residential Address
      $this->_upsResComCode = '1';
      break;
      case 'COM': // Commercial Address
      $this->_upsResComCode = '0';
      break;
    }
  }
  /**
   * Enter description here...
   *
   * @param unknown_type $action
   */
  function _upsAction($action) {
    /* 3 - Single Quote
    4 - All Available Quotes */

    $this->_upsActionCode = $action;
  }
  /**
   * Enter description here...
   *
   * @return unknown
   */
  function _upsGetQuote() {
    if (!isset($this->_upsActionCode)) $this->_upsActionCode = '4';

    $request = join('&', array('accept_UPS_license_agreement=yes',
    '10_action=' . $this->_upsActionCode,
    '13_product=' . $this->_upsProductCode,
    '14_origCountry=' . $this->_upsOriginCountryCode,
    '15_origPostal=' . $this->_upsOriginPostalCode,
    '19_destPostal=' . $this->_upsDestPostalCode,
    '22_destCountry=' . $this->_upsDestCountryCode,
    '23_weight=' . $this->_upsPackageWeight,
    '47_rate_chart=' . $this->_upsRateCode,
    '48_container=' . $this->_upsContainerCode,
    '49_residential=' . $this->_upsResComCode));
    $http = new httpClient();
    if ($http->Connect('www.ups.com', 80)) {
      $http->addHeader('Host', 'www.ups.com');
      $http->addHeader('User-Agent', 'Zen Cart');
      $http->addHeader('Connection', 'Close');

      if ($http->Get('/using/services/rave/qcostcgi.cgi?' . $request)) $body = $http->getBody();

      $http->Disconnect();
    } else {
      return 'error';
    }

    // BOF: UPS USPS
    /*
    TEST by checking out in the catalog; try a variety of shipping destinations to be sure
    your customers will be properly served.  If you are not getting any quotes, try enabling
    more alternatives in admin. Make sure your store's postal code is set in Admin ->
    Configuration -> Shipping/Packaging, since you won't get any quotes unless there is
    a origin that UPS recognizes.

    If you STILL don't get any quotes, here is a way to find out exactly what UPS is sending
    back in response to rate quote request.  At line 278, you will find this statement in a
    comment block:

    mail('[email protected]','UPS response',$body,'From: <[email protected]>');
    */
    // EOF: UPS USPS

    $body_array = explode("\n", $body);

    $returnval = array();
    $errorret = 'error'; // only return error if NO rates returned

    $n = sizeof($body_array);
    for ($i=0; $i<$n; $i++) {
      $result = explode('%', $body_array[$i]);
//print_r($result);
//die();
      $errcode = substr($result[0], -1);
      switch ($errcode) {
        case 3:
        if (is_array($returnval)) $returnval[] = array($result[1] => $result[8]);
        break;
        case 4:
        if (is_array($returnval)) $returnval[] = array($result[1] => $result[8]);
        break;
        case 5:
        $errorret = $result[1];
        break;
        case 6:
        if (is_array($returnval)) $returnval[] = array($result[3] => $result[10]);
        break;
      }
    }
    if (empty($returnval)) $returnval = $errorret;

    return $returnval;
  }
}
?>

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

2 Oct 2006, 3:53 PM
#17
brain21 avatar

brain21

New Zenner

Join Date:
Sep 2006
Posts:
42
Plugin Contributions:
0

Re: Error cloning a shipping module

OK, I'm not using weight for the delimeter for shipping. I'm using price.

However, I looked at the MZMT.php module in the languages/english directory.

AHA! So, UPS is turned off. In the English module for MZMT it shows (I didn't enter this info in, so I'm not positive how it got there) the following:

define('MODULE_SHIPPING_MZMT_GEOZONE_1_TEXT_TITLE', 'United Parcel Service (UPS)');
define('MODULE_SHIPPING_MZMT_GEOZONE_1_ICON', 'shipping_ups.gif');
define('MODULE_SHIPPING_MZMT_GEOZONE_1_TABLE_1_TEXT_WAY', 'Ground');
define('MODULE_SHIPPING_MZMT_GEOZONE_1_TABLE_2_TEXT_WAY', 'Second Day');
define('MODULE_SHIPPING_MZMT_GEOZONE_1_TABLE_3_TEXT_WAY', 'Next Day');

There should be 4 entreis there as that is what I put in in the module under admin. So I can just add it, and put in 3 day, and that will fix the "90" problem

For the GEOZONE_2 stuff, the text is all blank. So I fix that by adding in the text (UPS to Canada) and that should fix it all.

I still don't understand why I have the yellow circle next to the MZMT module, yet it is enabled... and why does MZMT apparently work w/ a yellow circle next to it and UPS doesn't?

Thanks for pointing me in the right direction!

Brain21

2 Oct 2006, 4:15 PM
#18
brain21 avatar

brain21

New Zenner

Join Date:
Sep 2006
Posts:
42
Plugin Contributions:
0

Re: Error cloning a shipping module

OK, this seems to have fixed everything. Looks like some sort of bug in MZMT.

I also noticed that the sort order for the shipping modules was off. I had flat-rate shipping as 3 and MZMT as 0. Flat rate was at the top of the list. I switched MZMT from a sort orcer of 0 to 1 and now MZMT shows up first.

Ran through the checkout procedure and it all seems working!

Thanks for all the help!

Brain21