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
Re: Decimal places in shipping weight
Does anyone have any idea how I could do this?
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 > 0 ? 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_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());
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
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:
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_weight, 2);
$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 == 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:
PHP Code:
<!--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 ...
Re: Decimal places in shipping weight
Thanks Linda that worked perfectly
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