Forums / General Questions / Decimal places in shipping weight

Decimal places in shipping weight

Locked

Views: 2,113

Results 1 to 7 of 7
This thread is locked. New replies are disabled.
12 Nov 2007, 6:53 PM
#1
phil020782 avatar

phil020782

Zen Follower

Join Date:
Jul 2007
Posts:
158
Plugin Contributions:
0

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

13 Nov 2007, 4:52 PM
#3
ajeh avatar

ajeh

Oba-san

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

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:

$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 > 0 ? TEXT_TOTAL_WEIGHT . $shipping_weight . TEXT_PRODUCT_WEIGHT_UNIT : '') . TEXT_TOTAL_AMOUNT . $currencies->format($_SESSION['cart']->show_total());

Change to read:

$totalsDisplay = '';
$shipping_weight_decimal = number_format($shipping_weight, 2);
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 > 0 ? 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!]
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!

14 Nov 2007, 4:27 AM
#5
ajeh avatar

ajeh

Oba-san

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

Re: Decimal places in shipping weight

fussy, fussy, fussy ... :rolleyes:

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

Change the lines:

  $products_weight = $product_info->fields['products_weight'];
  $products_quantity = $product_info->fields['products_quantity'];

to read:

  $products_weight = $product_info->fields['products_weight'];
$shipping_weight_decimal = number_format($products_weight, 2);
  $products_quantity = $product_info->fields['products_quantity'];

In tpl_products_info_display.php ... be sure to use your override ... Change from:

<!--bof Product details list  -->
<?php if ( (($flag_show_product_info_model == 1 and $products_model != '') or ($flag_show_product_info_weight == 1 and $products_weight !=0) or ($flag_show_product_info_quantity == 1) or ($flag_show_product_info_manufacturer == 1 and !empty($manufacturers_name))) ) { ?>
<ul id="productDetailsList" class="floatingBox back">
  <?php echo (($flag_show_product_info_model == 1 and $products_model !='') ? '<li>' . TEXT_PRODUCT_MODEL . $products_model . '</li>' : '') . "\n"; ?>
  <?php echo (($flag_show_product_info_weight == 1 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 == 1 and !empty($manufacturers_name)) ? '<li>' . TEXT_PRODUCT_MANUFACTURER . $manufacturers_name . '</li>' : '') . "\n"; ?>
</ul>
<br class="clearBoth" />
<?php
  }
?>
<!--eof Product details list -->

change to:

<!--bof Product details list  -->
<?php if ( (($flag_show_product_info_model == 1 and $products_model != '') or ($flag_show_product_info_weight == 1 and $products_weight !=0) or ($flag_show_product_info_quantity == 1) or ($flag_show_product_info_manufacturer == 1 and !empty($manufacturers_name))) ) { ?>
<ul id="productDetailsList" class="floatingBox back">
  <?php echo (($flag_show_product_info_model == 1 and $products_model !='') ? '<li>' . TEXT_PRODUCT_MODEL . $products_model . '</li>' : '') . "\n"; ?>
  <?php echo (($flag_show_product_info_weight == 1 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 == 1 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!]
Officially PayPal-Certified! Just click here

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

2 Feb 2009, 3:40 PM
#7
audradh avatar

audradh

Zen Follower

Join Date:
Oct 2005
Location:
Eastern US
Posts:
429
Plugin Contributions:
0

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

 case 'PRODUCT_LIST_WEIGHT':
        $lc_align = 'right';
        $lc_text = $listing->fields['products_weight'];
        break;

to this:

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