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

Neil
OpenCart Theme Options - See All My Extensions - OpenCart Themes and Mods
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.
Code: Select all
$this->data['text_model'] = $this->language->get('text_model');
Code: Select all
$this->data['text_dimensions'] = $this->language->get('text_dimensions');
$this->data['text_by'] = $this->language->get('text_by');
Code: Select all
$this->data['model'] = $product_info['model'];
Code: Select all
$this->data['length'] = $product_info['length'];
$this->data['width'] = $product_info['width'];
$this->data['height'] = $product_info['height'];
Code: Select all
$_['text_model'] = 'Product Code:';
Code: Select all
$_['text_dimensions'] = 'Size:';
$_['text_by'] = ' x ';
Code: Select all
<span><?php echo $text_model; ?></span> <?php echo $model; ?><br />
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 />
Code: Select all
$this->data['text_model'] = $this->language->get('text_model');
Code: Select all
$this->data['text_dimensions'] = $this->language->get('text_dimensions');
$this->data['text_by'] = $this->language->get('text_by');
Code: Select all
'description' => substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
Code: Select all
'length' => number_format($result['length'], 1) . "''",
'width' => number_format($result['width'], 1) . "''",
'height' => number_format($result['height'], 1) . "''",
Code: Select all
$_['text_model'] = 'Product Code:';
Code: Select all
$_['text_dimensions'] = 'Size:';
$_['text_by'] = ' x ';
Code: Select all
<div class="description"><?php echo $product['description']; ?></div>
Code: Select all
<div class="dimensions"><?php echo ($text_dimensions . $product['length'] . $text_by . $product['width'] . $text_by . $product['height']); ?></div>
Code: Select all
html += ' <div class="name">' + $(element).find('.name').html() + '</div>';
Code: Select all
html += ' <div class="dimensions">' + $(element).find('.dimensions').html() + '</div>';
Code: Select all
html += '<div class="name">' + $(element).find('.name').html() + '</div>';
Code: Select all
html += '<div class="dimensions">' + $(element).find('.dimensions').html() + '</div>';
no problem.jpg (69.62 KiB) Viewed 32779 times
problem.jpg (37.29 KiB) Viewed 32779 times
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); ?>
Luke,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:
More info on this function here: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); ?>
http://www.php.net/manual/en/function.round.php
Hope this helps.
Luke
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.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!
Website Design, hosting, seo and online marketing visit: http://www.yorkcreative.co.uk
Website Design, hosting, seo and online marketing visit: http://www.yorkcreative.co.uk
I have extension "Show Dimension and Weight" to show dimension on product page. That is support multilanguage and multipleunit.mattalt wrote:how do you put the size in the product.tpl?
hydrowire wrote: In the file: catalog/controller/product/category.php
Find this code line (~line 188):You are told to add the following code after it in the forum:Code: Select all
'description' => substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
Please modify those three lines to the following instead:Code: Select all
'length' => number_format($result['length'], 1) . "''", 'width' => number_format($result['width'], 1) . "''", 'height' => number_format($result['height'], 1) . "''",
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'], 'width' => number_format($result['width'], 1) . $result['length_class'], 'height' => number_format($result['height'], 1) . $result['length_class'],
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
Code: Select all
$this->data['model'] = $product_info['model'];
Code: Select all
$this->data['length'] = $product_info['length'];
$this->data['width'] = $product_info['width'];
$this->data['height'] = $product_info['height'];
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'];
Code: Select all
$this->data['length'] = $product_info['length'] . " " . $product_info['length_class'];
...
Developing Quality OpenCart Extensions since 2011.
View my extensions
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'],
Code: Select all
<div class="dimensions"><?php echo ($text_dimensions . $product['length'] . $text_by . $product['width'] . $text_by . $product['height']); ?></div>
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]
Users browsing this forum: No registered users and 6 guests