Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1
    Join Date
    Dec 2006
    Posts
    53
    Plugin Contributions
    0

    Default Remove decimal in shipping - grams

    Hoping to open by Jan 1st. Yippee.

    Question. I've searched and searched but can't get the darn thing to work.

    I need to get rid of the decimal place for weight. I use grams.

    Already tried to change to INT, SMALLINT and DECIMAL 5,0 in my database but still shows up.

    I read something about rounding but don't know how to go about it.

    Here is a screenshot of my problem.

    [IMG]http://******/images/zen_question.gif[/IMG]

    Thanks for any help in advance.
    Last edited by Ajeh; 3 Jan 2007 at 03:59 PM. Reason: Per request

  2. #2
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,755
    Plugin Contributions
    9

    Default Re: Remove decimal in shipping - grams

    If you can use a sql tool to edit your DB (phpmysql is most common) Here's what i think will fix your issue..

    In your database > on the table products > field products weight > change the length/value 5,2 to 5,0 - this should give you your "0" decimal places.

  3. #3
    Join Date
    Dec 2006
    Posts
    53
    Plugin Contributions
    0

    Default Re: Remove decimal in shipping - grams

    I tried that. Didn't work. My product info pages don't have the decimal points but everywhere else does.

  4. #4
    Join Date
    Dec 2006
    Posts
    53
    Plugin Contributions
    0

    Default Re: Remove decimal in shipping - grams

    Sstill stuck on this one.

    I'm looking everywhere but no luck. The products all show, for example 400 grams, but when I add them to the cart a decimal point gets added and two zeros.

    Could someone maybe tell me where the function for handling integers is located for shipping weight? Or maybe if there is a class for this?

    Does the database store weights anywhere other than product_weight?

    So much time for a little dot.

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

    Default Re: Remove decimal in shipping - grams

    It is not the database that needs to be changed on the weight ...

    It is the display of the weight in your shipping module ...

    You should see that your weight is displaying correctly in the shopping_cart, product _info, listings, etc.

    Where it is not displaying correctly appears to be your shipping module itself

    If you were to edit that file and look for: weight

    ... you will probably find that on the display it is specifically saying to show decimal places ...

    ie: number_format(blah blah)
    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!

  6. #6
    Join Date
    Dec 2006
    Posts
    53
    Plugin Contributions
    0

    Default Re: Remove decimal in shipping - grams

    Thank you so much Ajeh!

    The number_format was what I was looking for. I did a search for number_format using the Dev Tool Kit and found references to weight with a 2. When I used the override system on my mzmt.php files and changed the 2 to a zero it worked. Thank you.

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

    Default Re: Remove decimal in shipping - grams

    You are most welcome ...

    Thanks for letting us know that it was not the database causing you issues on your shipping display weights but the module itself was coded to show decimals and you did not want them ...
    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
    Dec 2006
    Posts
    53
    Plugin Contributions
    0

    Default Re: Remove decimal in shipping - grams

    Sorry Ajeh. This didn't fix it.

    When I tried to go through the Steps for an order I found that the changes I had made to mzmt.php made my site hiccup. I replaced the original file and everythign worked again, just with the same darn .00 after.

    I'm going to post the entire mzmt.php file. Maybe someone can see where I can make changes to get rid of the decimal point: Thanks.

    Code:
    <?php
    //
    // +----------------------------------------------------------------------+
    // |zen-cart Open Source E-commerce                                       |
    // +----------------------------------------------------------------------+
    // | Copyright (c) 2004 Josh Dechant                                      |
    // |                                                                      |
    // | Portions 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       |
    // | license AT zen-cart DOT com so we can mail you a copy immediately.          |
    // +----------------------------------------------------------------------+
    // $Id: mzmt.php,v 1.101 2004-10-31 Josh Dechant Exp $
    //
      class mzmt {
        var $code, $title, $description, $icon, $enabled, $num_zones, $num_tables, $delivery_geozone, $order_total;
     
        function mzmt() {
          global $order;
          $this->code = 'mzmt';
          $this->title = MODULE_SHIPPING_MZMT_TEXT_TITLE;
          $this->description = MODULE_SHIPPING_MZMT_TEXT_DESCRIPTION;
          $this->sort_order = MODULE_SHIPPING_MZMT_SORT_ORDER;
          $this->tax_class = MODULE_SHIPPING_MZMT_TAX_CLASS;
          $this->tax_basis = MODULE_SHIPPING_MZMT_TAX_BASIS;
          $this->num_geozones = MODULE_SHIPPING_MZMT_NUMBER_GEOZONES;
          $this->num_tables = MODULE_SHIPPING_MZMT_NUMBER_TABLES;
          // disable only when entire cart is free shipping
          if (zen_get_shipping_enabled($this->code)) {
            $this->enabled = ((MODULE_SHIPPING_MZMT_STATUS == 'True') ? true : false);
          }
          if ($this->enabled == true) {
            $this->enabled = false;
            for ($n=1; $n<=$this->num_geozones; $n++) {
              if ( ((int)constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $n . '_ID') > 0) && ((int)constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $n . '_ID') == $this->getGeoZoneID($order->delivery['country']['id'], $order->delivery['zone_id'])) ) {
                $this->enabled = true;
                $this->delivery_geozone = $n;
                break;
              } elseif ( ((int)constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $n . '_ID') == 0) && ($n == (int)$this->num_geozones) ) {
                $this->enabled = true;
                $this->delivery_geozone = $n;
                break;
              }
            }
          }
        }
    // class methods
        function quote($method = '') {
          global $order, $shipping_weight, $shipping_num_boxes, $template;
          $this->quotes = array('id' => $this->code,
                                'module' => constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_TEXT_TITLE'),
                                'methods' => array());
          $geozone_mode = $this->determineTableMethod(constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_MODE'));  
     
          if ($method) {
            $j = substr($method, 5);
            $shipping = $this->determineShipping(split("[:,]" , constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_TABLE_' . $j)));
            if ($geozone_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,2) . TEXT_SHIPPING_WEIGHT . ')';
                  break;
                default:
                  $show_box_weight = ' (' . $shipping_num_boxes . ' x ' . number_format($shipping_weight,2) . TEXT_SHIPPING_WEIGHT . ')';
                  break;
              }
            }
     
            $this->quotes['methods'][] = array('id' => 'table' . $j,
                                               'title' => constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_TABLE_' . $j . '_TEXT_WAY') . $show_box_weight,
                                               'cost' => $shipping + constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_HANDLING'));
          } else {
            for ($j=1; $j<=$this->num_tables; $j++) {
              if (!zen_not_null(constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_TABLE_' . $j))) continue;
              $shipping = $this->determineShipping(split("[:,]" , constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_TABLE_' . $j)));
              if ($geozone_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,2) . TEXT_SHIPPING_WEIGHT . ')';
                    break;
                  default:
                    $show_box_weight = ' (' . $shipping_num_boxes . ' x ' . number_format($shipping_weight,2) . TEXT_SHIPPING_WEIGHT . ')';
                    break;
                }
              }
              $this->quotes['methods'][] = array('id' => 'table' . $j,
                                                 'title' => constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_TABLE_' . $j . '_TEXT_WAY') . $show_box_weight,
                                                 'cost' => $shipping + constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_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(constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_ICON'))) $this->quotes['icon'] = zen_image($template->get_template_dir(constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_ICON'), DIR_WS_TEMPLATE, $current_page_base,'images/icons'). '/' . constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_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_MZMT_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 MultiRegion MultiTable Method', 'MODULE_SHIPPING_MZMT_STATUS', 'True', 'Do you want to offer multi-region multi-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, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_MZMT_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_MZMT_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, date_added) values ('Sort Order', 'MODULE_SHIPPING_MZMT_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
          for ($n=1; $n<=$this->num_geozones; $n++) {
            $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 ('<hr />Geo Zone $n', 'MODULE_SHIPPING_MZMT_GEOZONE_{$n}_ID', '', 'Enable this for the following geo zone.', '6', '0', 'zen_get_zone_class_title', '_cfg_pull_down_geozones(', 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 ('Geo Zone $n Table Method', 'MODULE_SHIPPING_MZMT_GEOZONE_{$n}_MODE', 'weight', 'The shipping cost is based on the total weight, total price, or total count of the items ordered.', '6', '0', 'zen_cfg_select_option(array(\'weight\', \'price\', \'count\'), ', now())");
     
            for ($j=1; $j<=$this->num_tables; $j++) {
              $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Geo Zone $n Shipping Table $j', 'MODULE_SHIPPING_MZMT_GEOZONE_{$n}_TABLE_{$j}', '', 'Shipping table $j for this geo zone', '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 ('Geo Zone $n Handling Fee', 'MODULE_SHIPPING_MZMT_GEOZONE_{$n}_HANDLING', '0', 'Handling Fee for this shipping geo zone', '6', '0', now())");
          }
        }
        function remove() {
          global $db;
          $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
        }
        function keys() {
          $keys = array('MODULE_SHIPPING_MZMT_STATUS', 'MODULE_SHIPPING_MZMT_TAX_CLASS', 'MODULE_SHIPPING_MZMT_TAX_BASIS', 'MODULE_SHIPPING_MZMT_SORT_ORDER');
          for ($n=1; $n<=$this->num_geozones; $n++) {
            $keys[] = 'MODULE_SHIPPING_MZMT_GEOZONE_' . $n . '_ID';
            $keys[] = 'MODULE_SHIPPING_MZMT_GEOZONE_' . $n . '_MODE';
            $keys[] = 'MODULE_SHIPPING_MZMT_GEOZONE_' . $n . '_HANDLING';
            for ($j=1; $j<=$this->num_tables; $j++) {
              $keys[] = 'MODULE_SHIPPING_MZMT_GEOZONE_' . $n . '_TABLE_' . $j;
            }
          }
          return $keys;
        }
        function determineTableMethod($geozone_mode) {
          global $total_count, $shipping_weight;
          switch ($geozone_mode) {
            case 'price':
              if (method_exists($_SESSION['cart'], 'free_shipping_prices')) {
                $this->order_total = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices();
              } else {
                $this->order_total = $_SESSION['cart']->show_total();
              }
              break;
            case 'count':
              if (method_exists($_SESSION['cart'], 'free_shipping_items')) {
                $this->order_total = $total_count - $_SESSION['cart']->free_shipping_items();
              } else {
                $this->order_total = $total_count;
              }
              break;
            case 'weight':
              $this->order_total = $shipping_weight;
              break;
          }
          return $geozone_mode;    
        }
        function determineShipping($table_cost) {
          for ($i=0, $n=sizeof($table_cost); $i<$n; $i+=2) {
            if ($this->order_total >= $table_cost[$i]) {
              $shipping_factor = $table_cost[$i+1];
            }
          }
          if (substr_count($shipping_factor, '%') > 0) {
            $shipping = ((($this->order_total*10)/10)*((str_replace('%', '', $shipping_factor))/100));
          } else {
            $shipping = str_replace('$', '', $shipping_factor);
          }
     
          return $shipping;
        }
        function getGeoZoneID($country_id, $zone_id) {
          global $db;
          // First, check for a Geo Zone that explicity includes the country & specific zone (useful for splitting countries with zones up)
          $zone = $db->Execute("select gz.geo_zone_id from " . TABLE_GEO_ZONES . " gz left join " . TABLE_ZONES_TO_GEO_ZONES . " ztgz on (gz.geo_zone_id = ztgz.geo_zone_id) where ztgz.zone_country_id = '" . (int)$country_id . "' and ztgz.zone_id = '" . (int)$zone_id . "' and LOWER(gz.geo_zone_name) like 'shp%'");
          if ($zone->RecordCount() > 0) {
            return $zone->fields['geo_zone_id'];
          } else {
            // No luck…  Now check for a Geo Zone for the country and "All Zones" of the country.
            $zone = $db->Execute("select gz.geo_zone_id from " . TABLE_GEO_ZONES . " gz left join " . TABLE_ZONES_TO_GEO_ZONES . " ztgz on (gz.geo_zone_id = ztgz.geo_zone_id) where ztgz.zone_country_id = '" . (int)$country_id . "' and (ztgz.zone_id = '0' or ztgz.zone_id is NULL) and LOWER(gz.geo_zone_name) like 'shp%'");
            if ($zone->RecordCount() > 0) {
              return $zone->fields['geo_zone_id'];
            } else {
              return false;
            }
          }
        }
      }
      function _cfg_pull_down_geozones($zone_class_id, $key = '') {
        global $db;
        $name = (($key) ? 'configuration[' . $key . ']' : 'configuration_value');
        $zone_class_array = array(array('id' => '0', 'text' => 'Rest of the World'));
        $zone_class = $db->Execute("select geo_zone_id, geo_zone_name from " . TABLE_GEO_ZONES . " where LOWER(geo_zone_name) like 'shp%' order by geo_zone_name");
        while (!$zone_class->EOF) {
          $zone_class_array[] = array('id' => $zone_class->fields['geo_zone_id'],
                                      'text' => $zone_class->fields['geo_zone_name']);
          $zone_class->MoveNext();
        }
        return zen_draw_pull_down_menu($name, $zone_class_array, $zone_class_id);
      }
    ?>

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

    Default Re: Remove decimal in shipping - grams

    You should just be able to find all: number_format

    And the references to the weight should be ,0 vs ,2

    Sounds like perhaps you had a typo the first time around ...
    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
    Dec 2006
    Posts
    53
    Plugin Contributions
    0

    Default Re: Remove decimal in shipping - grams

    Very interesting. It's fixed. Ajeh, the number_format string was the correct thing to change in order to use MZMT and grams without the decimal point. The problem for me was that the file was getting corrupted if I edited it directly using WS_FTP.

    I uploaded the original file back to the server from my computer and everything worked fine. I tested by simply uploading via right click and edit through WS_FTP and then (without editing anything) saving the file and then closing it which automatically uploads it. The problem reoccurs. Corrupted.

    Next, I made a copy of the mzmt.php file on my hard drive, edited it in Dreamweaver, saved it, uploaded it and renamed it. Bingo. It worked.

    Strange. But it works, movin' on.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Remove Decimal from Attribute Prices?
    By swamyg1 in forum Setting Up Categories, Products, Attributes
    Replies: 11
    Last Post: 17 Oct 2012, 04:08 AM
  2. changing shipping weight to grams
    By lukeciw in forum Setting Up Categories, Products, Attributes
    Replies: 9
    Last Post: 14 Jan 2010, 02:57 PM
  3. Need to change shipping calculation to grams
    By treasureshaven in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 29 Jul 2009, 02:21 AM
  4. Changing LB(s) to Grams in Checkout and Shipping
    By PuckQ in forum General Questions
    Replies: 5
    Last Post: 23 May 2009, 09:48 AM
  5. Shipping calculate in grams not kgs
    By arpeggio in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 27 Jan 2007, 11:53 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