View Single Post
  #1  
Old 05-21-2004, 02:45 AM
 
bluesunomi bluesunomi is offline
 

Member
  
Join Date: Feb 2004
Location: Oxford, UK
Posts: 22
 

Default Product weight in grams with no decimal places.

Hi,

If you have your site product weight set to just grams then it makes sense to remove the 2 decimal places when displaying product details as this is kind of meaningless (and at a glance misread). (i.e. 25 g looks better than 25.00 g)

I'm sure its not the only way of fixing this, but I've managed to sort this one by using the smarty math function to multiply the weight by 1 and format the output to 0 decimal places with

Code:
{math equation="x*1" x=$product.weight format="%.0f"}

This update affects Skin1\customer\main\product.tpl
(make sure you edit product, and not products with an s in the same directory or you'll get confused)

--------------

Update the following line - approx 26 lines from the top (which displays the product detail weight)

Code:
{if $product.weight ne "0.00"}<tr><td width=30%>{$lng.lbl_weight}</td><td nowrap>{$product.weight} {$config.General.weight_symbol}</td></tr>{/if}

with this one (replacing the {$product.weight} with the math function above)

Code:
{if $product.weight ne "0.00"}<tr><td width=30%>{$lng.lbl_weight}</td><td nowrap>{math equation="x*1" x=$product.weight format="%.0f"} {$config.General.weight_symbol}</td></tr>{/if}

And that's it !

Id be interested to know if there are any alternative or less compute intensive way of doing this - it's a shame smarty doesn't have a string function) - I think maybe a weight format option wouldn't be a bad idea for future relase maybe?

Anyway, TTFN,

John
Reply With Quote