AbanteCart Community

Shopping Cart Operations => Support => General Support => Topic started by: MLCS on July 30, 2012, 09:49:09 AM

Title: Showing Length, Width, Height?
Post by: MLCS on July 30, 2012, 09:49:09 AM
Hi. How can I make it so the products show their Length, Width and Height on the Product Information?
Title: Re: Showing Length, Width, Height?
Post by: abolabo on July 30, 2012, 12:08:43 PM
hi.
you can add something like this in your product.tpl file
Code: [Select]
<?php echo "width:".$product_info['width']; ?>
<?php echo "height:".$product_info['height']; ?>
<?php echo "length:".$product_info['length']; ?>

i see that we forgot to add length unit name in $product_info var. We'll add this into new version.
You can do this manually. Open file storefront/model/catalog/product.php method getProduct (29 line)
and  replace
Code: [Select]
$query = $this->db->query(
"SELECT DISTINCT *, pd.name AS name, m.name AS manufacturer, ss.name AS stock_status " .
$this->_sql_join_string() .
" WHERE p.product_id = '" . (int)$product_id . "'
AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'
AND p.date_available <= NOW() AND p.status = '1'");
by this

Code: [Select]
$query = $this->db->query(
"SELECT DISTINCT *, pd.name AS name, m.name AS manufacturer, ss.name AS stock_status, lcd.unit as length_class_name " .
$this->_sql_join_string() .
"LEFT JOIN " . DB_PREFIX . "length_class_descriptions lcd
ON (p.length_class_id = lcd.length_class_id AND lcd.language_id = '" . (int)$this->config->get('storefront_language_id') . "')
WHERE p.product_id = '" . (int)$product_id . "'
AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'
AND p.date_available <= NOW() AND p.status = '1'");
Thank you.
Title: Re: Showing Length, Width, Height?
Post by: MLCS on July 30, 2012, 12:33:26 PM
Thankyou so much!

The actual writing on the product.tpl was a bit different...
Maybe you can help so if I change the measurement it automatically changes on the page aswell.

This is what Ive put in

Code: [Select]
<tr>
<td><b><?php echo "Length:"?></b></td>
<td><?php echo $product_info['length'] . "mm"?></td>
</tr>
<tr>
<td><b><?php echo "Width:"?></b></td>
<td><?php echo $product_info['width'] . "mm"?></td>
</tr>
<tr>
<td><b><?php echo "Height:"?></b></td>
<td><?php echo $product_info['height'] . "mm"?></td>
</tr>

As you can see Ive wrote . "mm"; ?>
How can I change that so if one of the measurements in is cm then it would change
Title: Re: Showing Length, Width, Height?
Post by: abolabo on July 31, 2012, 11:04:20 AM
Thank you so much!

The actual writing on the product.tpl was a bit different...
Maybe you can help so if I change the measurement it automatically changes on the page aswell.

This is what Ive put in

Code: [Select]
<tr>
<td><b><?php echo "Length:"?></b></td>
<td><?php echo $product_info['length'] . "mm"?></td>
</tr>
<tr>
<td><b><?php echo "Width:"?></b></td>
<td><?php echo $product_info['width'] . "mm"?></td>
</tr>
<tr>
<td><b><?php echo "Height:"?></b></td>
<td><?php echo $product_info['height'] . "mm"?></td>
</tr>

As you can see Ive wrote . "mm"; ?>
How can I change that so if one of the measurements in is cm then it would change

MLCS, please look at my post above again.
I propose to change model and gets "length_class_name" from  $product_info array.
After that you need write
Code: [Select]
<?php echo $product_info['height'] . $product_info['length_class_name']; ?>
Title: Re: Showing Length, Width, Height?
Post by: MLCS on July 31, 2012, 01:28:34 PM
Thankyou so much! This has solved everything :)
Ill lock this for you :)
Title: Re: Showing Length, Width, Height?
Post by: MLCS on August 12, 2012, 12:20:01 PM
Another related question

Is there any chance I can set it so if I dont include a value for Length, Width or Height that it doesnt show them on the Product Information?
Also. Showing Weight?
Title: Re: Showing Length, Width, Height?
Post by: MLCS on August 21, 2012, 08:37:44 PM
anybody???
Title: Re: Showing Length, Width, Height?
Post by: abantecart on August 22, 2012, 12:16:42 PM
Yes,

You need to put conditional check around each display section in the same tpl file

Example:
Quote
<?php if ( $product_info['height'] ) { ?>
            <tr>
                  <td><b><?php echo "Height:"; ?></b></td>
                  <td><?php echo $product_info['height'] . "mm"; ?></td>
               </tr>
<?php } ?>
Title: Re: Showing Length, Width, Height?
Post by: MLCS on August 26, 2012, 02:46:59 PM
Yes,

You need to put conditional check around each display section in the same tpl file

Example:
Quote
<?php if ( $product_info['height'] ) { ?>
            <tr>
                  <td><b><?php echo "Height:"; ?></b></td>
                  <td><?php echo $product_info['height'] . "mm"; ?></td>
               </tr>
<?php } ?>

That didnt work. It still shows "Height: 0.00mm"

Also, displaying weight?!?!
Title: Re: Showing Length, Width, Height?
Post by: Nimitz1061 on August 27, 2012, 09:53:44 AM
This boils down to selecting the right test.  The problem with the example test provided is that it just tests to see if the variable exists, which it does, while the actual need is to test whether it exists and is not NULL.

Check PHP documentation for the specifics of correct conditionals. 

David
Title: Re: Showing Length, Width, Height?
Post by: abantecart on August 27, 2012, 06:30:07 PM
If you need PHP coding help. Please post code extract you have now
Title: Re: Showing Length, Width, Height?
Post by: MLCS on August 30, 2012, 08:22:51 AM
Showing the height (in product.tpl)
Code: [Select]
<?php if ( $product_info['height'] ) { ?>
            <tr>
                  <td><b><?php echo "Height:"?></b></td>
                  <td><?php echo $product_info['height'] . $product_info['length_class_name']; ?></td>
               </tr>
<?php ?>

Edit:
Found out where the error was
Just had to do:
Code: [Select]
<?php if($product_info['height']>'0'){?>

So thats that bit sorted

I still need to get the weight showing
Any help?