Post by BTdavid » Fri Apr 07, 2017 11:40 pm

Hi,

I'm trying to display the weight of a product on the product page and it's got me going around in circles. Following advice from other threads I added the following to /catalog/controller/product/product.php

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

And added the following to /catalog/view/theme/default/template/product/product.tpl

<?php echo $length; ?>
<?php echo $width; ?>
<?php echo $height; ?>
<?php echo $weight; ?>

It displays length, width, height, but not weight!

I've checked and re-checked everything and I'm stumped.

Could anyone help me with why it is not displaying weight? I have weight in the product details and I can see it in the database. I followed some advice on showing weight on category pages and that works, just not on the product page. Any help greatly appreciated!

Thanks!

New member

Posts

Joined
Wed Feb 08, 2017 9:29 pm

Post by IP_CAM » Sat Apr 08, 2017 12:08 am

it would also take some additional Content in the MODEL File, but it's MUCHO easier, to use one of the nice free
Extensions, shown as first and second Mod on the Extension Page, the:
Product Display Settings vqmod or the very comprehensive Advanced Product Display Settings, I also use,
and as shown on the Product Page image:
https://www.opencart.com/index.php?rout ... load_id=33
Good Luck
Ernie
---
Image
Image

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by BTdavid » Mon Apr 10, 2017 4:55 pm

Hi Ernie,

Thanks for your reply.

I installed the Advanced Product Display Settings module and I got this error:
Parse error: syntax error, unexpected ',' in /home/mysite/public_html/vqmod/vqcache/vq2-catalog_model_catalog_product.php on line 56

I didn't install the other one as it doesn't say it's compatible with my version of Open Cart.

I don't really need to display the weight of each product. I would only like to access the weight of the product to use in a calculator I embed on the page where my customer can calculate the weight of an order based on the amount of product they need. So if they need 50 of the product the calculator tells them the total weight. As I said it works for the other dimensions just not weight.

Could you say what I need to do to the Model file?

Thanks.

New member

Posts

Joined
Wed Feb 08, 2017 9:29 pm

Post by IP_CAM » Mon Apr 10, 2017 10:16 pm

what OC Version do you use ?
Ernie

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by BTdavid » Mon Apr 10, 2017 11:12 pm

It's OpenCart 1.5.6.4

By the way I found some forum topics on this and applied the steps above and steps to show on the category page. I can see the weight variable on the category page using the advice/code from those posts but not on the product page where I need it. It suggests to me that the weight attribute is there someplace I just can't access it or display it.

Thanks!

New member

Posts

Joined
Wed Feb 08, 2017 9:29 pm

Post by opencartboost » Fri Apr 14, 2017 7:05 am

I have one
https://www.opencart.com/index.php?rout ... on_id=2937
I will help you to installation.

Active Member

Posts

Joined
Thu Jul 09, 2015 5:59 am

Post by IP_CAM » Fri Apr 14, 2017 8:01 am

Parse error: syntax error, unexpected ',' in /home/mysite/public_html/vqmod/vqcache/vq2-catalog_model_catalog_product.php on line 56
---
Sorry for delay. If you use an unmodified Default Theme, and no other Extension, inserting some Code into the catalog/model/catalog/product.php
it has to work. Check if your model/catalog/product.php file looks the same as shown on the image, to make sure, the VqMod Content will be added in the right spot, and no second Comma, where no Comma should be.
But I would NOT have mentioned the other Extension, if it would not work, at least in my OC v.1.5.6.5_rc :D
Good Luck
Ernie

Image

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by BTdavid » Tue Apr 18, 2017 4:55 pm

Hi Ernie,
I appreciate your help, thank you. I am averse to installing the extension again as it is a live site and I cannot afford any more downtime trying to fix it. I don't want to take the risk.
I'm not sure that the extension would address my problem. It might show the weight in the product description, but I need access to the value on each product page for a calculation.
I can't understand why it isn't working on the product page but it does on the category page. The model file looks correct and it calls for the weight attribute from the database. I'm at a loss. Any insight would be great thanks again.
BTDavid

New member

Posts

Joined
Wed Feb 08, 2017 9:29 pm

Post by BTdavid » Wed Apr 26, 2017 9:33 pm

Hi Ernie,
I took another look at this and found something unusual.

