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
Cheers,
Dan
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.
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');
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'];
Find this code line (~line 6):
Code: Select all
$_['text_model'] = 'Product Code:';
Code: Select all
$_['text_dimensions'] = 'Size:';
$_['text_by'] = ' x ';
Find this code line (~line 29):
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 />
Find this code line (~line 85):
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) . "''",
Find this code line (~line 9):
Code: Select all
$_['text_model'] = 'Product Code:';
Code: Select all
$_['text_dimensions'] = 'Size:';
$_['text_by'] = ' x ';
Find this code line (~line 83):
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>';
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 (69.62 KiB) Viewed 31889 times
problem.jpg (37.29 KiB) Viewed 31889 times
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
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); ?>
http://www.php.net/manual/en/function.round.php
Hope this helps.
Luke
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
Thank you so much! This fixed the issue and it works like a dream.
- Dan
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!
Thanks.
Website Design, hosting, seo and online marketing visit: http://www.yorkcreative.co.uk
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
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?
http://www.opencart.com/index.php?route ... on_id=2937
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):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
In the file: catalog/controller/product/product.php
Find this code line (~line 183):
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>
thanks
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
Users browsing this forum: No registered users and 42 guests