News:

Support the VirtueMart project and become a member

Main Menu

Show Product Weights and Dimensions in Product Details

Started by webzight, April 19, 2012, 06:28:12 AM

Previous topic - Next topic

webzight

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
May the Cloud be with you :)

tzic

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

webzight

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)

May the Cloud be with you :)

James03

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


Actually on Joomla 2.5.6 & V.M. 2.0.8c

webzight

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
May the Cloud be with you :)

serena18


serena18

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.

Bit Stupid

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

jekkil

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?

Maxim Pishnyak

You can support Community by voting for Project on the JED
[url="https://extensions.joomla.org/extension/virtuemart/#reviews"]https://extensions.joomla.org/extension/virtuemart/#reviews[/url]
Join us at
[url="https://twitter.com/virtuemart"]https://twitter.com/virtuemart[/url]

f_karimian


jenkinhill

Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

ch1vph

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!!!