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']) ?>
Code language: HTML, XML (xml)

To this:

<?php $_MyValue = $_data['value']; if (is_numeric($_MyValue)) { $_MyValue = round($_MyValue, 2); //round to 0.00 } ?> <?php echo $_helper->productAttribute($_product, strip_tags($_MyValue), $_data['code']) ?>
Code language: HTML, XML (xml)

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

Add <code> Some Code </code> by using this tags.