In catalog/view/theme/xx/template/product/product.tpl I have
<?php echo $height; ?>
On the product page it will display 1.6cm which is correct.

As a test I tried changing catalogue/controller/product/product.php
I changed:
$this->data['height'] = $product_info['height'];
to:
$this->data['height'] = $product_info['length'];

but I saved everything and the product page still shows 1.6cm not the length with is 20cm

This suggests to me that the .tpl is getting the value for the dimensions from some other .php file but I cannot find it anyplace.

Can you offer any suggestions?

Thanks
David

New member

Posts

Joined
Wed Feb 08, 2017 9:29 pm

Post by cyclops12 » Wed Apr 26, 2017 10:52 pm

Are you clearing your browser cache after each change also you might have to click refresh in extensions/modifications to see changes made

Expert Member

Posts

Joined
Sun Sep 27, 2015 1:10 am

Post by BTdavid » Wed Apr 26, 2017 11:14 pm

It's OpenCart 1.5 so I don't have modifications refresh as in version 2
I clear cache and I clear vqmod cache and its' the same.

New member

Posts

Joined
Wed Feb 08, 2017 9:29 pm

Post by cyclops12 » Thu Apr 27, 2017 1:39 am

Oh yeah didnt read that properly sorry..
BTW i just tried your code on a default 1.5.6.1 and it works fine
I added to the catalog/controller/product/product.php

Code: Select all

$this->data['length'] = $product_info['length'];
$this->data['width'] = $product_info['width'];
$this->data['height'] = $product_info['height'];
$this->data['weight'] = $product_info['weight'];
Directly underneath

Code: Select all

$this->data['product_id'] = $this->request->get['product_id'];
			$this->data['manufacturer'] = $product_info['manufacturer'];
			$this->data['manufacturers'] = $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $product_info['manufacturer_id']);
			$this->data['model'] = $product_info['model'];
			$this->data['reward'] = $product_info['reward'];
			$this->data['points'] = $product_info['points'];
Then in the product.tpl file i added

Code: Select all

<?php echo $length; ?><br />
<?php echo $width; ?><br />
<?php echo $height; ?><br />
<?php echo $weight; ?>
Directly underneath

Code: Select all

<div class="description">
        <?php if ($manufacturer) { ?>
        <span><?php echo $text_manufacturer; ?></span> <a href="<?php echo $manufacturers; ?>"><?php echo $manufacturer; ?></a><br />
        <?php } ?>
        <span><?php echo $text_model; ?></span> <?php echo $model; ?><br />
        <?php if ($reward) { ?>
        <span><?php echo $text_reward; ?></span> <?php echo $reward; ?><br />
        <?php } ?>
        <span><?php echo $text_stock; ?></span> <?php echo $stock; ?></div>
Just to make sure it works and it does, all i done was refreshed the browser once code was added

Attachments

extras.JPG

extras.JPG (16.5 KiB) Viewed 7328 times


Expert Member

Posts

Joined
Sun Sep 27, 2015 1:10 am

Post by BTdavid » Thu Apr 27, 2017 4:10 pm

No problem at all, I really just appreciate any help.
I am trying to debug it a bit by changing the product.php like I did, but it doesn't change the variable like it would by default.
This says to me that the variables are assigned from the database in another file, other than default.
It's a big enough website that I am trying to add functionality to, so I would really like to be able tofigure it out.

New member

Posts

Joined
Wed Feb 08, 2017 9:29 pm

Post by cyclops12 » Fri Apr 28, 2017 1:08 am

Do you have any mods/extensions installed that modify the product php/tpl files ??

Expert Member

Posts

Joined
Sun Sep 27, 2015 1:10 am

Post by BTdavid » Fri Apr 28, 2017 4:14 pm

Hi,
I thought about that last night so I checked, and there it was! There was a vqmod installed that was why changing the product.php file didn't change the dimensions.
I changed it to include adding the weight and it worked. The file was:
xml/displaydimensions-for-1551.xml
Thanks :D

New member

Posts

Joined
Wed Feb 08, 2017 9:29 pm

Post by cyclops12 » Sat Apr 29, 2017 12:33 am

Got there at last lol.
Glad its all working now for you

Expert Member

Posts

Joined
Sun Sep 27, 2015 1:10 am
Who is online

Users browsing this forum: No registered users and 27 guests