Post by ThePath » Mon Jul 05, 2010 11:53 pm

Hi all,

Im wondering how to display the product dimension fields (the ones set in catalog->products->data->Dimensions (L x W x H): ) on category.tpl

Does anybody have any idea on how to do this or perhaps implemented it before?

Cheers O0

Neil

Image

OpenCart Theme Options - See All My Extensions - OpenCart Themes and Mods


User avatar
Active Member

Posts

Joined
Fri Jun 26, 2009 11:53 pm
Location - Scotland

Post by dantheman50_98 » Fri Oct 15, 2010 10:11 pm

Did you have any luck with this, or does anybody have a solution? I'm setting up a site selling art so a dimensions field is pretty essential.

Cheers,
Dan

Active Member

Posts

Joined
Sat Sep 18, 2010 2:18 am

Post by dantheman50_98 » Fri Oct 22, 2010 2:02 am

Is there definitely no solution to this?

Active Member

Posts

Joined
Sat Sep 18, 2010 2:18 am

Post by LeorLindel » Sun Nov 07, 2010 12:30 pm

Look here

Tous les packs de langues Française depuis la v1.4.7 et toutes les versions intégrales 100 % Français sont disponibles sur le Portail Officiel Français.

Image


User avatar
Active Member

Posts

Joined
Mon Feb 22, 2010 8:05 pm

Post by joakescan » Fri Jul 29, 2011 3:48 pm

Solution to: Display product dimensions as single line (Size: L x W x H) in both product view and category view...

In the file: catalog/controller/product/product.php

Find this code line (~line 140):

Code: Select all

$this->data['text_model'] = $this->language->get('text_model');
Add the following code after it:

Code: Select all

$this->data['text_dimensions'] = $this->language->get('text_dimensions');
         $this->data['text_by'] = $this->language->get('text_by');
Find this code line (~line 183):

Code: Select all

$this->data['model'] = $product_info['model'];
Add the following code after it:

Code: Select all

$this->data['length'] = $product_info['length'];
         $this->data['width'] = $product_info['width'];
         $this->data['height'] = $product_info['height'];
In the file: catalog/language/english/product/product.php

Find this code line (~line 6):

Code: Select all

$_['text_model']        = 'Product Code:';
Add the following code after it:

Code: Select all

$_['text_dimensions']   = 'Size:';	
$_['text_by']  = ' x ';
In the file: catalog/view/theme/default/template/product/product.tpl

Find this code line (~line 29):

Code: Select all

<span><?php echo $text_model; ?></span> <?php echo $model; ?><br />
Add the following code after it:

Code: Select all

<span><?php echo $text_dimensions; ?></span>
	<?php echo $length; ?><?php echo $text_by; ?><?php echo $width; ?>
	<?php echo $text_by; ?><?php echo $height; ?><br />
In the file: catalog/controller/product/category.php

Find this code line (~line 85):

Code: Select all

$this->data['text_model'] = $this->language->get('text_model');
Add the following code after it:

Code: Select all

$this->data['text_dimensions'] = $this->language->get('text_dimensions');
	$this->data['text_by'] = $this->language->get('text_by');
Find this code line (~line 188):

Code: Select all

'description' => substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
Add the following code after it:

Code: Select all

'length'	  => number_format($result['length'], 1) . "''",
	'width'	  => number_format($result['width'], 1) . "''",
	'height'	  => number_format($result['height'], 1) . "''",
In the file: catalog/language/english/product/category.php

Find this code line (~line 9):

Code: Select all

$_['text_model']        = 'Product Code:';
Add the following code after it:

Code: Select all

$_['text_dimensions']   = 'Size:';	
$_['text_by']  = ' x ';
In the file: catalog/view/theme/default/template/product/category.tpl

Find this code line (~line 83):

Code: Select all

<div class="description"><?php echo $product['description']; ?></div>
Add the following code after it:

Code: Select all

<div class="dimensions"><?php echo ($text_dimensions . $product['length'] . $text_by . $product['width'] . $text_by . $product['height']); ?></div>
Find this code line (~line 145):

Code: Select all

html += '  <div class="name">' + $(element).find('.name').html() + '</div>';
Add the following code after it:

Code: Select all

html += '  <div class="dimensions">' + $(element).find('.dimensions').html() + '</div>';
Find this code line (~line 177):

Code: Select all

html += '<div class="name">' + $(element).find('.name').html() + '</div>';
Add the following code after it:

Code: Select all

html += '<div class="dimensions">' + $(element).find('.dimensions').html() + '</div>';
This worked for me... hope it works for everyone else.... O0

Newbie

Posts

Joined
Fri Jul 29, 2011 3:09 pm

