Page 1 of 1

How to add Weight and size dimensions to Product Page

Posted: Mon May 15, 2017 6:03 pm
by apollovs
Hi,
I am running a site on Opencart Version 2.3.0.2 and what i would like to do is display the measurements and weight of each product on the product page.

Is ths possible?

cheers

Re: How to add Weight and size dimensions to Product Page

Posted: Mon May 15, 2017 8:35 pm
by sachin6609
HIi

Go to admin panel catalog->product

Add New Product or edit the exiting one

Go To data Tab and check the bottom of that tab

You can add the size and weight of that product

Thanks
Sachin

Re: How to add Weight and size dimensions to Product Page

Posted: Mon May 15, 2017 8:40 pm
by apollovs
Not sure you understand what i mean, i have already added the weights and sizes on the product page in my admin area but i would like these weights and measurements to also show on the product page and my web site so customers can view them before they buy

Re: How to add Weight and size dimensions to Product Page

Posted: Mon May 15, 2017 9:57 pm
by sachin6609
Hii

Ok i got it

I will tell you the changes with file location and code 2marrow

Currently i just leave my laptop so i will sure tell you the solution dont warry . i know how to do this i have already done it in my localhost opencart

Thanks
Sachin

Re: How to add Weight and size dimensions to Product Page

Posted: Tue May 16, 2017 5:57 am
by Gr3nT
Weight and size are only displayed in one place for visitors.
Product comparison page and the weight may even be in the delivery way.
Or you can show it individually with development

Re: How to add Weight and size dimensions to Product Page

Posted: Tue May 16, 2017 1:53 pm
by sachin6609
Hii

it will be display on the product page just below the model,stock section

Thanks
Sachin

Re: How to add Weight and size dimensions to Product Page

Posted: Tue May 16, 2017 3:48 pm
by apollovs
sachin6609 wrote:
Tue May 16, 2017 1:53 pm
Hii

it will be display on the product page just below the model,stock section

Thanks
Sachin
Hi,
How do i do this as i see a screenshot but no instructions?

cheers

Re: How to add Weight and size dimensions to Product Page

Posted: Tue May 16, 2017 4:28 pm
by sachin6609
Hii

Open the product controller file and search the below line

file location -> catalog / controller / product then open the product.php file

$data['points'] = $product_info['points'];

Then after this line add the below line

$data['weight'] = $product_info['weight'];
$data['length'] = $product_info['length'];
$data['width'] = $product_info['width'];
$data['height'] = $product_info['height'];

Then open the product.tpl file and serach for the below line

File Location-> catalog / view / theme / default or (Your_Theme_Folder_If_You_Use_any_theme) / template / product then product.tpl file

<li><?php echo $text_stock; ?> <?php echo $stock; ?></li>

just after that line add the below code

<?php if($weight) { ?>
Weight : <?php echo number_format($weight,2); ?>
<?php } ?>
<br/>
<?php if($length || $width || $height) { ?>
L x W x H : <?php echo number_format($length,2)," x ", number_format($width,2) , " x " , number_format($height,2); ?>
<?php } ?>

All The Best

Thanks
Sachin

Re: How to add Weight and size dimensions to Product Page

Posted: Wed May 17, 2017 1:16 am
by apollovs
I have done what you have put below but doesnt seem to work for me the details are not showing on the products pages?
sachin6609 wrote:
Tue May 16, 2017 4:28 pm
Hii

Open the product controller file and search the below line

file location -> catalog / controller / product then open the product.php file

$data['points'] = $product_info['points'];

Then after this line add the below line

$data['weight'] = $product_info['weight'];
$data['length'] = $product_info['length'];
$data['width'] = $product_info['width'];
$data['height'] = $product_info['height'];

Then open the product.tpl file and serach for the below line

File Location-> catalog / view / theme / default or (Your_Theme_Folder_If_You_Use_any_theme) / template / product then product.tpl file

<li><?php echo $text_stock; ?> <?php echo $stock; ?></li>

just after that line add the below code

<?php if($weight) { ?>
Weight : <?php echo number_format($weight,2); ?>
<?php } ?>
<br/>
<?php if($length || $width || $height) { ?>
L x W x H : <?php echo number_format($length,2)," x ", number_format($width,2) , " x " , number_format($height,2); ?>
<?php } ?>

