Magento Themes and Magento Extensions

How to change Weight Attribute decimals Magento


There is no simple way to change the decimal numbers in the Weight Attribute in Magento.

And is not a specific solution either.

What can we do?

For example, we can force to all numeric attributes to show with 2 decimals.

Open the attributes.phtml located in:

app/design/frontend/YOUR THEME/template/catalog/product/view/

I changed this:

<?php echo $_helper->productAttribute($_product, strip_tags($_data['value']), $_data['code']) ?

To this:

$_MyValue = $_data['value'];
if (is_numeric($_MyValue))
$_MyValue = round($_MyValue, 2); //round to 0.00
<?php echo $_helper->productAttribute($_product, strip_tags($my_data_value), $_data['code']) ?>

What it does?

The code above adds a condition is_numeric and uses the round function to round it

After it we just print again the attributes with our new value, in this case $my_data_value

Leave a Reply

You must be logged in to post a comment.