Post by serban84 » Sun Oct 02, 2011 12:16 am

works like a charm. Thanks! :)

Newbie

Posts

Joined
Sun Oct 02, 2011 12:15 am

Post by BULBCART » Sun Nov 06, 2011 3:11 am

Sweet! Worked perfectly! Thank you very much for this info...

http://bulbcart.com


User avatar
Newbie

Posts

Joined
Thu Nov 03, 2011 8:31 am


Post by oblio » Fri Feb 03, 2012 12:06 am

i have done everything u said and it works perfectly for products view.
my only problem is that in category view of a product i get my dimesions converted and displayed in INCHES with the sign .".(symbol for inch) after the numbers and only one one decimal instead of two. but when i click on the specific product to view it's details, my dimensions are swiched to Centimeter class ad get a two decimals and no .". sign.
i want all of them to be in cm..:(
i've deleted the inch class from my admin area and still getting the same results..
i've attached some photos in case i didn.'t made my self very clear..Thanks!

Attachments

no problem.jpg

no problem.jpg (69.62 KiB) Viewed 29828 times

problem.jpg

problem.jpg (37.29 KiB) Viewed 29828 times


Newbie

Posts

Joined
Thu Feb 02, 2012 11:53 pm

Post by acedra » Tue May 15, 2012 10:05 pm

Hi there!

I have a similar problem to what OBLIO is experiencing. The dimensions are displayed on the product view as 4.25000000 instead of 4.25". Not sure if this is the same problem or not, but I was wondering if someone could point me in the right direction to fix this. I've changed the excel sheet numerous times when uploading in case it was a formatting issue with the cells that caused this to no avail.

Any help would be appreciated greatly. Thanks in advance!

- Dan

New member

Posts

Joined
Fri Jan 13, 2012 2:06 am

Post by LukeClifton » Thu May 17, 2012 7:43 pm

Dan,

You can use the PHP Round function to format the dimension variables that are being outputted.

Add the following code to your product view file:

Code: Select all

	  <?php echo round($length, 2); ?>
  	  <?php echo $text_by; ?>
  	  <?php echo round($width, 2); ?>
  	  <?php echo $text_by; ?>
  	  <?php echo round($height, 2); ?>
More info on this function here:
http://www.php.net/manual/en/function.round.php


Hope this helps.

Luke

Newbie

Posts

Joined
Thu May 17, 2012 7:38 pm

Post by acedra » Fri May 18, 2012 4:07 am

LukeClifton wrote:Dan,

You can use the PHP Round function to format the dimension variables that are being outputted.

Add the following code to your product view file:

Code: Select all

	  <?php echo round($length, 2); ?>
  	  <?php echo $text_by; ?>
  	  <?php echo round($width, 2); ?>
  	  <?php echo $text_by; ?>
  	  <?php echo round($height, 2); ?>
More info on this function here:
http://www.php.net/manual/en/function.round.php


Hope this helps.

Luke
Luke,

Thank you so much! This fixed the issue and it works like a dream.

- Dan

New member

Posts

Joined
Fri Jan 13, 2012 2:06 am

Post by jonah » Tue May 29, 2012 7:39 am

oblio wrote:i have done everything u said and it works perfectly for products view.
my only problem is that in category view of a product i get my dimesions converted and displayed in INCHES with the sign .".(symbol for inch) after the numbers and only one one decimal instead of two. but when i click on the specific product to view it's details, my dimensions are swiched to Centimeter class ad get a two decimals and no .". sign.
i want all of them to be in cm..:(
i've deleted the inch class from my admin area and still getting the same results..
i've attached some photos in case i didn.'t made my self very clear..Thanks!
Hi I also have this problem. Everything works great, except on the Category view I'm getting the " inches symbol. Can anyone help me change this to mm in the code? I can't find where this is to change it.

Thanks. :)

Website Design, hosting, seo and online marketing visit: http://www.yorkcreative.co.uk


New member

Posts

Joined
Sun Feb 19, 2012 12:54 am

Post by mattalt » Thu May 31, 2012 7:21 am

Does anyone have a qmode for this?

New member

Posts

Joined
Thu May 31, 2012 7:12 am

Post by jonah » Sat Jun 09, 2012 9:54 am

Here is an example of the product list showing in inches but when you click on a product it's in mm:

http://www.photoengraver.co.uk/index.ph ... ry&path=59

If anyone can please let me know where to find the " symbol in the template files that would be great so I can amend it to just say mm instead. Thanks :)

Website Design, hosting, seo and online marketing visit: http://www.yorkcreative.co.uk


New member

Posts

Joined
Sun Feb 19, 2012 12:54 am

Post by mattalt » Sat Jun 09, 2012 12:11 pm

how do you put the size in the product.tpl?

New member

Posts

Joined
Thu May 31, 2012 7:12 am

Post by nosecret » Sun Jun 10, 2012 10:43 am

mattalt wrote:how do you put the size in the product.tpl?
I have extension "Show Dimension and Weight" to show dimension on product page. That is support multilanguage and multipleunit.

http://www.opencart.com/index.php?route ... on_id=2937

Active Member

Posts

Joined
Tue Dec 28, 2010 12:28 pm

Post by jonah » Sun Jun 10, 2012 9:21 pm

Hi thanks to the very talented Open Cart developer hydrowire for finding a fix!! He's one of the most talented Opencart guys around and has great addon modules too! Thanks again!

It works perfectly and displays the correct measurements on the category page listings.
hydrowire wrote: In the file: catalog/controller/product/category.php

Find this code line (~line 188):

Code: Select all

'description' => substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
You are told to add the following code after it in the forum:

Code: Select all

'length'     => number_format($result['length'], 1) . "''",
'width'     => number_format($result['width'], 1) . "''",
'height'     => number_format($result['height'], 1) . "''",
Please modify those three lines to the following instead:

Code: Select all

'length'     => number_format($result['length'], 1) . $result['length_class'],
'width'     => number_format($result['width'], 1) . $result['length_class'],
'height'     => number_format($result['height'], 1) . $result['length_class'],
That's all. You can always add some space in between the value and unit like this:

Code: Select all

'length'     => number_format($result['length'], 1) . " " . $result['length_class'],
...

Website Design, hosting, seo and online marketing visit: http://www.yorkcreative.co.uk


New member

Posts

Joined
Sun Feb 19, 2012 12:54 am

Post by hydrowire » Sun Jun 10, 2012 10:45 pm

The previous solution posted by jonah is for the category page. To add the default length unit to the product page as well, you can perform the following code changes:

In the file: catalog/controller/product/product.php

Find this code line (~line 183):

Code: Select all

$this->data['model'] = $product_info['model'];
joakescan suggested to add the following code after it:

Code: Select all

         $this->data['length'] = $product_info['length'];
         $this->data['width'] = $product_info['width'];
         $this->data['height'] = $product_info['height'];
To show the default length unit, modify those three lines of code to the following instead:

Code: Select all

         $this->data['length'] = $product_info['length'] . $product_info['length_class'];
         $this->data['width'] = $product_info['width'] . $product_info['length_class'];
         $this->data['height'] = $product_info['height'] . $product_info['length_class'];
That's all. To add space in between length value and unit:

Code: Select all

         $this->data['length'] = $product_info['length'] . " " . $product_info['length_class'];
...

Developing Quality OpenCart Extensions since 2011.
View my extensions


User avatar
Active Member

Posts

Joined
Wed Jan 26, 2011 5:41 pm


Post by lbaxterl » Thu Jun 21, 2012 8:20 pm

Does anyone know how to add the dimensions to "special.tpl". I added the follwing to the controller in cataolg/controller/product/special.php

Code: Select all

'length'     => number_format($result['length'], 0) . $result['length_class'],
'width'     => number_format($result['width'], 0) . $result['length_class'],
'height'     => number_format($result['height'], 0) . $result['length_class'],
And then in the special.tpl file i added:

Code: Select all

<div class="dimensions"><?php echo ($text_dimensions . $product['length'] . $text_by . $product['width'] . $text_by . $product['height']); ?></div>
Im getting an undefined index on all the dimensions. I have got it working correctly on the cateogry and product pages using this method just a bit stuck now. Any ideas?

thanks

Newbie

Posts

Joined
Fri Jun 17, 2011 9:56 pm

Post by emptyT » Sun Oct 07, 2012 10:11 pm

Re: Display Product Dimensions Field on category.tpl
[background=]by LukeClifton » Thu May 17, 2012 11:43 am

Dan,

You can use the PHP Round function to format the dimension variables that are being outputted.

Add the following code to your product view file:

CODE: SELECT ALL
<?php echo round($length, 2); ?>
<?php echo $text_by; ?>
<?php echo round($width, 2); ?>
<?php echo $text_by; ?>
<?php echo round($height, 2); ?>


More info on this function here:
http://www.php.net/manual/en/function.round.php[/background]

Where exactly does this code go?
Can someone tell me which file and where in the file please.
Everything else works great but I have 8 zeros after the decimal point :(

Newbie

Posts

Joined
Sun Oct 07, 2012 9:59 pm
Who is online

Users browsing this forum: No registered users and 9 guests