Page 1 of 3
[MOD] Show weight in product description
Posted: Fri Jul 24, 2009 12:25 am
by wilmaogando
Hi everybody, firstable i don´t speak english very well but i will try to explain myself.
I don´t know php, but i have my store in OpenCart 1.2.9
I sell perfumes and i am having a problem. Each perfume comes in differents sizes, like
1.7 ounces and 3.4 ounces.
I allready created the weight class and coversion, but if i have the both perfumes in stock
what i am doing is creating the product again, for example:
1 product: 212 perfume 1.7ounces
1 product: 212 perfume 3.4ounces
The ounces i am putting it in the camp for weight. But the problem is when a client see the product in the
store don't know wich one is because it doesn´t display weight even when they clic the product
the only information that says about the product is: Price, Availability, Model, Manufacturer and Average Rating.
The big question is: HOW CAN I MAKE THE WEIGHT BE DISPLAYED INTO DE PRODUCT INFORMATION???
OR ANY SUGESTION??
Re: Show weight in product description
Posted: Fri Jul 24, 2009 1:29 am
by slawrence10
Hey
You could put it in the grey box that displays stock, model and rating average quite easily.
In cart/catalog/controller/product/product.php
after
Code: Select all
$this->data['text_wait'] = $this->language->get('text_wait');
add this line
Code: Select all
$this->data['text_weight'] = $this->language->get('text_weight');
after:
Code: Select all
$this->data['average'] = $average;
add this line:
Code: Select all
$this->data['weight'] = $product_info['weight'];
In cart/catalog/language/english/product/product.php
after
add
Finally in
cart/catalog/view/theme/default/template/product/product.tpl
after
Code: Select all
<tr>
<td><b><?php echo $text_availability; ?></b></td>
<td><?php echo $stock; ?></td>
</tr>
add
Code: Select all
<tr>
<td><b><?php echo $text_weight; ?></b></td>
<td><?php echo $weight; ?></td>
</tr>
Let me know how it goes
Scott
Re: Show weight in product description
Posted: Sun Aug 09, 2009 1:50 am
by wilmaogando
Thank you very much slawrence10!!
Today I'am looking your answer I was waiting the answer to be received in my mail.
And today I check here and found your HELP, thanks.
It works perfectly!!!
Now another question, that weight can be shown down the name and model
in the page that list all the manufacturer products?? I don´t know if I’m explaining
myself right, so I give an example: When you select a manufacturer the web page
shows all the products it has, but each product just presents: Name, Model and Price.
Can the weight be there two??? in perfumes this is really important because the image
is the same but the difference in price is the ounces it has.
Thank, Wilma
Re: Show weight in product description
Posted: Sun Aug 09, 2009 2:22 am
by slawrence10
Yes
go to
catalog\controller\product\manufacturer.php
and
add
after this (line 81 on mine)
Code: Select all
$this->data['products'][] = array(
'name' => $result['name'],
'model' => $result['model'],
then go to
catalog\view\theme\default\template\product\manufacturer.tpl
and
add this
Code: Select all
<span style="color: #999; font-size: 11px;">
<?php echo $products[$j]['weight']; ?>
</span><br>
after this (line 26 on mine)
Code: Select all
<a href="<?php echo $products[$j]['href']; ?>"><?php echo $products[$j]['name']; ?></a><br />
Let me know how it goes,
Scott
Re: Show weight in product description
Posted: Sun Aug 09, 2009 2:59 am
by wilmaogando
Yes it works!!! thanks again!!
But its not shown when you clic the categories, just in manufacturers, can you add me that?
Sorry for asking so much.
Wilma

Re: Show weight in product description
Posted: Sun Aug 09, 2009 3:22 am
by slawrence10
Basically the same just have to find the code at different lines
go to
catalog\controller\product\category.php
and
add
after this (line 133 on mine)
Code: Select all
$this->data['products'][] = array(
'name' => $result['name'],
'model' => $result['model'],
then go to
catalog\view\theme\default\template\product\category.tpl
and
add this
Code: Select all
<span style="color: #999; font-size: 11px;">
<?php echo $products[$j]['weight']; ?>
</span><br>
after this (line 44 on mine)
Code: Select all
<a href="<?php echo $products[$j]['href']; ?>"><?php echo $products[$j]['name']; ?></a><br />
Cheers
Scott
Re: Show weight in product description
Posted: Sat Aug 15, 2009 5:21 pm
by banane
sorry
does someone knows how to show the weight unit just after the weight? I found the instructions on top really valuable, but having the weight without unit isn't so useful.
I'm using opencart 1.3.2
many thanks
Re: Show weight in product description
Posted: Sat Aug 15, 2009 11:18 pm
by Qphoria
^^
Yes, in the controller of each of the files above, when you do
'weight' => $result['weight'],
change it to
'weight' => $this->weight->format($result['weight'], $this->config->get('config_weight_class_id'))
Re: Show weight in product description
Posted: Sun Aug 16, 2009 10:14 pm
by banane
thanks Qphoria
it's working but I guess there's something wrong. even if I've set different weight unit for each products, I always see the default weight unit for each product and not the right one. I've checked the weight class and seems to be ok..
and, another thing: how can I put and extra empty space between weight and unit?
many thanks!
Re: Show weight in product description
Posted: Sun Aug 16, 2009 11:39 pm
by Qphoria
yea sorry.. i gave you the code for the store-wide unit, not the per product unit.
Try
'weight' => $this->weight->format($result['weight'], $result['weight_class_id'])
Re: Show weight in product description
Posted: Mon Aug 17, 2009 12:31 am
by banane
it's working!
thanks, I really appreciated
Re: Show weight in product description
Posted: Mon Aug 17, 2009 8:57 am
by wilmaogando
Thanks for that Qphoria too!!
Another question, wich files do I need to modify for this information appear in the Index page, in the section down the Welcome message, to the latest products??.
I already modify (with Scott insctruction):
catalog/controller/product/category.php
catalog/controller/product/manufacturer.php
catalog/controller/product/product.php
catalog/controller/product/search.php
catalog/controller/product/special.php
catalog/view/theme/default/template/product/product.tpl
catalog/view/theme/default/template/product/category.tpl
catalog/view/theme/default/template/product/manufacturer.tpl
catalog/view/theme/default/template/product/search.tpl
catalog/view/theme/default/template/product/special.tpl
But is not workin just appear, product name, model and price.
Thanks in advance,
Wilma
Re: Show weight in product description
Posted: Mon Aug 17, 2009 5:14 pm
by banane
I guess you have to modify those files:
catalog/controller/common/home.php
catalog/view/theme/default/template/common/home.tpl
Re: Show weight in product description
Posted: Tue Aug 18, 2009 1:17 am
by wilmaogando
Thanks to all you it's working, it's being shown in my index too!!
But the other contribution about show the weight unit just after the weight is not working for me.
I have to be missing something.
Here I post my changes:
In: /catalog/controller/product/product.php
I add this:
$this->data['text_weight'] = $this->language->get('text_weight');
and this:
$this->data['weight'] = $product_info['weight'];
In /catalog/language/english/product/product.php
I add this:
$_['text_weight'] = 'Weight';
In /catalog/view/theme/default/template/product/product.tpl
I add this:
<tr>
<td><b><?php echo $text_weight; ?></b></td>
<td><?php echo $weight; ?></td>
</tr>
AND I MODIFY ALL THIS OTHER FILES:
with this on php: 'weight' => $result['weight'],
an this on tpl:
<span style="color: #999; font-size: 11px;">
<?php echo $products[$j]['weight']; ?>
</span><br>
catalog/controller/product/category.php
catalog/controller/product/manufacturer.php
catalog/controller/product/product.php
catalog/controller/product/search.php
catalog/controller/product/special.php
catalog/view/theme/default/template/product/product.tpl
catalog/view/theme/default/template/product/category.tpl
catalog/view/theme/default/template/product/manufacturer.tpl
catalog/view/theme/default/template/product/search.tpl
catalog/view/theme/default/template/product/special.tpl
BUT TO ADD THE weight unit I JUST CHANGE IN PHP FILES:
this: 'weight' => $result['weight'],
for this: 'weight' => $this->weight->format($result['weight'], $result['weight_class_id'])
What am I missing please?? its working for you banane right? what i did wrong?
--------------------------------------
Do anybody knows something about this question?
http://forum.opencart.com/viewtopic.php?f=24&t=5665
Re: Show weight in product description
Posted: Thu Aug 20, 2009 3:40 pm
by banane
I'm sorry wilmaogando but I've the same issue
I forgot to say that's working just in the index page but I can't show the weight unit in the product page..
Re: Show weight in product description
Posted: Thu Aug 20, 2009 7:13 pm
by Qphoria
EDIT: catalog/controller/product/product.php
FIND:
Code: Select all
$this->data['model'] = $product_info['model'];
BEFORE, ADD:
Code: Select all
$this->data['weight'] = $product_info['weight'];
EDIT: view/theme/default/template/product/product.tpl
FIND:
Code: Select all
<tr>
<td><b><?php echo $text_model; ?></b></td>
<td><?php echo $model; ?></td>
</tr>
AFTER, ADD:
Code: Select all
<tr>
<td><b>Weight:</b></td>
<td><?php echo $weight; ?></td>
</tr>
Re: Show weight in product description
Posted: Fri Aug 21, 2009 1:25 am
by wilmaogando
Thanks Qphoria!!! it' not working, I did that but it seems that made no difference.
Don't show anything. Is there any extra step?
Thanks in advance!!!
Wilma

Re: Show weight in product description
Posted: Sat Aug 22, 2009 9:37 pm
by banane
I found the trick!
edit catalog/controller/product/product.php
just before
Code: Select all
$this->data['model'] = $product_info['model'];
past this:
Code: Select all
$this->data['weight'] = $this->weight->format($product_info['weight'], $product_info['weight_class_id']);
edit view/theme/default/template/product/product.tpl
add this:
Code: Select all
<tr>
<td><b><?php echo $text_weight; ?></b></td>
<td><?php echo $weight; ?></td>
</tr>
and, if you want to change the number of decimal appearing, edit system/helper/weight.php
Re: Show weight in product description
Posted: Sun Aug 23, 2009 1:05 am
by wilmaogando
Hi banane, I just Tryed what you said, but I just modify:
poduct.php and product.tpl, is there any other file that need to be modify, because there is no change in my web.
Anyone can see it here:
http://www.waohzone.com
The weight is being shown, but still not presenting the unit (onz.).
Please if is working for you, can you explain if there are anyother steps that maybe a no newbi would now?
Wilma
(don't speak english)
Re: Show weight in product description
Posted: Sun Aug 23, 2009 9:13 am
by TBT
Qphoria wrote:EDIT: catalog/controller/product/product.php
FIND:
Code: Select all
$this->data['model'] = $product_info['model'];
BEFORE, ADD:
Code: Select all
$this->data['weight'] = $product_info['weight'];
EDIT: view/theme/default/template/product/product.tpl
FIND:
Code: Select all
<tr>
<td><b><?php echo $text_model; ?></b></td>
<td><?php echo $model; ?></td>
</tr>
AFTER, ADD:
Code: Select all
<tr>
<td><b>Weight:</b></td>
<td><?php echo $weight; ?></td>
</tr>
Thanks Qphoria
Works like a charm
