VirtueMart Forum

VirtueMart 2 + 3 + 4 => Administration & Configuration => Topic started by: webzight on April 19, 2012, 06:28:12 AM

Title: Show Product Weights and Dimensions in Product Details
Post by: webzight on April 19, 2012, 06:28:12 AM
This is another one of those questions I thought I had seen an answer for previously, but can't seem to find it doing a search. :o

Why doesn't all the product information show in the 'Product Details' view, i.e. product weight and dimensions, UOM, etc and is there a way to make this happen ???

My client has been harping on this ever since I started building her site as a necessary required function!!

If I have to hand code it in, I'll do that, but I was hoping there is an easier way ???

[Edit by Milbo: vm3.0.12 has the customfield type "Property" which allows to display a property of the product (for example the weight)], please read http://docs.virtuemart.net/manual/general-concepts/212-customfields.html
Title: Re: Show Product Weights and Dimensions in Product Details
Post by: tzic on April 19, 2012, 15:07:17 PM
Grab default.php from /components/com_virtuemart/views/productdetails/tmpl and add

<?php //Product Weight
if (!(($this->product->product_weight)==0)) { ?>

<span class="product-fields-title" >
<?php echo JText::_('COM_VIRTUEMART_PRODUCT_WEIGHT'?>
</span>
<?php echo $this->product->product_weight ?>
</br>
<?php ?>

<?php //Product Length
if (!(($this->product->product_length)==0)) { ?>


<?php echo JText::_('COM_VIRTUEMART_PRODUCT_LENGTH'?>
<strong>
<?php echo floor($this->product->product_length?></strong>
</br>
<?php ?>

<?php //Product Width
if (!(($this->product->product_width)==0)) { ?>


<?php echo JText::_('COM_VIRTUEMART_PRODUCT_WIDTH'?>
<strong>
<?php echo floor($this->product->product_width?></strong>
</br>
<?php ?>

<?php //Product Height
if (!(($this->product->product_height)==0)) { ?>

<span class="product-fields-title" >
<?php echo JText::_('COM_VIRTUEMART_PRODUCT_HEIGHT'?>
</span>
<?php echo floor($this->product->product_height?>
</br>
<?php ?>


anywhere you want it to show
Title: Re: Show Product Weights and Dimensions in Product Details
Post by: webzight on April 20, 2012, 01:49:20 AM
Thanks tzic your code does work :D

The line breaks </br> were not working, everything was run together on one line :-\

Inserted <p style="text-align: left;"></p> between each element and that fixed it ;)

Now I need to get the unit-of-measure (UOM) to display and I'll be happier than a hooker on payday 8)

Title: Re: Show Product Weights and Dimensions in Product Details
Post by: James03 on June 18, 2012, 19:43:33 PM
Quote from: webzight on April 20, 2012, 01:49:20 AM
Thanks tzic your code does work :D

The line breaks </br> were not working, everything was run together on one line :-\

Inserted <p style="text-align: left;"></p> between each element and that fixed it ;)

Now I need to get the unit-of-measure (UOM) to display and I'll be happier than a hooker on payday 8)

You may add the following row after <?php echo $this->product->product_length ?> - <?php echo $this->product->product_width ?> etc.

<?php echo $this->product->product_lwh_uom ?>

The UOM is the same for length, width and heigth so you have to repeat the same row three times.

Attention Tested only on VM 2.0.6


Title: Re: Show Product Weights and Dimensions in Product Details
Post by: webzight on June 19, 2012, 00:23:57 AM
Thanks James for the info :D

The issue I am having now is the decimals are being truncated from the length and width numbers, i.e. instead of 24.375 it just displays 24 :(

What am I missing here ???

I am running the latest "stable" versions of everything :o
Title: Re: Show Product Weights and Dimensions in Product Details
Post by: serena18 on November 02, 2012, 12:10:28 PM
Thanks!! it works perfectly!!

great job
Title: Re: Show Product Weights and Dimensions in Product Details
Post by: serena18 on November 02, 2012, 12:23:42 PM
Quote from: webzight on June 19, 2012, 00:23:57 AM
Thanks James for the info :D

The issue I am having now is the decimals are being truncated from the length and width numbers, i.e. instead of 24.375 it just displays 24 :(

What am I missing here ???

I am running the latest "stable" versions of everything :o

You have to change <?php echo floor($this->product->product_weight)  ?>  for  <?php echo $this->product->product_weight  ?> this function returns a float value rounded to the next lowest integer.
Title: Re: Show Product Weights and Dimensions in Product Details
Post by: Bit Stupid on October 03, 2013, 16:43:56 PM
Thanks to tzic for this.  Exactly what I was looking for. 

Serena18, excellent thank you as well although this info helped me to figure out something different.  The above gave me the weight with 4 decimals after (like 10.0000KG) which looked silly.  So I basically did the reverse
replaced <?php echo $this->product->product_weight ?> with <?php echo floor($this->product->product_weight)  ?>
and it returns the display to 10KG

Fab guys thanks
Title: Re: Show Product Weights and Dimensions in Product Details
Post by: jekkil on October 08, 2013, 13:45:22 PM
Hi , i followed the instructions by the letter, but there is nothing showing up in the product details;

Joomla and VM all latest versions, template Furniturestore from HotTemplate

any idea?
Title: Re: Show Product Weights and Dimensions in Product Details
Post by: Maxim Pishnyak on October 10, 2013, 19:08:00 PM
Post followed instructions then.
Title: Re: Show Product Weights and Dimensions in Product Details
Post by: f_karimian on November 12, 2015, 09:33:07 AM
hi,

this code dont work for me  :(
Pleas Help me
Title: Re: Show Product Weights and Dimensions in Product Details
Post by: jenkinhill on November 12, 2015, 10:21:03 AM
http://forum.virtuemart.net/index.php?topic=104795.0
Title: Re: Show Product Weights and Dimensions in Product Details
Post by: ch1vph on July 04, 2017, 22:46:54 PM
Place the code above under this code in the default.php in html/com_virtuemart/productdetails...I did via template

<div class="productdetails-tabs">
<ul class="nav nav-tabs">
<li class="active"><a href="#desc" data-toggle="tab">
<?php echo JText::_('COM_VIRTUEMART_PRODUCT_DESC_TITLE') ?></a></li>
<li><a href="#review" data-toggle="tab">Reviews</a></li>
</ul>
<div class="tab-content">

CODE IN POST ABOVE GOES HERE!!!