All The Best

Thanks
Sachin

Re: How to add Weight and size dimensions to Product Page

Posted: Wed May 17, 2017 1:47 am
by cyclops12
Have you gone into extensions/modifications and clicked the refresh button?

Re: How to add Weight and size dimensions to Product Page

Posted: Wed May 17, 2017 2:52 am
by apollovs
cyclops12 wrote:
Wed May 17, 2017 1:47 am
Have you gone into extensions/modifications and clicked the refresh button?
Thanks works now!, you can tell i am new to this!

Re: How to add Weight and size dimensions to Product Page

Posted: Wed May 17, 2017 3:06 am
by cyclops12
Hey no problems, happy to help :)

Re: How to add Weight and size dimensions to Product Page

Posted: Wed Aug 23, 2017 5:30 am
by Oyekunle
hello please i use opencart 3
can you guide how to go about this
thanks

Re: How to add Weight and size dimensions to Product Page

Posted: Fri Mar 23, 2018 10:51 pm
by samee
yet another newbie

Can someone PLEASE help to achieve the same in OC3.0.2.0, I tried solution provided by sachin but just can't get it to show without decimal and weight class (ie gm). PLEASE PLEASE help

Solved... 24Mar

(1) file location -> catalog / controller / product then open the product.php file
search/find line
$data['points'] = $product_info['points'];

Then after this line add the below line
$data['weight'] = $this->weight->format(($product_info['weight'] ) , $product_info['weight_class_id'], $this->language->get('decimal_point'), $this->language->get('thousand_point'))

(2) File Location-> catalog / view / theme / default or (Your_Theme_Folder_If_You_Use_any_theme) / template / product then product.twig file
search/find line <li>{{ text_stock }} {{ stock }}</li>

Then after this line add the below line
<li>{{'Weight:'}} {{weight}}</li>


Now I need find way to show weight on search result page. any guidance ?

Re: How to add Weight and size dimensions to Product Page

Posted: Tue Apr 03, 2018 12:22 am
by appsfinder
hi ive got this working but does not display grams this is what it show weight 299 there no g on the end please advise code change so looks like this weight 299g

Re: How to add Weight and size dimensions to Product Page

Posted: Thu May 10, 2018 1:14 am
by jagall
Hi I have same issue got this to display but missing the label i.e. grams or inches, etc.
thanks

Re: How to add Weight and size dimensions to Product Page

Posted: Wed May 06, 2020 6:10 pm
by Cherice
Hi
Please could someone let me know how to edit this code to show the dimensions? (Opencart 3x) I got this to work with the weight, but i need to change weight to L x H x W

Thank you

Re: How to add Weight and size dimensions to Product Page

Posted: Tue Feb 13, 2024 3:08 pm
by speedytm
OpenCart 3

Add in file: controller/catalog/product/product.php

after

Code: Select all

$data['points'] = $product_info['points'];
this:

Code: Select all

if ($product_info['weight']>0) {
				$data['weight'] = str_replace('.00','',$this->weight->format($product_info['weight'], $product_info['weight_class_id']));
			} else {
				$data['weight'] = '';
			}
			if ($product_info['length']>0) {
				$data['length'] = str_replace('.00','',$this->length->format($product_info['length'], $product_info['length_class_id']));
			} else {
				$data['length'] = '';
			}
			if ($product_info['width']>0) {
				$data['width'] = str_replace('.00','',$this->length->format($product_info['width'], $product_info['length_class_id']));
			} else {
				$data['width'] = '';
			}
			if ($product_info['height']>0) {
				$data['height'] = str_replace('.00','',$this->length->format($product_info['height'], $product_info['length_class_id']));
			} else {
				$data['height'] = '';
			}
Next, in theme file catalog/view/theme/YOURTHEMENAME/template/product/product.twig
after

Code: Select all

<li>{{ text_stock }} {{ stock }}</li>
:

Code: Select all

{% if length %}
	<li>{{'Размеры (ДхШхВ):'}} {{length}} x {{width}} x {{height}}</li>
{% endif %}
Have a nice day!