Page 1 of 1
[1.4.9.1] How to add weight + weigh unit for product
Posted: Wed Nov 24, 2010 12:32 pm
by mohit11
opencart ver 1.4.91.- how to add weight and weigh unit for products and in the cart
have looked in the forum but the code is for version 1.2.9 which doesnt work for the newer er 1.4.9.1
can some guide please
Re: opencart ver 1.4.91.- how to add weight and weigh unit f
Posted: Thu Nov 25, 2010 3:30 am
by Candesco
Hello mohit11,
I do not know for the cart, but I do for the product page.
Open /template/product/product.tpl
Find
Code: Select all
<tr>
<td><b><?php echo $text_model; ?></b></td>
<td><?php echo $model; ?></td>
</tr>
And add just after or before) :
Code: Select all
<tr>
<td><b><?php echo $text_weight; ?></b></td> // declare it in both language and controller folders to display "Weight" on the page
<td><?php echo $product_info['weight'] ;?></td>
</tr>
Hope it helps!
Re: [1.4.9.1] How to add weight + weigh unit for product
Posted: Thu Nov 25, 2010 1:32 pm
by mohit11
Hi Candesco
tried it and didnt work.
Regards
Mohit
Re: [1.4.9.1] How to add weight + weigh unit for product
Posted: Thu Nov 25, 2010 3:58 pm
by Candesco
well, it should ^^
see on my store (with $product_info['length'], $product_info['width'], $product_info['height'] called exactly as $product_info['weight'] :
http://candesco.be/oc/index.php?route=p ... duct_id=33
did you get an error message ?
Re: [1.4.9.1] How to add weight + weigh unit for product
Posted: Fri Nov 26, 2010 3:04 am
by mohit11
Hi,
This is my cat-view-theme-temp-prod-prod.tpl
<tr>
<td><b><?php echo $text_model; ?></b></td>
<td><?php echo $model; ?></td>
<tr>
<td><b><?php echo $text_weight; ?></b></td> // declare it in both language and controller folders to display "Weight" on the page
<td><?php echo $product_info['weight'] ;?></td>
</tr>
<?php if ($manufacturer) { ?>
<tr>
and this is the error i get on my website- weight unit shows properly
http://patashiexports.com/index.php?rou ... duct_id=49
Re: [1.4.9.1] How to add weight + weigh unit for product
Posted: Fri Nov 26, 2010 11:43 pm
by Candesco
you get this error because you forgot to declare $text_weight

To do so, open /catalog/language/english/product/product.php
Find
Add just after :
If you have other languages on your website, you have to do the same for each of them (e.g. if you have Dutch; then edit the /catalog/language/dutch/product/product.php)
Then, open /catalog/controller/product/product.php
Find
Code: Select all
$this->data['text_model'] = $this->language->get('text_model');
Add just after :
Code: Select all
$this->data['text_weight'] = $this->language->get('text_weight');
The error should now disappear
ps: you can delete the
Code: Select all
// declare it in both language and controller folders to display "Weight" on the page
Re: [1.4.9.1] How to add weight + weigh unit for product
Posted: Sat Nov 27, 2010 1:37 am
by mohit11
Thanks a lot.
works perfectly
Is there any way to show the weight unit as well?
Re: [1.4.9.1] How to add weight + weigh unit for product
Posted: Sat Nov 27, 2010 1:50 am
by mohit11
The weight unit kgs is displaying on your web site.
Re: [1.4.9.1] How to add weight + weigh unit for product
Posted: Sat Nov 27, 2010 7:51 pm
by Candesco
Of course

open ....../template/product/product.tpl
Change this
Code: Select all
<tr>
<td><b><?php echo $text_weight; ?></b></td>
<td><?php echo $product_info['weight'] ;?></td>
</tr>
by this
Code: Select all
<tr>
<td><b><?php echo $text_weight; ?></b></td>
<td><?php echo $product_info['weight'] . 'kgs' ;?></td>
</tr>
Re: [1.4.9.1] How to add weight + weigh unit for product
Posted: Sat Nov 27, 2010 10:50 pm
by Johnathan
Just a quick note: this won't actually use the weight_unit for the product, it'll just use "kg" for everything. The only way to get the weight_unit is doing something like I suggested
in this post.
Re: [1.4.9.1] How to add weight + weigh unit for product
Posted: Sun Nov 28, 2010 11:39 am
by mohit11
Thank you Candesco ,
it works
Weight: 0.20kg
Now how dd you get the space betwwen the weight amount and weight unit or kgs
0.20 kg ?
Regards
Mohit
Jonathan I am using only kg unit so this is prefect for me ,thanks.

Re: [1.4.9.1] How to add weight + weigh unit for product
Posted: Thu Dec 02, 2010 10:05 pm
by Candesco
Just add
before kgs.
Your code will then look like :
<tr>
<td><b><?php echo $text_weight; ?></b></td>
<td><?php echo $product_info['weight'] . ' kgs' ;?></td>
</tr>
One
equals one space. You can add more if you want.
Re: [1.4.9.1] How to add weight + weigh unit for product
Posted: Sun Feb 26, 2012 1:47 am
by sayx
Can anyone update this for 1.5.1.3 tried the code and not working. Looks like there has been some larger changes to the code from 1.4 to 1.5.
thanks