Post by ihateusernames » Wed Jul 24, 2019 4:00 pm

I've created some products in opencart, but the default theme doesn't show the dimensions or weight of the product that I've entered? Is there a simple way to add this information to the product page or description? Or do I need a different theme? Or something else?

Thanks for any information provided.

Active Member

Posts

Joined
Wed Jul 24, 2019 10:31 am

Post by paulfeakins » Wed Jul 24, 2019 5:57 pm

This has been asked and answered before:
viewtopic.php?t=184213

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by ihateusernames » Wed Jul 24, 2019 7:11 pm

Thanks, I've edited the php & twig files, but I now get an error. When I open the php file it states there's a syntax error (unexpected T_VARIABLE).
Code Line reads:

$data['description'] = html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8');

Any suggestions? Thanks for your assistance so far.

Active Member

Posts

Joined
Wed Jul 24, 2019 10:31 am

Post by Johnathan » Wed Jul 24, 2019 10:22 pm

If you don't want to make custom edits, the easiest way to do this is to just use product attributes to enter that data. You'll have to enter it twice for every product, but that will show up automatically on the product page, and wouldn't require any editing. The only downside is you can't choose where to display it, since it will show up in the area where attributes are listed.

Image Image Image Image Image


User avatar
Administrator

Posts

Joined
Fri Dec 18, 2009 3:08 am


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by ihateusernames » Sun Jul 28, 2019 8:46 pm

Thanks Jonathan & xxvirusxx,

I'll look into both options. I'm happy to edit stuff, but just need help with the errors. Still getting the parse error explained before....
Thanks.

Using OC Version 3.0.3.2


Active Member

Posts

Joined
Wed Jul 24, 2019 10:31 am

Post by xxvirusxx » Sun Jul 28, 2019 9:21 pm

We don't know what you changed, where you changed and code you used...to tell you how to fix the error/errors.

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by ihateusernames » Mon Jul 29, 2019 4:58 pm

Thanks, as I previously mentioned, I followed the instructions in the linked email. The copied parts all seem ok, but the following line is the one generating the parse error. That line of code reads:
$data['description'] = html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8');
Can you see anything wrong with it? Thanks.

I also tried downloading the extension you mentioned, but after unzipping & trying to upload it in Extensions, OpenCart stated that the .xml file was an invalid file type. That was the only file in the folder? So not sure what to do there? But thanks for the suggestion.

Active Member

Posts

Joined
Wed Jul 24, 2019 10:31 am

Post by ihateusernames » Mon Jul 29, 2019 5:07 pm

OK, extension now uploaded & installed properly 'I think!'. I was trying to upload the file rather than the folder.

But still getting the parse syntax error on the line of code in my previous post.

Thanks.

Using OC Version 3.0.3.2


Active Member

Posts

Joined
Wed Jul 24, 2019 10:31 am

Post by xxvirusxx » Mon Jul 29, 2019 5:10 pm

ihateusernames wrote:
Mon Jul 29, 2019 4:58 pm
Thanks, as I previously mentioned, I followed the instructions in the linked email.
What instructions?

Now need to unzip, just install as it is (blabla.ocmod.zip) and that tell you clear on extension page....

1. Go to Extensions-->Installer
2. Click on Upload and chose the file product_dimensions_and_weight.ocmod.zip
3. Refresh Ocmod

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by ihateusernames » Mon Jul 29, 2019 5:31 pm

Here is the instructions as guided by the first guy who responded to this post.

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 } ?>

Thanks.

Active Member

Posts

Joined
Wed Jul 24, 2019 10:31 am

Post by xxvirusxx » Mon Jul 29, 2019 5:35 pm

ihateusernames wrote:
Mon Jul 29, 2019 5:31 pm
<?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 } ?>
And you have converted this code for 3.x?

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by ihateusernames » Mon Jul 29, 2019 5:58 pm

Sorry, I copied the wrong post! This is the correct data I inserted. (apologies....)

(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>

Thanks.

Active Member

Posts

Joined
Wed Jul 24, 2019 10:31 am

Post by xxvirusxx » Mon Jul 29, 2019 6:03 pm

ihateusernames wrote:
Mon Jul 29, 2019 5:58 pm
$data['weight'] = $this->weight->format(($product_info['weight'] ) , $product_info['weight_class_id'], $this->language->get('decimal_point'), $this->language->get('thousand_point'))
Try with this

$data['weight'] = $this->weight->format(($product_info['weight'] ) , $product_info['weight_class_id'], $this->language->get('decimal_point'), $this->language->get('thousand_point'));

And use

Code: Select all

<li>{{'Weight:'}} {{ weight }}</li>

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by ihateusernames » Mon Jul 29, 2019 6:19 pm

Thanks , parse error now gone & product pages all loading fine.

However, still no weight or dimensions showing on the product page? If I use the attributes it looks like they show up in the specifications tab rather than on the product itself (as per Jonathan's suggestion). I'd rather they showed up on the product tab or info. Is this possible?

Thanks.

Using OC Version 3.0.3.2


Active Member

Posts

Joined
Wed Jul 24, 2019 10:31 am

Post by xxvirusxx » Mon Jul 29, 2019 6:31 pm

You have refreshed ocmod? Cleared SASS cache, theme cache?

Code work just fine

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by ihateusernames » Mon Jul 29, 2019 6:54 pm

Thanks, the refresh ocmod extension did the trick. I guess that is standard procedure in OpenCart after an install.

Apologies as I'm still finding my way around all the intricacies of this app. The layout & use is not what I was expecting, but hopefully I'll get there in the end :)

I've just noticed the weight is now shown twice, above & below the Dimensions.....!

Using OC Version 3.0.3.2


Active Member

Posts

Joined
Wed Jul 24, 2019 10:31 am

Post by xxvirusxx » Mon Jul 29, 2019 6:55 pm

ihateusernames wrote:
Mon Jul 29, 2019 6:54 pm
I've just noticed the weight is now shown twice, above & below the Dimensions.....!
Then disable my extension....or remove that code and use my extension.

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by ihateusernames » Mon Jul 29, 2019 8:46 pm

OK, if I disable your ext & remove the lines of code I inserted previously, everything reverts back to 'as before'.

If I insert the lines of code, the weight & dimensions still don't show up at all?

If I remove the lines of code & enable your ext, then the weight is shown twice & the dimensions once?

Any suggestions? Thanks.

Using OC Version 3.0.3.2


Active Member

Posts

Joined
Wed Jul 24, 2019 10:31 am

Post by ihateusernames » Mon Jul 29, 2019 8:54 pm

OK, clearing SASS & theme caches did the trick for the ext.

Thanks.....

Using OC Version 3.0.3.2


Active Member

Posts

Joined
Wed Jul 24, 2019 10:31 am
Who is online

Users browsing this forum: Adminas99999, Google [Bot] and 103 guests