VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: antodones on April 11, 2012, 00:59:51 AM

Title: decimal hide the product weight
Post by: antodones on April 11, 2012, 00:59:51 AM
Would it be possible to hide decimal weight of the product?
Sorry for my English

[attachment cleanup by admin]
Title: Re: decimal hide the product weight
Post by: antodones on April 13, 2012, 16:11:33 PM
Anyone can help me?
thanks
Title: Re: decimal hide the product weight
Post by: Piccolopoeta on December 22, 2015, 20:43:19 PM
Hi, I think I have the same issue..know this topic is old, if you want I can create a new one, but it's the exact same problem
Title: Re: decimal hide the product weight
Post by: GJC Web Design on December 22, 2015, 22:06:47 PM
this has been asked and I have answered at least twice

last time

simple php for what ever the display is

do

$weight = number_format($weight,2);

echo $weight;
Title: Re: decimal hide the product weight
Post by: Piccolopoeta on December 23, 2015, 08:17:36 AM
Yes I read that, but still the same problem as the other user;
I don't understand where I should put this string, have been opening many css but even with firebug can't grasp it
Title: Re: decimal hide the product weight
Post by: AH on December 23, 2015, 10:09:21 AM
You have to do this in a product details page override

Look in the forum on how to do overrides
Title: Re: decimal hide the product weight
Post by: PRO on December 23, 2015, 10:39:27 AM
views/productdetails/default.php

after this
<div class="productdetails-view productdetails">

add this
<?php
$this->product->product_weight = number_format($this->product->product_weight,2);
?>
Title: Re: decimal hide the product weight
Post by: Piccolopoeta on December 23, 2015, 12:02:37 PM
Thanks, your help is greatly appreciated. Yet, I keep having the same issue, the numbers keep on showing like this
http://www.toelettaroma.it/index.php/shop2/cani/alimentazione/cuccioli-fino-a-4-5-mesi

Actually I went in
Components/com_virtuemart/views/productdetails/tmpl/default.php
added the string
<?php $weight = number_format($weight,2);
echo $weight;
?>

but nothing changed

tried with this, thought it seems strange, and still nothing happened
<?php
$this->product->product_weight = number_format($this->product->product_weight,2);
?>

tried to change it to
<?php
$this->product->product_weight = number_format(weight,2);
?>

but still unchanged

sorry bothering!

Also in the backend, when I save with "1" as soon as I reopen the product it gives 1.0000 right away!
Title: Re: decimal hide the product weight
Post by: GJC Web Design on December 23, 2015, 12:49:03 PM
this isn't even the weight!!!!!!

it is your custom fields I assume your talking about..

search for custom fields display
Title: Re: decimal hide the product weight
Post by: Piccolopoeta on December 23, 2015, 12:55:25 PM
Yes, it's the weight, and then the custom field is linked to the weight!
Here's the backend screenshot

https://www.dropbox.com/s/fpm9bvxnwcz0fmw/Screenshot%202015-12-23%2012.54.37.png?dl=0
Title: Re: decimal hide the product weight
Post by: PRO on December 23, 2015, 13:19:34 PM
Quote from: Piccolopoeta on December 23, 2015, 12:02:37 PM
Thanks, your help is greatly appreciated. Yet, I keep having the same issue, the numbers keep on showing like this
http://www.toelettaroma.it/index.php/shop2/cani/alimentazione/cuccioli-fino-a-4-5-mesi

Actually I went in
Components/com_virtuemart/views/productdetails/tmpl/default.php
added the string
<?php $weight = number_format($weight,2);
echo $weight;
?>

but nothing changed

tried with this, thought it seems strange, and still nothing happened
<?php
$this->product->product_weight = number_format($this->product->product_weight,2);
?>

tried to change it to
<?php
$this->product->product_weight = number_format(weight,2);
?>

but still unchanged

sorry bothering!

Also in the backend, when I save with "1" as soon as I reopen the product it gives 1.0000 right away!


thats not the product page.

Its the category
Title: Re: decimal hide the product weight
Post by: Piccolopoeta on January 14, 2016, 11:38:50 AM
Uh..but it's just the same in the product details, see?
http://www.toelettaroma.it/index.php/shop2/cani/alimentazione/cuccioli-fino-a-4-5-mesi/primi-mesi-bufalo-detail

I get the same problem when i edit the product via administration. Even if I write "1" in the product weight, as soon as I save, it turns to "1.000"!
Title: Re: decimal hide the product weight
Post by: GJC Web Design on January 14, 2016, 13:40:56 PM
just change the display as above.. it will ALWAYS be stored as 1.0000 .. doesn't need to be displayed as..
enuf info above to achieve this
Title: Re: decimal hide the product weight
Post by: PRO on January 14, 2016, 18:40:33 PM
Quote from: Piccolopoeta on January 14, 2016, 11:38:50 AM
Uh..but it's just the same in the product details, see?
http://www.toelettaroma.it/index.php/shop2/cani/alimentazione/cuccioli-fino-a-4-5-mesi/primi-mesi-bufalo-detail

I get the same problem when i edit the product via administration. Even if I write "1" in the product weight, as soon as I save, it turns to "1.000"!


this is tested for product details page.
This removed the decimals

<?php
$this->product->product_weight = number_format($this->product->product_weight,0);
echo $this->product->product_weight;
?>

THEN: on the category page this is tested and working

<?php
$product->product_weight = number_format($product->product_weight,0);
echo $product->product_weight;

?>