Page 1 of 2 12 LastLast
Results 1 to 10 of 16
  1. #1
    Join Date
    Feb 2007
    Posts
    819
    Plugin Contributions
    0

    Default how to have different two diff table rates?

    hi,

    i would like to have two table rates. one table will reflect priority shipping rates (more $) and the other table will reflect parcel table rates (less $). all based on order $ amount.

    how do i do that?

    i am thinking i should clone the table.php shipping module??? maybe call one tablepriority.php and the other tableparcel.php???

    and if i do that, what do i rename from table to tableparcel (in the php file itself)???


    thanks

  2. #2
    Join Date
    Feb 2007
    Posts
    819
    Plugin Contributions
    0

    Default Re: how to have different two diff table rates?

    Update:

    I tried saving the table.php as a new duplicate file called tableparcel.php and then renaming every instance of: MODULE_SHIPPING_TABLE to MODULE_SHIPPING_TABLEPARCEL, but that hasn't worked.

    I get this error in admin: Fatal error: Cannot redeclare class table

    The code is below. Does anyone know what else I should change?



    Code:
     
    <?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: table.php 6347 2007-05-20 19:46:59Z ajeh $
     */
    /**
     * Enter description here...
     *
     */
    class table 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...
       *
       * @return table
       */
      function table() {
        global $order, $db;
        $this->code = 'table';
        $this->title = MODULE_SHIPPING_TABLEPARCEL_TEXT_TITLE;
        $this->description = MODULE_SHIPPING_TABLEPARCEL_TEXT_DESCRIPTION;
        $this->sort_order = MODULE_SHIPPING_TABLEPARCEL_SORT_ORDER;
        $this->icon = '';
        $this->tax_class = MODULE_SHIPPING_TABLEPARCEL_TAX_CLASS;
        $this->tax_basis = MODULE_SHIPPING_TABLEPARCEL_TAX_BASIS;
        // disable only when entire cart is free shipping
        if (zen_get_shipping_enabled($this->code)) {
          $this->enabled = ((MODULE_SHIPPING_TABLEPARCEL_STATUS == 'True') ? true : false);
        }
        if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_TABLEPARCEL_ZONE > 0) ) {
          $check_flag = false;
          $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_TABLEPARCEL_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;
          }
        }
      }
      /**
       * Enter description here...
       *
       * @param unknown_type $method
       * @return unknown
       */
      function quote($method = '') {
        global $order, $shipping_weight, $shipping_num_boxes, $total_count;
        // shipping adjustment
        switch (MODULE_SHIPPING_TABLEPARCEL_MODE) {
          case ('price'):
            $order_total = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ;
            break;
          case ('weight'):
            $order_total = $shipping_weight;
            break;
          case ('item'):
            $order_total = $total_count - $_SESSION['cart']->free_shipping_items();
            break;
        }
        $order_total_amount = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ;
        $table_cost = split("[:,]" , MODULE_SHIPPING_TABLEPARCEL_COST);
        $size = sizeof($table_cost);
        for ($i=0, $n=$size; $i<$n; $i+=2) {
          if (round($order_total,9) <= $table_cost[$i]) {
            if (strstr($table_cost[$i+1], '%')) {
              $shipping = ($table_cost[$i+1]/100) * $order_total_amount;
            } else {
              $shipping = $table_cost[$i+1];
            }
            break;
          }
        }
        if (MODULE_SHIPPING_TABLEPARCEL_MODE == 'weight') {
          $shipping = $shipping * $shipping_num_boxes;
          // show boxes if weight
          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($shipping_weight * $shipping_num_boxes,2) . TEXT_SHIPPING_WEIGHT . ')';
            break;
            default:
            $show_box_weight = ' (' . $shipping_num_boxes . ' x ' . number_format($shipping_weight,2) . TEXT_SHIPPING_WEIGHT . ')';
            break;
          }
        }
        $this->quotes = array('id' => $this->code,
        'module' => MODULE_SHIPPING_TABLEPARCEL_TEXT_TITLE . $show_box_weight,
        'methods' => array(array('id' => $this->code,
        'title' => MODULE_SHIPPING_TABLEPARCEL_TEXT_WAY,
        'cost' => $shipping + MODULE_SHIPPING_TABLEPARCEL_HANDLING)));
        if ($this->tax_class > 0) {
          $this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
        }
        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_TABLEPARCEL_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 Table Method', 'MODULE_SHIPPING_TABLEPARCEL_STATUS', 'True', 'Do you want to offer table rate 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, set_function, date_added) values ('Shipping Table', 'MODULE_SHIPPING_TABLEPARCEL_COST', '25:8.50,50:5.50,10000:0.00', 'The shipping cost is based on the total cost or weight of items or count of the items. Example: 25:8.50,50:5.50,etc.. Up to 25 charge 8.50, from there to 50 charge 5.50, etc<br />You can end the last amount as 10000:7% to charge 7% of the Order Total', '6', '0', 'zen_cfg_textarea(', 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 ('Table Method', 'MODULE_SHIPPING_TABLEPARCEL_MODE', 'weight', 'The shipping cost is based on the order total or the total weight of the items ordered or the total number of items orderd.', '6', '0', 'zen_cfg_select_option(array(\'weight\', \'price\', \'item\'), ', 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_TABLEPARCEL_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_TABLEPARCEL_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_TABLEPARCEL_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_TABLEPARCEL_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', 'MODULE_SHIPPING_TABLEPARCEL_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
      }
      /**
       * 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_TABLEPARCEL_STATUS', 'MODULE_SHIPPING_TABLEPARCEL_COST', 'MODULE_SHIPPING_TABLEPARCEL_MODE', 'MODULE_SHIPPING_TABLEPARCEL_HANDLING', 'MODULE_SHIPPING_TABLEPARCEL_TAX_CLASS', 'MODULE_SHIPPING_TABLEPARCEL_TAX_BASIS', 'MODULE_SHIPPING_TABLEPARCEL_ZONE', 'MODULE_SHIPPING_TABLEPARCEL_SORT_ORDER');
      }
    }
    ?>
    thanks.

  3. #3
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: how to have different two diff table rates?

    You appear to have used:
    TABLEPARCEL for TABLE
    tableparcel for table

    But you left the class itself called:
    table

    Everything needs to be changed ...

    NOTE: be careful to NOT change the references to true database table names on these replaces ...
    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!

  4. #4
    Join Date
    Feb 2007
    Posts
    819
    Plugin Contributions
    0

    Default Re: how to have different two diff table rates?

    Hi Ajeh,

    Thanks for responding. My bad, I did change the table and table to tableparcel in the code above but I copied it before I finished.

    class table extends base > class tableparcel extends base

    and

    $this->code = 'table'; > $this->code = 'tableparcel';


    I still get this error:
    Fatal error: Cannot redeclare class tableparcel in

    What else do I have to change?

    Thanks.

  5. #5
    Join Date
    Feb 2007
    Posts
    819
    Plugin Contributions
    0

    Default Re: how to have different two diff table rates?

    I still get this error:
    Fatal error: Cannot redeclare class tableparcel in

    Anyone else have an idea one what i need to change to successfully clone the table rates?


    Thanks.

    Code:
     
    <?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: table.php 6347 2007-05-20 19:46:59Z ajeh $
     */
    /**
     * Enter description here...
     *
     */
    class tableparcel 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...
       *
       * @return table
       */
      function tableparcel() {
        global $order, $db;
        $this->code = 'tableparcel';
        $this->title = MODULE_SHIPPING_TABLEPARCEL_TEXT_TITLE;
        $this->description = MODULE_SHIPPING_TABLEPARCEL_TEXT_DESCRIPTION;
        $this->sort_order = MODULE_SHIPPING_TABLEPARCEL_SORT_ORDER;
        $this->icon = '';
        $this->tax_class = MODULE_SHIPPING_TABLEPARCEL_TAX_CLASS;
        $this->tax_basis = MODULE_SHIPPING_TABLEPARCEL_TAX_BASIS;
        // disable only when entire cart is free shipping
        if (zen_get_shipping_enabled($this->code)) {
          $this->enabled = ((MODULE_SHIPPING_TABLEPARCEL_STATUS == 'True') ? true : false);
        }
        if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_TABLEPARCEL_ZONE > 0) ) {
          $check_flag = false;
          $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_TABLEPARCEL_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;
          }
        }
      }
      /**
       * Enter description here...
       *
       * @param unknown_type $method
       * @return unknown
       */
      function quote($method = '') {
        global $order, $shipping_weight, $shipping_num_boxes, $total_count;
        // shipping adjustment
        switch (MODULE_SHIPPING_TABLEPARCEL_MODE) {
          case ('price'):
            $order_total = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ;
            break;
          case ('weight'):
            $order_total = $shipping_weight;
            break;
          case ('item'):
            $order_total = $total_count - $_SESSION['cart']->free_shipping_items();
            break;
        }
        $order_total_amount = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ;
        $table_cost = split("[:,]" , MODULE_SHIPPING_TABLEPARCEL_COST);
        $size = sizeof($table_cost);
        for ($i=0, $n=$size; $i<$n; $i+=2) {
          if (round($order_total,9) <= $table_cost[$i]) {
            if (strstr($table_cost[$i+1], '%')) {
              $shipping = ($table_cost[$i+1]/100) * $order_total_amount;
            } else {
              $shipping = $table_cost[$i+1];
            }
            break;
          }
        }
        if (MODULE_SHIPPING_TABLEPARCEL_MODE == 'weight') {
          $shipping = $shipping * $shipping_num_boxes;
          // show boxes if weight
          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($shipping_weight * $shipping_num_boxes,2) . TEXT_SHIPPING_WEIGHT . ')';
            break;
            default:
            $show_box_weight = ' (' . $shipping_num_boxes . ' x ' . number_format($shipping_weight,2) . TEXT_SHIPPING_WEIGHT . ')';
            break;
          }
        }
        $this->quotes = array('id' => $this->code,
        'module' => MODULE_SHIPPING_TABLEPARCEL_TEXT_TITLE . $show_box_weight,
        'methods' => array(array('id' => $this->code,
        'title' => MODULE_SHIPPING_TABLEPARCEL_TEXT_WAY,
        'cost' => $shipping + MODULE_SHIPPING_TABLEPARCEL_HANDLING)));
        if ($this->tax_class > 0) {
          $this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
        }
        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_TABLEPARCEL_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 Table Method', 'MODULE_SHIPPING_TABLEPARCEL_STATUS', 'True', 'Do you want to offer table rate 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, set_function, date_added) values ('Shipping Table', 'MODULE_SHIPPING_TABLEPARCEL_COST', '25:8.50,50:5.50,10000:0.00', 'The shipping cost is based on the total cost or weight of items or count of the items. Example: 25:8.50,50:5.50,etc.. Up to 25 charge 8.50, from there to 50 charge 5.50, etc<br />You can end the last amount as 10000:7% to charge 7% of the Order Total', '6', '0', 'zen_cfg_textarea(', 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 ('Table Method', 'MODULE_SHIPPING_TABLEPARCEL_MODE', 'weight', 'The shipping cost is based on the order total or the total weight of the items ordered or the total number of items orderd.', '6', '0', 'zen_cfg_select_option(array(\'weight\', \'price\', \'item\'), ', 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_TABLEPARCEL_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_TABLEPARCEL_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_TABLEPARCEL_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_TABLEPARCEL_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', 'MODULE_SHIPPING_TABLEPARCEL_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
      }
      /**
       * 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_TABLEPARCEL_STATUS', 'MODULE_SHIPPING_TABLEPARCEL_COST', 'MODULE_SHIPPING_TABLEPARCEL_MODE', 'MODULE_SHIPPING_TABLEPARCEL_HANDLING', 'MODULE_SHIPPING_TABLEPARCEL_TAX_CLASS', 'MODULE_SHIPPING_TABLEPARCEL_TAX_BASIS', 'MODULE_SHIPPING_TABLEPARCEL_ZONE', 'MODULE_SHIPPING_TABLEPARCEL_SORT_ORDER');
      }
    }
    ?>

  6. #6
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: how to have different two diff table rates?

    Make sure you do not have a backup copy of this file in the directory:
    /includes/modules/shipping

    That is a autoloading directory and all files load and will conflict if you have a backup in there or a renamed file with the same constants ...
    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!

  7. #7
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: how to have different two diff table rates?

    Also make sure that you did not copy the code into the language directory:
    /includes/languages/english/modules/shipping

    That too will cause a problem like this ...
    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!

  8. #8
    Join Date
    Feb 2007
    Posts
    819
    Plugin Contributions
    0

    Default Re: how to have different two diff table rates?

    hmmm... ok i deleted my tableparcel.php from the following places:

    /includes/modules/shipping
    /includes/languages/english/modules/shipping

    so if the code is correct, where do I pup the tableparcel.php?

    what i am hoping to do is allow the customer to choose from either the parcel table rate or the priority table rate to determine shipping charges. maybe there is a better way to do this???

    thanks.

    Code:
     
     
    <?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: table.php 6347 2007-05-20 19:46:59Z ajeh $
     */
    /**
     * Enter description here...
     *
     */
    class tableparcel 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...
       *
       * @return table
       */
      function tableparcel() {
        global $order, $db;
        $this->code = 'tableparcel';
        $this->title = MODULE_SHIPPING_TABLEPARCEL_TEXT_TITLE;
        $this->description = MODULE_SHIPPING_TABLEPARCEL_TEXT_DESCRIPTION;
        $this->sort_order = MODULE_SHIPPING_TABLEPARCEL_SORT_ORDER;
        $this->icon = '';
        $this->tax_class = MODULE_SHIPPING_TABLEPARCEL_TAX_CLASS;
        $this->tax_basis = MODULE_SHIPPING_TABLEPARCEL_TAX_BASIS;
        // disable only when entire cart is free shipping
        if (zen_get_shipping_enabled($this->code)) {
          $this->enabled = ((MODULE_SHIPPING_TABLEPARCEL_STATUS == 'True') ? true : false);
        }
        if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_TABLEPARCEL_ZONE > 0) ) {
          $check_flag = false;
          $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_TABLEPARCEL_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;
          }
        }
      }
      /**
       * Enter description here...
       *
       * @param unknown_type $method
       * @return unknown
       */
      function quote($method = '') {
        global $order, $shipping_weight, $shipping_num_boxes, $total_count;
        // shipping adjustment
        switch (MODULE_SHIPPING_TABLEPARCEL_MODE) {
          case ('price'):
            $order_total = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ;
            break;
          case ('weight'):
            $order_total = $shipping_weight;
            break;
          case ('item'):
            $order_total = $total_count - $_SESSION['cart']->free_shipping_items();
            break;
        }
        $order_total_amount = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ;
        $table_cost = split("[:,]" , MODULE_SHIPPING_TABLEPARCEL_COST);
        $size = sizeof($table_cost);
        for ($i=0, $n=$size; $i<$n; $i+=2) {
          if (round($order_total,9) <= $table_cost[$i]) {
            if (strstr($table_cost[$i+1], '%')) {
              $shipping = ($table_cost[$i+1]/100) * $order_total_amount;
            } else {
              $shipping = $table_cost[$i+1];
            }
            break;
          }
        }
        if (MODULE_SHIPPING_TABLEPARCEL_MODE == 'weight') {
          $shipping = $shipping * $shipping_num_boxes;
          // show boxes if weight
          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($shipping_weight * $shipping_num_boxes,2) . TEXT_SHIPPING_WEIGHT . ')';
            break;
            default:
            $show_box_weight = ' (' . $shipping_num_boxes . ' x ' . number_format($shipping_weight,2) . TEXT_SHIPPING_WEIGHT . ')';
            break;
          }
        }
        $this->quotes = array('id' => $this->code,
        'module' => MODULE_SHIPPING_TABLEPARCEL_TEXT_TITLE . $show_box_weight,
        'methods' => array(array('id' => $this->code,
        'title' => MODULE_SHIPPING_TABLEPARCEL_TEXT_WAY,
        'cost' => $shipping + MODULE_SHIPPING_TABLEPARCEL_HANDLING)));
        if ($this->tax_class > 0) {
          $this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
        }
        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_TABLEPARCEL_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 Table Method', 'MODULE_SHIPPING_TABLEPARCEL_STATUS', 'True', 'Do you want to offer table rate 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, set_function, date_added) values ('Shipping Table', 'MODULE_SHIPPING_TABLEPARCEL_COST', '25:8.50,50:5.50,10000:0.00', 'The shipping cost is based on the total cost or weight of items or count of the items. Example: 25:8.50,50:5.50,etc.. Up to 25 charge 8.50, from there to 50 charge 5.50, etc<br />You can end the last amount as 10000:7% to charge 7% of the Order Total', '6', '0', 'zen_cfg_textarea(', 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 ('Table Method', 'MODULE_SHIPPING_TABLEPARCEL_MODE', 'weight', 'The shipping cost is based on the order total or the total weight of the items ordered or the total number of items orderd.', '6', '0', 'zen_cfg_select_option(array(\'weight\', \'price\', \'item\'), ', 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_TABLEPARCEL_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_TABLEPARCEL_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_TABLEPARCEL_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_TABLEPARCEL_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', 'MODULE_SHIPPING_TABLEPARCEL_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
      }
      /**
       * 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_TABLEPARCEL_STATUS', 'MODULE_SHIPPING_TABLEPARCEL_COST', 'MODULE_SHIPPING_TABLEPARCEL_MODE', 'MODULE_SHIPPING_TABLEPARCEL_HANDLING', 'MODULE_SHIPPING_TABLEPARCEL_TAX_CLASS', 'MODULE_SHIPPING_TABLEPARCEL_TAX_BASIS', 'MODULE_SHIPPING_TABLEPARCEL_ZONE', 'MODULE_SHIPPING_TABLEPARCEL_SORT_ORDER');
      }
    }
    ?>

  9. #9
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: how to have different two diff table rates?

    You would put it in the shipping modules directory but some where you have already added it ...

    Do a search with the Tools ... Developers Tool Kit ... and in the bottom input box enter:
    class tableparcel

    See what file(s) come up ... there can be only one and it should be the one you made and the code belongs in:
    /includes/modules/shipping

    and the language defines belong in:
    /includes/languages/english/modules/shipping
    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!

  10. #10
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: how to have different two diff table rates?

    Note: your code does appear to work so I am guessing you have:

    1 placed it on the server in the wrong directory

    2 put the code in the language file too

    3 added it incorrectly to another self loading directory

    Or some combination of the 3 ...
    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!

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. is it possible to setup shipping charges for diff rates for diff products & states?
    By newdude in forum Built-in Shipping and Payment Modules
    Replies: 4
    Last Post: 10 Nov 2010, 09:20 PM
  2. Two different shipping rates...
    By whywaitweb in forum Built-in Shipping and Payment Modules
    Replies: 4
    Last Post: 7 Nov 2007, 01:48 PM
  3. How to have different flat rates to different countries
    By vandiermen in forum Built-in Shipping and Payment Modules
    Replies: 4
    Last Post: 28 Feb 2007, 10:28 AM
  4. Different table rates for different items?
    By jegelstaff in forum Addon Shipping Modules
    Replies: 1
    Last Post: 8 Dec 2006, 07:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg