News:

AbanteCart v1.4.2 is released.

Main Menu
support

Showing Length, Width, Height?

Started by MLCS, July 30, 2012, 09:49:09 AM

Previous topic - Next topic

MLCS

Hi. How can I make it so the products show their Length, Width and Height on the Product Information?

abolabo

hi.
you can add something like this in your product.tpl file
<?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
$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

$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.
"No one is useless in this world who lightens the burdens of another."
― Charles Dickens

MLCS

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


<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

abolabo

Quote from: MLCS on July 30, 2012, 12:33:26 PM
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


<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 <?php echo $product_info['height'] . $product_info['length_class_name']; ?>

"No one is useless in this world who lightens the burdens of another."
― Charles Dickens

MLCS

Thankyou so much! This has solved everything :)
Ill lock this for you :)

MLCS

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?

MLCS


abantecart

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 } ?>
Please  rate your experience or leave your review
We need your help to build better free open source ecommerce platform for everyone. See how you can help

MLCS

#8
Quote from: 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 } ?>

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

Also, displaying weight?!?!

Nimitz1061

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

abantecart

If you need PHP coding help. Please post code extract you have now
Please  rate your experience or leave your review
We need your help to build better free open source ecommerce platform for everyone. See how you can help

MLCS

#11
Showing the height (in product.tpl)
<?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:

<?php if($product_info['height']>'0'){?>


So thats that bit sorted

I still need to get the weight showing
Any help?

Forum Rules Code of conduct
AbanteCart.com 2010 -