Display Weight and Size in product details

Display weight and size in product details

If you want to display the weight and size (lenght/width/height) on the product details page just upload the following file to your vqmod/xml folder:

Product dimensions

This is the code:

[xml] <modification>

<id>Product Dimensions</id>
<version>1.0.0</version>
<vqmver>2.1.2</vqmver>
<author>everthemes.com</author>

<file name="catalog/controller/product/product.php">

<operation>
<search position="after"><![CDATA[
$this->data[‘text_model’] = $this->language->get(‘text_model’);
]]></search>
<add><![CDATA[
$this->data[‘text_weight’] = $this->language->get(‘text_weight’);
$this->data[‘text_size’] = $this->language->get(‘text_size’);
]]></add>
</operation>

<operation>
<search position="after"><![CDATA[
$this->data[‘model’] = $product_info[‘model’];
]]></search>
<add><![CDATA[
$this->data[‘weight’] = number_format($product_info[‘weight’],2) . ‘ kg’;
$this->data[‘length’] = number_format($product_info[‘length’],2) . ‘ cm’;
$this->data[‘width’] = number_format($product_info[‘width’],2) . ‘ cm’;
$this->data[‘height’] = number_format($product_info[‘height’],2) . ‘ cm’;
]]></add>
</operation>

</file>

<file name="catalog/view/theme/*/template/product/product.tpl">
<operation>
<search position="after"><![CDATA[
<span><?php echo $text_stock; ?></span> <?php echo $stock; ?>
]]></search>
<add><![CDATA[
<?php if ($weight) { ?>
<br /><span><?php echo $text_weight; ?></span> <?php echo $weight; ?>
<?php } ?>
<?php if ($length || $width || $height) { ?>
<br /><span><?php echo $text_size; ?></span> <?php echo $length; ?> x <?php echo $width; ?> x <?php echo $height; ?>
<?php } ?>
]]></add>
</operation>
</file>

<file name="catalog/language/english/product/product.php">
<operation>
<search position="before"><![CDATA[
?>
]]></search>
<add><![CDATA[
$_[‘text_weight’] = ‘Weight:’;
$_[‘text_size’] = ‘Size (LxWxH):’;
]]></add>
</operation>
</file>

</modification>

[/xml]

Change the units from line 25 to 28.

2 replies on “Display Weight and Size in product details”

Leave a Reply to Agus Widi Cancel reply

Your email address will not be published. Required fields are marked *