Page 1 of 2 12 LastLast
Results 1 to 10 of 17
  1. #1
    Join Date
    Aug 2005
    Location
    Australia
    Posts
    110
    Plugin Contributions
    1

    Default How do I customize handling weights for this module?

    Hi all,

    I have this module which is a custom one I use for Australia post airbags. It has some features such as an insurance option and a limitation based on the price. A would like to change it to add another limitation based on weight. I no I need to add another configuration value to the database install code for weight limit and I was hoping I could use similar code found in line 59 to limit the module use by shipping weight. This is the code but I'm not clever enough to write the additional code.

    Code I'd think I can use but change to weight limit:
    Code:
         if(MODULE_SHIPPING_EXPOST_MONEY_LIMIT < $order->info['total']) $check_flag = false;
    
            if ($check_flag == false) {
              $this->enabled = false;
            }
    Whole module as I currently have it:
    Code:
    <?php
    //
    // +----------------------------------------------------------------------+
    // |zen-cart Open Source E-commerce                                       |
    // +----------------------------------------------------------------------+
    // | Copyright (c) 2004 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: EXPOST.php 1038 2005-03-18 07:09:17Z ajeh $
    //
    
      class expost {
        var $code, $title, $description, $icon, $enabled;
    
    // class constructor
        function expost() {
          global $order, $db;
    
          $this->code = 'expost';
          $this->title = MODULE_SHIPPING_EXPOST_TEXT_TITLE;
          $this->description = MODULE_SHIPPING_EXPOST_TEXT_DESCRIPTION;
          $this->sort_order = MODULE_SHIPPING_EXPOST_SORT_ORDER;
          $this->icon = '';
          $this->tax_class = MODULE_SHIPPING_EXPOST_TAX_CLASS;
          $this->tax_basis = MODULE_SHIPPING_EXPOST_TAX_BASIS;
          // disable only when entire cart is free shipping
          if (zen_get_shipping_enabled($this->code)) {
            $this->enabled = ((MODULE_SHIPPING_EXPOST_STATUS == 'True') ? true : false);
          }
          $this->types[0] = 'NINSURED';
    			if(MODULE_SHIPPING_EXPOST_INSURANCE == 'True') {
         		$this->types[1] = 'INSURED';
    			}
    
          if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_EXPOST_ZONE > 0) ) {
            $check_flag = false;
            $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES  . " where geo_zone_id = '" . MODULE_SHIPPING_EXPOST_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(MODULE_SHIPPING_EXPOST_MONEY_LIMIT < $order->info['total']) $check_flag = false;
    
            if ($check_flag == false) {
              $this->enabled = false;
            }
          }
        }
    
    // class methods
        function quote($method = '') {
          global $order, $shipping_weight, $shipping_num_boxes;
    
    // shipping adjustment
          if (MODULE_SHIPPING_EXPOST_MODE == 'price') {
            $order_total = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ;
          } else {
            $order_total = $shipping_weight;
          }
    
          $EXPOST_cost = split("[:,]" , MODULE_SHIPPING_EXPOST_COST);
          $size = sizeof($EXPOST_cost);
          for ($i=0, $n=$size; $i<$n; $i+=2) {
            if ($order_total <= $EXPOST_cost[$i]) {
              $shipping = $EXPOST_cost[$i+1];
              break;
            }
          }
    
          if (MODULE_SHIPPING_EXPOST_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;
            }
          }
    			foreach($this->types as $type) {
    				if($method != '' && $method == $type) {
    
    					if($type == 'INSURED') {
    					$methods[] = array('id' => $type,
    														 'title' => constant(MODULE_SHIPPING_EXPOST_TEXT_WAY.'_'.$type),
    														 'cost' => ($shipping + MODULE_SHIPPING_EXPOST_HANDLING) + ($order->info['total'] * 0.05));
    					}else{
    					$methods[] = array('id' => $type,
    														 'title' => constant(MODULE_SHIPPING_EXPOST_TEXT_WAY.'_'.$type),
    														 'cost' => $shipping + MODULE_SHIPPING_EXPOST_HANDLING);
    					}
    				}elseif($method != '' && $method != $type) {
    				}elseif($method == '') {
    					if($type == 'INSURED') {
    					$methods[] = array('id' => $type,
    														 'title' => constant(MODULE_SHIPPING_EXPOST_TEXT_WAY.'_'.$type),
    														 'cost' => ($shipping + MODULE_SHIPPING_EXPOST_HANDLING) + ($order->info['total'] * 0.05));
    					}else{
    					$methods[] = array('id' => $type,
    														 'title' => constant(MODULE_SHIPPING_EXPOST_TEXT_WAY.'_'.$type),
    														 'cost' => $shipping + MODULE_SHIPPING_EXPOST_HANDLING);
    					}
    				}
    }
    
         $this->quotes = array('id' => $this->code,
                                'module' => MODULE_SHIPPING_EXPOST_TEXT_TITLE . $show_box_weight.'</strong><br />'.$this->description.'<strong>',
                                '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']);
          }
    
          if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title);
    
          return $this->quotes;
        }
    
        function check() {
          global $db;
          if (!isset($this->_check)) {
            $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_EXPOST_STATUS'");
            $this->_check = $check_query->RecordCount();
          }
          return $this->_check;
        }
    
        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 EXPOST Method', 'MODULE_SHIPPING_EXPOST_STATUS', 'True', 'Do you want to offer EXPOST 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 ('Enable Insurance', 'MODULE_SHIPPING_EXPOST_INSURANCE', 'True', 'Do you want to offer insurance?', '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 EXPOST', 'MODULE_SHIPPING_EXPOST_COST', '25:8.50,50:5.50,10000:0.00', 'The shipping cost is based on the total cost or weight of items. Example: 25:8.50,50:5.50,etc.. Up to 25 charge 8.50, from there to 50 charge 5.50, etc', '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 ('EXPOST Method', 'MODULE_SHIPPING_EXPOST_MODE', 'weight', 'The shipping cost is based on the order total or the total weight of the items ordered.', '6', '0', 'zen_cfg_select_option(array(\'weight\', \'price\'), ', 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_EXPOST_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_EXPOST_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_EXPOST_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_EXPOST_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 ('Shipping Limitation', 'MODULE_SHIPPING_EXPOST_MONEY_LIMIT', '0', 'Do not use this module, if order exceeds the value of XXX of your default currency.', '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 ('Sort Order', 'MODULE_SHIPPING_EXPOST_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
        }
    
        function remove() {
          global $db;
          $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
        }
    
        function keys() {
          return array('MODULE_SHIPPING_EXPOST_STATUS', 'MODULE_SHIPPING_EXPOST_INSURANCE', 'MODULE_SHIPPING_EXPOST_COST', 'MODULE_SHIPPING_EXPOST_MODE', 'MODULE_SHIPPING_EXPOST_HANDLING', 'MODULE_SHIPPING_EXPOST_TAX_CLASS', 'MODULE_SHIPPING_EXPOST_TAX_BASIS', 'MODULE_SHIPPING_EXPOST_ZONE', 'MODULE_SHIPPING_EXPOST_MONEY_LIMIT', 'MODULE_SHIPPING_EXPOST_SORT_ORDER');
        }
      }
    ?>
    PS: I know the insurance should be a configuration value also rather than the hard coded value.
    Cheers all,

    Gruntre69

    WayCool
    Zen is Way Cool too!

  2. #2
    Join Date
    Aug 2005
    Location
    Australia
    Posts
    110
    Plugin Contributions
    1

    Default Re: How do I customize handling weights for this module?

    Bump... Anybody out there that can help me with this? I also need it for the table rate modules. My problem is and I'm sure many others are finding this is that there is no way to handle cubic size/weight for products. This makes it very difficult to handle multiple items in a cart of large size that can't be calculated by weight alone. Ideally, a field in the product that denotes a large item, or even better the length, width, height and a multiplier factor for cubic cubic weight would be ideal.

    My simple solution is to clone the table rate modules with the switch for maximum weight. This way the large items can just have there actual weights adjusted to allow for cubic size and then the cloned modules can be evoked with a handling fee added to allow for this size.

    I hope this makes sense and somebody out there can help. It would be a good plugin as I'm sure it would be very useful.
    Cheers all,

    Gruntre69

    WayCool
    Zen is Way Cool too!

  3. #3
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: How do I customize handling weights for this module?

    Quote Originally Posted by gruntre69 View Post
    My problem is and I'm sure many others are finding this is that there is no way to handle cubic size/weight for products.
    Tell that to the author of the ozpost module. I'm sure he'll disagree. ;-)

    Quote Originally Posted by gruntre69 View Post
    My simple solution is to clone the table rate modules with the switch for maximum weight. This way the large items can just have there actual weights adjusted to allow for cubic size and then the cloned modules can be evoked with a handling fee added to allow for this size.

    I hope this makes sense and somebody out there can help. It would be a good plugin as I'm sure it would be very useful.
    There is nothing simple about a shipping module that deals with dimensional data - that's why there are so few modules that support it - Not just ZenCart - but all eCommerce systems.

    I wish you all the best with what you are trying to achieve, but you really don't know what you are getting yourself into. Having said that, your 1st post was seeking advice on how to limit based on weight - Your code shows that you are on the right track for this one - I didn't take a good look to see where/why it isn't working for you though - and unlike your 'new' problem (dimensional data) that should be quite trivial to rectify.

    The mere fact that *I've* chosen to give a response (even though not particularity helpful) is enough to ensure that someone here (possibly several someones) will now step in and give the answer(s) that you are seeking. <LOL>

    Cheers
    RodG

  4. #4
    Join Date
    Aug 2005
    Location
    Australia
    Posts
    110
    Plugin Contributions
    1

    Default Re: How do I customize handling weights for this module?

    Thanks for the reply Rod, If I can get the max weight switch added to my shipping modules I'll be able to achieve what I need in a round about kind of way. I haven't actually got any code for a maximum weight switch, just a maximum price switch. I'm sure it won't be difficult, it's just beyond my level... (no PHP level)
    I understand the minefield, especially due to multiple products in the cart....
    Cheers all,

    Gruntre69

    WayCool
    Zen is Way Cool too!

  5. #5
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: How do I customize handling weights for this module?

    Quote Originally Posted by gruntre69 View Post
    Thanks for the reply Rod, If I can get the max weight switch added to my shipping modules I'll be able to achieve what I need in a round about kind of way. I haven't actually got any code for a maximum weight switch, just a maximum price switch. I'm sure it won't be difficult, it's just beyond my level... (no PHP level)
    I understand the minefield, especially due to multiple products in the cart....

    Try this: (add the line in blue)
    Code:
           if(MODULE_SHIPPING_EXPOST_MONEY_LIMIT < $order->info['total']) $check_flag = false;
    
    
           if($shipping_weight > YOURMAXWEIGHT) $check_flag = false;
    
    
            if ($check_flag == false) {
              $this->enabled = false;
            }
          }
    Cheers
    RodG

  6. #6
    Join Date
    Aug 2005
    Location
    Australia
    Posts
    110
    Plugin Contributions
    1

    Default Re: How do I customize handling weights for this module?

    Thanks Rod,

    This actually worked but it has causes problems with other modules when I have to change the max weight field in configuration shipping.

    Is there a way I could do something like this? I've tried it but it doesn't seem to work...

    Code:
          if(MODULE_SHIPPING_TABLE3_MONEY_LIMIT < $order->info['total']) $check_flag = false;
    if(MODULE_SHIPPING_TABLE3_WEIGHT_LIMIT < $shipping_weight) $check_flag = false;
            if ($check_flag == false) {
              $this->enabled = false;
    and
    Code:
              $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Shipping Weight Limitation', 'MODULE_SHIPPING_TABLE3_WEIGHT_LIMIT', '100', 'Do not use this module, if order weight exceeds the value of XXX.', '6', '0', now())");
    Cheers all,

    Gruntre69

    WayCool
    Zen is Way Cool too!

  7. #7
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: How do I customize handling weights for this module?

    Quote Originally Posted by gruntre69 View Post
    Thanks Rod,

    This actually worked but it has causes problems with other modules when I have to change the max weight field in configuration shipping.

    Is there a way I could do something like this? I've tried it but it doesn't seem to work...

    Code:
          if(MODULE_SHIPPING_TABLE3_MONEY_LIMIT < $order->info['total']) $check_flag = false;
    if(MODULE_SHIPPING_TABLE3_WEIGHT_LIMIT < $shipping_weight) $check_flag = false;
            if ($check_flag == false) {
              $this->enabled = false;
    and
    Code:
              $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Shipping Weight Limitation', 'MODULE_SHIPPING_TABLE3_WEIGHT_LIMIT', '100', 'Do not use this module, if order weight exceeds the value of XXX.', '6', '0', now())");
    Not quite sure what you mean by causing problems with othershipping modules. They all work independently of each other (one module has no idea what the others are doing).

    In principle, this updated code should work, but the logic appears backwards. The way you have it, it is saying 'if the max weight setting is less than the shipping weight then disable this module.

    I think what you want is if the shipping weight is greater than the max weight setting then disable this module.

    Code:
    if($shipping_weight > MODULE_SHIPPING_TABLE3_WEIGHT_LIMIT ) $check_flag = false;
    
    Alternatively
    Code:
    
    if(MODULE_SHIPPING_TABLE3_WEIGHT_LIMIT < $shipping_weight)  { $check_flag = true; } else {  $check_flag = false; }
    As I say though, I'm a little puzzled over how anything you do with this module is going to have any effect on any of the other modules.

    If you are seeking a way to enable one module and disable another based on the maximum weight factor you will need to add similar (but reversed) logic in the other modules.

    Cheers
    RodG

  8. #8
    Join Date
    Aug 2005
    Location
    Australia
    Posts
    110
    Plugin Contributions
    1

    Default Re: How do I customize handling weights for this module?

    Sorry Rod,

    I didn't explain myself fully. What I meant is if I use YOURMAXWEIGHT I need to set that variable for this table rate module but it will cause problems with how other modules calculate. I'll try again and see how I go..

    Thanks again for your help!
    Cheers all,

    Gruntre69

    WayCool
    Zen is Way Cool too!

  9. #9
    Join Date
    Aug 2005
    Location
    Australia
    Posts
    110
    Plugin Contributions
    1

    Default Re: How do I customize handling weights for this module?

    I've tried it again but it is definitely not working. I have a feeling that the shipping weight ($shipping_weight) is not available at that line of the code and it cannot calculate it.

    It also seems to me that this:
    Code:
     if($shipping_weight > MODULE_SHIPPING_TABLE3_WEIGHT_LIMIT ) $check_flag = false;
    and this:
    Code:
    if(MODULE_SHIPPING_PLATINUM_WEIGHT_LIMIT < $shipping_weight) $check_flag = false;
    are the same thing...

    Here is the entire code again with the things I have added to try and make this work in blue.
    Entire code:
    Code:
    <?php
    //
    // +----------------------------------------------------------------------+
    // |zen-cart Open Source E-commerce                                       |
    // +----------------------------------------------------------------------+
    // | Copyright (c) 2004 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: PLATINUM.php 1038 2005-03-18 07:09:17Z ajeh $
    //
    
      class platinum {
        var $code, $title, $description, $icon, $enabled;
    
    // class constructor
        function platinum() {
          global $order, $db;
    
          $this->code = 'platinum';
          $this->title = MODULE_SHIPPING_PLATINUM_TEXT_TITLE;
          $this->description = MODULE_SHIPPING_PLATINUM_TEXT_DESCRIPTION;
          $this->sort_order = MODULE_SHIPPING_PLATINUM_SORT_ORDER;
          $this->icon = '';
          $this->tax_class = MODULE_SHIPPING_PLATINUM_TAX_CLASS;
          $this->tax_basis = MODULE_SHIPPING_PLATINUM_TAX_BASIS;
          // disable only when entire cart is free shipping
          if (zen_get_shipping_enabled($this->code)) {
            $this->enabled = ((MODULE_SHIPPING_PLATINUM_STATUS == 'True') ? true : false);
          }
          $this->types[0] = 'NINSURED';
    			if(MODULE_SHIPPING_PLATINUM_INSURANCE == 'True') {
         		$this->types[1] = 'INSURED';
    			}
    
          if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_PLATINUM_ZONE > 0) ) {
            $check_flag = false;
            $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES  . " where geo_zone_id = '" . MODULE_SHIPPING_PLATINUM_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(MODULE_SHIPPING_PLATINUM_MONEY_LIMIT < $order->info['total']) $check_flag = false;
    		if(MODULE_SHIPPING_PLATINUM_WEIGHT_LIMIT < $shipping_weight) $check_flag = false;
    
            if ($check_flag == false) {
              $this->enabled = false;
            }
          }
        }
    
    // class methods
        function quote($method = '') {
          global $order, $shipping_weight, $shipping_num_boxes;
    
    // shipping adjustment
          if (MODULE_SHIPPING_PLATINUM_MODE == 'price') {
            $order_total = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ;
          } else {
            $order_total = $shipping_weight;
          }
    
          $PLATINUM_cost = split("[:,]" , MODULE_SHIPPING_PLATINUM_COST);
          $size = sizeof($PLATINUM_cost);
          for ($i=0, $n=$size; $i<$n; $i+=2) {
            if ($order_total <= $PLATINUM_cost[$i]) {
              $shipping = $PLATINUM_cost[$i+1];
              break;
            }
          }
    
          if (MODULE_SHIPPING_PLATINUM_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;
            }
          }
    			foreach($this->types as $type) {
    				if($method != '' && $method == $type) {
    
    					if($type == 'INSURED') {
    					$methods[] = array('id' => $type,
    														 'title' => constant(MODULE_SHIPPING_PLATINUM_TEXT_WAY.'_'.$type),
    														 'cost' => ($shipping + MODULE_SHIPPING_PLATINUM_HANDLING) + ($order->info['total'] * 0.05));
    					}else{
    					$methods[] = array('id' => $type,
    														 'title' => constant(MODULE_SHIPPING_PLATINUM_TEXT_WAY.'_'.$type),
    														 'cost' => $shipping + MODULE_SHIPPING_PLATINUM_HANDLING);
    					}
    				}elseif($method != '' && $method != $type) {
    				}elseif($method == '') {
    					if($type == 'INSURED') {
    					$methods[] = array('id' => $type,
    														 'title' => constant(MODULE_SHIPPING_PLATINUM_TEXT_WAY.'_'.$type),
    														 'cost' => ($shipping + MODULE_SHIPPING_PLATINUM_HANDLING) + ($order->info['total'] * 0.05));
    					}else{
    					$methods[] = array('id' => $type,
    														 'title' => constant(MODULE_SHIPPING_PLATINUM_TEXT_WAY.'_'.$type),
    														 'cost' => $shipping + MODULE_SHIPPING_PLATINUM_HANDLING);
    					}
    				}
    }
    
         $this->quotes = array('id' => $this->code,
                                'module' => MODULE_SHIPPING_PLATINUM_TEXT_TITLE . $show_box_weight.'</strong><br />'.$this->description.'<strong>',
                                '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']);
          }
    
          if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title);
    
          return $this->quotes;
        }
    
        function check() {
          global $db;
          if (!isset($this->_check)) {
            $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_PLATINUM_STATUS'");
            $this->_check = $check_query->RecordCount();
          }
          return $this->_check;
        }
    
        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 PLATINUM Method', 'MODULE_SHIPPING_PLATINUM_STATUS', 'True', 'Do you want to offer PLATINUM 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 ('Enable Insurance', 'MODULE_SHIPPING_PLATINUM_INSURANCE', 'True', 'Do you want to offer insurance?', '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 PLATINUM', 'MODULE_SHIPPING_PLATINUM_COST', '0.5:18.09,3:25,100:1000', 'The shipping cost is based on the total cost or weight of items. Example: 25:8.50,50:5.50,etc.. Up to 25 charge 8.50, from there to 50 charge 5.50, etc', '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 ('PLATINUM Method', 'MODULE_SHIPPING_PLATINUM_MODE', 'weight', 'The shipping cost is based on the order total or the total weight of the items ordered.', '6', '0', 'zen_cfg_select_option(array(\'weight\', \'price\'), ', 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_PLATINUM_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_PLATINUM_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_PLATINUM_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_PLATINUM_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 ('Shipping Limitation', 'MODULE_SHIPPING_PLATINUM_MONEY_LIMIT', '10000', 'Do not use this module, if order exceeds the value of XXX of your default currency.', '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 ('Shipping weight Limitation', 'MODULE_SHIPPING_PLATINUM_WEIGHT_LIMIT', '5', 'Do not use this module, if order weight the value of XXX.', '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 ('Sort Order', 'MODULE_SHIPPING_PLATINUM_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
        }
    
        function remove() {
          global $db;
          $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
        }
    
        function keys() {
         return array('MODULE_SHIPPING_PLATINUM_STATUS', 'MODULE_SHIPPING_PLATINUM_INSURANCE', 'MODULE_SHIPPING_PLATINUM_COST', 'MODULE_SHIPPING_PLATINUM_MODE', 'MODULE_SHIPPING_PLATINUM_HANDLING', 'MODULE_SHIPPING_PLATINUM_TAX_CLASS', 'MODULE_SHIPPING_PLATINUM_TAX_BASIS', 'MODULE_SHIPPING_PLATINUM_ZONE', 'MODULE_SHIPPING_PLATINUM_MONEY_LIMIT', 'MODULE_SHIPPING_PLATINUM_SORT_ORDER','MODULE_SHIPPING_PLATINUM_WEIGHT_LIMIT');
        }
      }
    ?>
    Cheers all,

    Gruntre69

    WayCool
    Zen is Way Cool too!

  10. #10
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default Re: How do I customize handling weights for this module?

    Quote Originally Posted by gruntre69 View Post
    Sorry Rod,

    I didn't explain myself fully. What I meant is if I use YOURMAXWEIGHT I need to set that variable for this table rate module but it will cause problems with how other modules calculate. I'll try again and see how I go..

    Thanks again for your help!
    I believe RodG's use of the YOURMAXWEIGHT "constant" was such that you could type in the value (hard-code) or as you have attempted/suggested to add a constant into the module that can be modified from the admin and then use that constant elsewhere. The constant applied in the sql statement snippet will not be incorporated into the database until either the module is removed/installed or a "properly" formatted sql is applied to the database through a tool such as tools->Install SQL patches.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v154 USPS module returning different rates for same weights
    By Phil S in forum Built-in Shipping and Payment Modules
    Replies: 10
    Last Post: 19 Dec 2015, 05:21 AM
  2. Flat Rate Handling Fee for Payment Module
    By AngiePoo in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 17 Jan 2010, 09:42 AM
  3. How do I approach this? Max shipping weights
    By Dunk in forum Built-in Shipping and Payment Modules
    Replies: 4
    Last Post: 21 Jan 2009, 05:28 PM
  4. USPS module, disabling a service for certain weights
    By dman76 in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 18 Nov 2007, 01:58 AM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR