Post by artexstudio » Sun Oct 21, 2012 4:41 pm

emptyT wrote:
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 :(
For changing the 0.00000000 to 0 for example, you can go to your database phpMyADMIN ; go to table 'product' ->structure > find 'lenght' , 'width' and 'height' and change the decimal values from 15,8 to 15,0 ' .
If you preffer to have the numbers like 0,00 , you have to change the decimal to 15.2

Newbie

Posts

Joined
Sat Apr 09, 2011 1:11 am

Post by piezoo » Sat Nov 10, 2012 5:53 pm

Hello, Newbie here,

I added the code and modified code according to previous directions. I gat a lot of errors saying i did not specify length_class in category/controller/product/category.php and product.php. So i modiefied catalog/controller/product category.php & product.php by changing lenght_class to lenght_class_id.

Now my product size info is displayed as
Size:40.0 1 x 0.0 1 x 60.0 1 where the 1 is the actual id.

Example:
Image

So, no more errors.. but how to change the 1 to say cm ?

Please help this semi-novice out

Example of code in category/controller/product/category.php and product.php

Code: Select all

$this->data['products'][] = array(
'product_id'  => $result['product_id'],
'thumb'       => $image,
'name'        => $result['name'],
'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
'length'      => number_format($result['length'], 1) . " " . $result['length_class_id'],
'width'       => number_format($result['width'], 1) . " " . $result['length_class_id'],
'height'      => number_format($result['height'], 1) . " " . $result['length_class_id'],
'price'       => $price,
'special'     => $special,
'tax'         => $tax,
'rating'      => $result['rating'],
'reviews'     => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
'href'        => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'])
Wahat do i have to change to get the size displayed in cm ?

Newbie

Posts

Joined
Sat Nov 10, 2012 5:45 pm

Post by piezoo » Wed Nov 21, 2012 6:06 pm

Anyone ? Please ?

I just don't know how to fix this. I have been looking over various examples, the database itself, the code... I don't understand what i've done wrong.

Thnx

Newbie

Posts

Joined
Sat Nov 10, 2012 5:45 pm

Post by ThePath » Sat Feb 16, 2013 12:13 am

I know this is an old thread but Ive just released a FREE vqmod which will display the dimensions on the product page, enjoy:

http://www.opencart.com/index.php?route ... n_id=10557

Hope that helps some folk.

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 steveand007 » Mon Mar 11, 2013 9:53 pm

Awesome Thx a lot. work like a charm

User avatar
Newbie

Posts

Joined
Fri Apr 13, 2012 8:43 pm

Post by joerichards » Thu Aug 22, 2013 11:00 pm

To get the proper length/width/height displaying with the correct "cm" or whatever...

use these lines in your code:

Code: Select all

		$this->data['length'] = $this->length->format($product_info['length'], $product_info['length_class_id']);
		$this->data['width'] = $this->length->format($product_info['width'], $product_info['length_class_id']);
		$this->data['height'] = $this->length->format($product_info['height'], $product_info['length_class_id']);
instead of:

Code: Select all

		$this->data['length'] = $product_info['length'];
		$this->data['width'] = $product_info['width'];
		$this->data['height'] = $product_info['height'];
(or whatever else has been suggested since)

There is already a library class for formatting lengths, so the above code uses that!

Newbie

Posts

Joined
Sat Jun 29, 2013 10:39 am

Post by IP_CAM » Thu Mar 20, 2014 9:29 am

I admit, it took several hours to find out about it, but finally, with the Help of several Postings here as well as 10 Dollars to finally find and buy the "Show Dimension and Weight 1.5 (VQMOD)" on Opencart, I was able to accomplish what I was looking for. So, I forgot again what I found here:

http://forum.opencart.com/viewtopic.php?t=17255
and
http://forum.opencart.com/viewtopic.php?t=16843

with the exeption of the the Posting of 'LukeClifton' on the bottom of the Page, because I needed

Code: Select all

<?php if ($weight)  { ?>
				<span><?php echo $text_weight; ?></span> <?php echo round($weight, 3); ?> kg.<br />
in order to make my 10-Dollar Add-On work on weight too.

I am not sure it one of my unsuccessful Mods had any influence, that the "Show Dimension and Weight 1.5 (VQMOD)" does NOT show the weight without the endless line of zero's, but anyway, the php echo round routine made it work as planned.

Now it looks this way:

Image

So much to this, I now get on to the next Mod...
Greeting to all who share their knowledge! :clown:

Ernie
ipc.li/cart

Update 04-02-2014: implemented the VQMOD into the different Files to clean out my VQMOD as much as possible.

My Github OC Site: https://github.com/IP-CAM
5'600 + 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 mmtgv » Sun Aug 31, 2014 6:24 pm

jonah wrote: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'],
...
If you use:

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'];
you'll get an error message like:

Code: Select all

Notice: Undefined index: lenght_class in /home/xxx/public_html/admin/controller/catalog/product.php on line 280
Notice: Undefined index: lenght_class in /home/xxx/public_html/admin/controller/catalog/product.php on line 281
Notice: Undefined index: lenght_class in /home/xxx/public_html/admin/controller/catalog/product.php on line 282
You should use this instead:

Code: Select all

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

Newbie

Posts

Joined
Fri Sep 14, 2012 7:47 pm

Post by accend » Sun Aug 02, 2015 8:00 pm

Hi all,

Hopefully the support is still going on this thread.

I followed all the directions by joakescan, but unfortunately nothing has worked for me.

So I thought it was because I was using a theme and needed to change the relevant files within the lexus_superstore folder rather than the default folder, and then I couldn't find the lines of code.

But I have truly followed the steps to the t and nothing is appearing for me.

http://www.hm-stox.co.uk

Thanks

Newbie

Posts

Joined
Wed Aug 06, 2014 12:46 am

Post by IP_CAM » Tue Aug 16, 2016 7:11 am

if you or someone else is still intested in a working v.1.5.6.x Version VqMod for this, just let me know!
Ernie

My Github OC Site: https://github.com/IP-CAM
5'600 + 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 umeshp1212@gmail.com » Sat Dec 03, 2016 4:26 pm

Hi,

Please help me to solve the problem , it showing error to display product code in RELATED PRODUCTS

Product Code: Notice: Undefined index: model in /home/kitsgbpq/public_html/catalog/view/theme/pav_sportshop/template/common/product/default.tpl on line 73

And Code is

Code: Select all

 <div class="product-block" itemtype="http://schema.org/Product" itemscope>
       
     <?php if( $product['special'] ) {   ?>
        <div class="product-label">
            <div class="product-label-wapper">
                <?php echo $this->language->get( 'text_sale' ); ?>
            </div>
        </div>
    <?php } ?>
    <?php if ($product['thumb']) {    ?>
        <div class="image">
            <a class="img" itemprop="url" title="<?php echo $product['name']; ?>" href="<?php echo $product['href']; ?>">
                <img class="img-responsive" itemprop="image" src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" /></a>                            
            <!-- zoom image-->
            <?php if( isset($categoryPzoom) && $categoryPzoom ) { $zimage = str_replace( "cache/","", preg_replace("#-\d+x\d+#", "",  $product['thumb'] ));  ?>
                <a href="<?php echo $zimage;?>" class="btn btn-outline-inverse colorbox product-zoom cboxElement" title="<?php echo $product['name']; ?>">
                <i class="fa fa-search-plus"></i></a>
            <?php } ?>
            <?php //#2 Start fix quickview in fw?>
                <?php if ( isset($quickview) && $quickview ) { ?>
                    <a class="pav-colorbox btn btn-outline-inverse cboxElement" href="<?php echo $this->url->link("themecontrol/product",'product_id='.$product['product_id'] );?>"><em class="fa fa-eye"></em><span><?php echo $this->language->get('quick_view'); ?></span></a>
                <?php } ?>
            <?php //#2 End fix quickview in fw?>
        </div>
    <?php } ?>
                     
    <div class="product-meta">          
        <div class="left">

            <?php if ( isset($product['rating']) && $product['rating'] ) { ?>
            <div class="rating"><img src="catalog/view/theme/<?php echo $this->config->get('config_template');?>/image/stars-<?php echo $product['rating']; ?>.png" alt="<?php echo $product['rating']; ?>">
                <span class="text-review"><?php echo $product['reviews']; ?></span>
                     <?php echo $product['product_id']; ?>
            </div>
            <?php } else { ?>
            <div class="norating">
                <img alt="0" src="catalog/view/theme/<?php echo $this->config->get('config_template');?>/image/stars-0.png">
                <span class="text-review"><?php echo $product['reviews']; ?></span>
            </div>
            <?php } ?>
                
            <?php if ($product['price']) { ?>
            <div class="price" itemtype="http://schema.org/Offer" itemscope itemprop="offers">
                <?php if (!$product['special']) {  ?>
                    <span class="special-price"><?php echo $product['price']; ?></span>
                    <?php if( preg_match( '#(\d+).?(\d+)#',  $product['price'], $p ) ) { ?> 
                    <meta content="<?php echo $p[0]; ?>" itemprop="price">
                    <?php } ?>
                <?php } else { ?>
                    <span class="price-new"><?php echo $product['special']; ?></span>
                     <span class="price-old"><?php echo $product['price']; ?></span> 
                    <?php if( preg_match( '#(\d+).?(\d+)#',  $product['special'], $p ) ) { ?> 
                    <meta content="<?php echo $p[0]; ?>" itemprop="price">
                    <?php } ?>

                <?php } ?>
                <?php if ( isset($product['tax']) && $product['tax']) { ?>            
                    <span class="price-tax"><?php echo $this->language->get('text_tax'); ?> <?php echo $product['tax']; ?></span>
                <?php } ?>

                <meta content="<?php echo $this->currency->getCode(); ?>" itemprop="priceCurrency">
            </div>
            <?php } ?>

            <h3 class="name" itemprop="name"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></h3>
                        <!---extra code-->
                        <div style="margin-top: -16px;">


                       <b>Product Code:</b>
            <strong style="color: red;" class="name" itemprop="name">
                        
            <?php echo $product['model']; ?></strong>
                        </div>
                        <!---extra code-->


            <?php if( isset($product['description']) ){ ?> 
            <p class="description" itemprop="description"><?php echo utf8_substr( strip_tags($product['description']),0,220);?>...</p>
            <?php } ?>    
        </div>
  
        <div class="right">        
            <div class="action">            
                <?php if( !isset($listingConfig['catalog_mode']) || !$listingConfig['catalog_mode'] ) { ?>
                <div class="cart">                        
                    <button onclick="addToCart('<?php echo $product['product_id']; ?>');" class="btn btn-shopping-cart btn-outline-inverse">
                        <span class="fa fa-shopping-cart"></span>
                        <?php echo $this->language->get("button_cart"); ?>
                    </button>
                </div>
                <?php } ?>
                    
                <div class="wishlist">
                    <a data-toggle="tooltip" data-placement="top" onclick="addToWishList('<?php echo $product['product_id']; ?>');" title="<?php echo $this->language->get("button_wishlist"); ?>" class="btn btn-outline">
                         <span class="fa fa-heart"></span>
                        <span class="hide"><?php echo $this->language->get("button_wishlist"); ?></span>
                    </a>    
                </div>    

                <div class="compare">            
                    <a data-toggle="tooltip" data-placement="top" class="btn btn-outline" onclick="addToCompare('<?php echo $product['product_id']; ?>');" title="<?php echo $this->language->get("button_compare"); ?>">
                        <span class="fa fa-files-o"></span>
                        <span class="hide"><?php echo $this->language->get("button_compare"); ?></span>
                    </a>    
                </div>                            
            </div>         
        </div>     
    </div>         
</div>
Last edited by Johnathan on Sun Dec 04, 2016 12:31 am, edited 1 time in total.
Reason: Added [code] tags for readability


Posts

Joined
Sat Dec 03, 2016 4:15 pm
Who is online

Users browsing this forum: No registered users and 15 guests