Author Topic: Show Product Weights and Dimensions in Product Details  (Read 14121 times)

webzight

  • Jr. Member
  • **
  • Posts: 77
    • WEBZIGHT.COM
Show Product Weights and Dimensions in Product Details
« 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
May the Cloud be with you :)

tzic

  • Jr. Member
  • **
  • Posts: 59
Re: Show Product Weights and Dimensions in Product Details
« Reply #1 on: April 19, 2012, 15:07:17 pm »
Grab default.php from /components/com_virtuemart/views/productdetails/tmpl and add

Code: [Select]
<?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

  • Jr. Member
  • **
  • Posts: 77
    • WEBZIGHT.COM
Re: Show Product Weights and Dimensions in Product Details
« Reply #2 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)

May the Cloud be with you :)

James03

  • Beginner
  • *
  • Posts: 3
Re: Show Product Weights and Dimensions in Product Details
« Reply #3 on: June 18, 2012, 19:43:33 pm »
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

  • Jr. Member
  • **
  • Posts: 77
    • WEBZIGHT.COM
Re: Show Product Weights and Dimensions in Product Details
« Reply #4 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
May the Cloud be with you :)

serena18

  • Beginner
  • *
  • Posts: 2
Re: Show Product Weights and Dimensions in Product Details
« Reply #5 on: November 02, 2012, 12:10:28 pm »
Thanks!! it works perfectly!!

great job

serena18

  • Beginner
  • *
  • Posts: 2
Re: Show Product Weights and Dimensions in Product Details
« Reply #6 on: November 02, 2012, 12:23:42 pm »
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

  • Beginner
  • *
  • Posts: 13
Re: Show Product Weights and Dimensions in Product Details
« Reply #7 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

jekkil

  • Beginner
  • *
  • Posts: 6
Re: Show Product Weights and Dimensions in Product Details
« Reply #8 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?

Maxim Pishnyak

  • Virtuemart 2 is quite bugfree now
  • Global Moderator
  • Sr. Member
  • *
  • Posts: 2657
  • Virtuemart 2 is quite bugfree now
    • Virtuemart Ukraine division
Re: Show Product Weights and Dimensions in Product Details
« Reply #9 on: October 10, 2013, 19:08:00 pm »
Post followed instructions then.
Virtuemart 2 is quite bugfree now. You can support Community by voting for Project on the JED
http://extensions.joomla.org/extensions/e-commerce/shopping-cart/129/review
Join us in
https://www.facebook.com/virtuemart
https://twitter.com/virtuemart

f_karimian

  • Beginner
  • *
  • Posts: 1
  • A beginner
Re: Show Product Weights and Dimensions in Product Details
« Reply #10 on: November 12, 2015, 09:33:07 am »
hi,

 this code dont work for me  :(
Pleas Help me

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 26201
  • Always on vacation
    • Jenkin Hill Internet
Kelvyn

Jenkin Hill Internet,
Keswick, Lake District

Unsolicited PMs/emails will be ignored.

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

Currently using VM3.2.4 on Joomla 3.8 PHP 7.0.23

Testing VM3.2.5 on J!3.8

ch1vph

  • Beginner
  • *
  • Posts: 16
  • A beginner
Re: Show Product Weights and Dimensions in Product Details
« Reply #12 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!!!