Post by mohit11 » Wed Nov 24, 2010 12:32 pm

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
Last edited by i2Paq on Thu Nov 25, 2010 4:28 am, edited 1 time in total.
Reason: Title adjusted

New member

Posts

Joined
Thu Nov 18, 2010 5:01 pm

Post by Candesco » Thu Nov 25, 2010 3:30 am

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!

New member

Posts

Joined
Thu Nov 11, 2010 12:01 am

Post by mohit11 » Thu Nov 25, 2010 1:32 pm

Hi Candesco

tried it and didnt work.

Regards
Mohit

New member

Posts

Joined
Thu Nov 18, 2010 5:01 pm

Post by Candesco » Thu Nov 25, 2010 3:58 pm

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 ?

New member

Posts

Joined
Thu Nov 11, 2010 12:01 am

Post by mohit11 » Fri Nov 26, 2010 3:04 am

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

New member

Posts

Joined
Thu Nov 18, 2010 5:01 pm

Post by Candesco » Fri Nov 26, 2010 11:43 pm

you get this error because you forgot to declare $text_weight :P
To do so, open /catalog/language/english/product/product.php

Find

Code: Select all

$_['text_model']          = 'Model :';
Add just after :

Code: Select all

$_['text_weight']          = 'Weight :';
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

New member

Posts

Joined
Thu Nov 11, 2010 12:01 am

Post by mohit11 » Sat Nov 27, 2010 1:37 am

Thanks a lot.
works perfectly

Is there any way to show the weight unit as well?

New member

Posts

Joined
Thu Nov 18, 2010 5:01 pm

Post by mohit11 » Sat Nov 27, 2010 1:50 am

The weight unit kgs is displaying on your web site.

New member

Posts

Joined
Thu Nov 18, 2010 5:01 pm

Post by Candesco » Sat Nov 27, 2010 7:51 pm

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>

New member

Posts

Joined
Thu Nov 11, 2010 12:01 am

Post by Johnathan » Sat Nov 27, 2010 10:50 pm

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.

Image Image Image Image Image


User avatar
Administrator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by mohit11 » Sun Nov 28, 2010 11:39 am

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. :)

New member

Posts

Joined
Thu Nov 18, 2010 5:01 pm

Post by Candesco » Thu Dec 02, 2010 10:05 pm

Just add

Code: Select all

&nbsp;
before kgs.

Your code will then look like :
<tr>
<td><b><?php echo $text_weight; ?></b></td>
<td><?php echo $product_info['weight'] . '&nbsp;kgs' ;?></td>
</tr>
One &nbsp; equals one space. You can add more if you want.

New member

Posts

Joined
Thu Nov 11, 2010 12:01 am

Post by sayx » Sun Feb 26, 2012 1:47 am

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

Newbie

Posts

Joined
Thu Aug 25, 2011 9:02 pm
Who is online

Users browsing this forum: No registered users and 140 guests