Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2007
    Posts
    156
    Plugin Contributions
    0

    Default Decimal places in shipping weight

    Hi,
    On my site I use the weight as the shipping price which works fine, I've changed the text so that it says shipping price: £*.** on the products page.

    The problem is if say the shipping price is £2.50 it displays as £2.5 is there a way to make it insert the 0 on the end just like it does with all other prices?

    Thanks

  2. #2
    Join Date
    Jul 2007
    Posts
    156
    Plugin Contributions
    0

    Default Re: Decimal places in shipping weight

    Does anyone have any idea how I could do this?

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

    Default Re: Decimal places in shipping weight

    You would need to force it ...

    Edit the file:
    /includes/modules/pages/header_php.php

    and around line 40 you will see:
    PHP Code:
    $totalsDisplay '';
    switch (
    true) {
      case (
    SHOW_TOTALS_IN_CART == '1'):
      
    $totalsDisplay TEXT_TOTAL_ITEMS $_SESSION['cart']->count_contents() . TEXT_TOTAL_WEIGHT $shipping_weight TEXT_PRODUCT_WEIGHT_UNIT TEXT_TOTAL_AMOUNT $currencies->format($_SESSION['cart']->show_total());
      break;
      case (
    SHOW_TOTALS_IN_CART == '2'):
      
    $totalsDisplay TEXT_TOTAL_ITEMS $_SESSION['cart']->count_contents() . ($shipping_weight TEXT_TOTAL_WEIGHT $shipping_weight TEXT_PRODUCT_WEIGHT_UNIT '') . TEXT_TOTAL_AMOUNT $currencies->format($_SESSION['cart']->show_total()); 
    Change to read:
    PHP Code:
    $totalsDisplay '';
    $shipping_weight_decimal number_format($shipping_weight2);
    switch (
    true) {
      case (
    SHOW_TOTALS_IN_CART == '1'):
      
    $totalsDisplay TEXT_TOTAL_ITEMS $_SESSION['cart']->count_contents() . TEXT_TOTAL_WEIGHT $shipping_weight_decimal TEXT_PRODUCT_WEIGHT_UNIT TEXT_TOTAL_AMOUNT $currencies->format($_SESSION['cart']->show_total());
      break;
      case (
    SHOW_TOTALS_IN_CART == '2'):
      
    $totalsDisplay TEXT_TOTAL_ITEMS $_SESSION['cart']->count_contents() . ($shipping_weight_decimal TEXT_TOTAL_WEIGHT $shipping_weight_decimal TEXT_PRODUCT_WEIGHT_UNIT '') . TEXT_TOTAL_AMOUNT $currencies->format($_SESSION['cart']->show_total()); 
    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: v1.5.5]
    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
    Jul 2007
    Posts
    156
    Plugin Contributions
    0

    Default Re: Decimal places in shipping weight

    Hi Linda,
    That doesn't seem to be the right file, that one is for the shopping cart and it the shipping weight on the product info page that I need to force to 2 decimal places

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

    Default Re: Decimal places in shipping weight

    fussy, fussy, fussy ...

    In the file ... note no override here:
    /includes/modules/pages/product_info/main_template_vars.php

    Change the lines:
    PHP Code:
      $products_weight $product_info->fields['products_weight'];
      
    $products_quantity $product_info->fields['products_quantity']; 
    to read:
    PHP Code:
      $products_weight $product_info->fields['products_weight'];
    $shipping_weight_decimal number_format($products_weight2);
      
    $products_quantity $product_info->fields['products_quantity']; 
    In tpl_products_info_display.php ... be sure to use your override ... Change from:
    PHP Code:
    <!--bof Product details list  -->
    <?php if ( (($flag_show_product_info_model == and $products_model != '') or ($flag_show_product_info_weight == and $products_weight !=0) or ($flag_show_product_info_quantity == 1) or ($flag_show_product_info_manufacturer == and !empty($manufacturers_name))) ) { ?>
    <ul id="productDetailsList" class="floatingBox back">
      <?php echo (($flag_show_product_info_model == and $products_model !='') ? '<li>' TEXT_PRODUCT_MODEL $products_model '</li>' '') . "\n"?>
      <?php echo (($flag_show_product_info_weight == and $products_weight !=0) ? '<li>' TEXT_PRODUCT_WEIGHT .  $products_weight TEXT_PRODUCT_WEIGHT_UNIT '</li>'  '') . "\n"?>
      <?php echo (($flag_show_product_info_quantity == 1) ? '<li>' $products_quantity TEXT_PRODUCT_QUANTITY '</li>'  '') . "\n"?>
      <?php echo (($flag_show_product_info_manufacturer == and !empty($manufacturers_name)) ? '<li>' TEXT_PRODUCT_MANUFACTURER $manufacturers_name '</li>' '') . "\n"?>
    </ul>
    <br class="clearBoth" />
    <?php
      
    }
    ?>
    <!--eof Product details list -->
    change to:
    PHP Code:
    <!--bof Product details list  -->
    <?php if ( (($flag_show_product_info_model == and $products_model != '') or ($flag_show_product_info_weight == and $products_weight !=0) or ($flag_show_product_info_quantity == 1) or ($flag_show_product_info_manufacturer == and !empty($manufacturers_name))) ) { ?>
    <ul id="productDetailsList" class="floatingBox back">
      <?php echo (($flag_show_product_info_model == and $products_model !='') ? '<li>' TEXT_PRODUCT_MODEL $products_model '</li>' '') . "\n"?>
      <?php echo (($flag_show_product_info_weight == and $shipping_weight_decimal !=0) ? '<li>' TEXT_PRODUCT_WEIGHT .  $shipping_weight_decimal TEXT_PRODUCT_WEIGHT_UNIT '</li>'  '') . "\n"?>
      <?php echo (($flag_show_product_info_quantity == 1) ? '<li>' $products_quantity TEXT_PRODUCT_QUANTITY '</li>'  '') . "\n"?>
      <?php echo (($flag_show_product_info_manufacturer == and !empty($manufacturers_name)) ? '<li>' TEXT_PRODUCT_MANUFACTURER $manufacturers_name '</li>' '') . "\n"?>
    </ul>
    <br class="clearBoth" />
    <?php
      
    }
    ?>
    <!--eof Product details list -->
    Then customize appropriate text etc., again using the templates and overrides ...
    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: v1.5.5]
    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
    Jul 2007
    Posts
    156
    Plugin Contributions
    0

    Default Re: Decimal places in shipping weight

    Thanks Linda that worked perfectly

  7. #7
    Join Date
    Oct 2005
    Location
    Eastern US
    Posts
    488
    Plugin Contributions
    0

    Default Re: Decimal places in shipping weight

    Thanks Linda, that worked a charm for me as well.

    I am looking to extend this logic to the Product Listing Page, although on that page it will need "$" added as well. On the product info pages I was able to add the "$" in the language definitions.
    The products listing page does not seem to have corresponding files to the product info page. I'm looking for a nudge in the right direction.

    I did find includes/modules/product_listing.php
    I am not PHP literate, but I can usually manage not to break syntax and insert the logic of others (dangerous, I know.)

    Using logic I previously found to add and format item price in the shopping cart sidebox, I tried changing this:
    in includes/modules/product_listing.php around line 156
    PHP Code:
     case 'PRODUCT_LIST_WEIGHT':
            
    $lc_align 'right';
            
    $lc_text $listing->fields['products_weight'];
            break; 
    to this:
    PHP Code:
    case 'PRODUCT_LIST_WEIGHT':
            
    $lc_align 'right';
            
    $lc_text $listing->fields['products_weight']; $currencies->format($products[$i]['products_weight']) .
            break; 
    No change. I realize this wouldn't even be the entire logic, but I'm first trying to find the right file(s)

    Anyone wanna give a PHP illiterate a nudge?
    Audra

 

 

Similar Threads

  1. Currency Setting of Decimal Places vs pricing to 5 decimal places?
    By GoldBuckle in forum Customization from the Admin
    Replies: 0
    Last Post: 20 Aug 2013, 05:16 PM
  2. Shipping weight - decimal
    By ilonka in forum Built-in Shipping and Payment Modules
    Replies: 7
    Last Post: 15 Sep 2008, 08:36 PM
  3. Regiontables - Weight decimal places
    By Under pressure in forum Addon Shipping Modules
    Replies: 4
    Last Post: 5 Mar 2008, 09:47 PM
  4. Decimal places in Zone Shipping
    By livesol in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 25 Jun 2007, 09:06 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