Author Topic: Virtuemart 1.1.9 Product Dimension Decimals - length, width, height and weight  (Read 10170 times)

brentonking

  • Jr. Member
  • **
  • Posts: 74
    • Brenton King Graphic Design, Web Design and Joomla! Site Development
How do I change how many decimals appear in the product dimensions, length, width, height and weight?

I have looked through the forum and could only find sql changes and old hacks and want to check if there is an updated (and better) way?

MobiVM

  • Jr. Member
  • **
  • Posts: 267
    • Native Mobile Apps for VritueMart
Re: Virtuemart Product Dimension Decimals - length, width, height and weight
« Reply #1 on: September 01, 2011, 08:53:23 am »
Hello,

You need to change in your database:-

table name:- jos_vm_product and alter table and product_length decimal(10,4)-> decimal(10,2)

same for other fields.

Best Regards,
Trivedi kartik.
Native mobile Apps for VirtueMart! Visit http://www.ivmstore.com

brentonking

  • Jr. Member
  • **
  • Posts: 74
    • Brenton King Graphic Design, Web Design and Joomla! Site Development
Re: Virtuemart Product Dimension Decimals - length, width, height and weight
« Reply #2 on: September 01, 2011, 09:11:48 am »
Thanks! Worked fine. I was just hoping there was a better way to do it without editing the database.

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10497
  • VM4.0.7 Eagle Owl
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Virtuemart Product Dimension Decimals - length, width, height and weight
« Reply #3 on: February 04, 2015, 11:06:13 am »
Yes the way is the wrong way.
The right way is to add a round() to the display. If you want to display 2 digits, it is absolutly wrong to calculate only with  2 digits. Else you cannot even write 1/8.

So I would just use something like echo round($product->product_weight,2);

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

saviB

  • Jr. Member
  • **
  • Posts: 187
I'm no PHP programmer, so I often have trouble using help found on this forum. Syntax is always the issue. To help those like me, here is the idiot guide to how to add UOM (Unit of Measure), Length, Width, Height, and how to truncate the decimal points. This solution - from Max works great.

1. In Template manager, Click on Templates on the right side (just below Styles).
2. In the templates returned, scroll to and select the template you are using.
3. In the tabs, click Create Override
4. In the second column, click com_virtuemart
5. Click Editor in the tabs
6. Click HTML in the left side menu
7. Click com_virtuiemart
8. Click productdetails
9. Click default.php
10. Find in the file where you want the UOM to go. I chose to place it below the image and above the long description - after line 181 showing: <div class="clear"></div>.
11. Add a return where you want to place the UOM. So, in my case (step: 10 above) add a return after line 181.
12. Create a new div. I chose to add a class so I can control how the content displays. So you should see this now:

Line 181: <div class="clear"></div>
Line 182:
Line 183:<div class="my_new_div"></div>

13. Add the following code between your new div tags:

Product Size:
  L: <?php echo round($this->product->product_length,2) ?> <?php echo $this->product->product_lwh_uom ?>
  W: <?php echo round($this->product->product_width,2) ?> <?php echo $this->product->product_lwh_uom ?>
  H: <?php echo round($this->product->product_height,2) ?> <?php echo $this->product->product_lwh_uom ?>

14. Save, view, and edit as you see fit.

What's doing what?

1. Product Size: This is just text that will go before the LWH display. You can write whatever you want, or use a language block (I don't know the correct term for this). Language block is the way to go if your site is multi lingual.

2. L: More text - like in point 1.

3. <?php echo round($this->product->product_length,2) ?> This part: $this->product->product_length, displays the product LENGTH.

3a. This part: round() to it removes the additional decimals added by the VM system.

3b. If you wanted to show all the decimal places, you would use this instead - remove the round(): <?php echo $this->product->product_length ?> instead.

4. <?php echo $this->product->product_lwh_uom ?> This shows the UOM for LWH set in CONFIGURATION.

The block shown in step 13 will display like this: Product Size: L:Value CM W:Value CM H:Value CM

I hope this helps someone. If I've made any mistakes - please feel free to correct me. Including terminology.

ryandiaz

  • Beginner
  • *
  • Posts: 18
  • VirtueMart Version: 1.1.6 Stable
Thank you saviB, not only for your help in solving this but for the extremely fool proof and extensive way you described your work.
Joomla 1.5.22 | Virtuemart 1.1.6 Stable | PHP 5.3.13

JCott

  • Beginner
  • *
  • Posts: 1
  • A beginner
Some good tips over here, relatively straightforward, too. You wouldn't have to tweak the database too much to get the desired results