Author Topic: Showing Length, Width, Height?  (Read 14453 times)

Offline MLCS

  • Newbie
  • *
  • Posts: 28
  • Karma: +3/-0
    • View Profile
    • My Little Crystal Shop
Showing Length, Width, Height?
« 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?

Offline abolabo

  • core-developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2046
  • Karma: +318/-13
  • web for all, all for web!
    • View Profile
    • AbanteCart
Re: Showing Length, Width, Height?
« Reply #1 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.
“No one is useless in this world who lightens the burdens of another.”
― Charles Dickens

Offline MLCS

  • Newbie
  • *
  • Posts: 28
  • Karma: +3/-0
    • View Profile
    • My Little Crystal Shop
Re: Showing Length, Width, Height?
« Reply #2 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

Offline abolabo

  • core-developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2046
  • Karma: +318/-13
  • web for all, all for web!
    • View Profile
    • AbanteCart
Re: Showing Length, Width, Height?
« Reply #3 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']; ?>
“No one is useless in this world who lightens the burdens of another.”
― Charles Dickens

Offline MLCS

  • Newbie
  • *
  • Posts: 28
  • Karma: +3/-0
    • View Profile
    • My Little Crystal Shop
Re: Showing Length, Width, Height?
« Reply #4 on: July 31, 2012, 01:28:34 PM »
Thankyou so much! This has solved everything :)
Ill lock this for you :)

Offline MLCS

  • Newbie
  • *
  • Posts: 28
  • Karma: +3/-0
    • View Profile
    • My Little Crystal Shop
Re: Showing Length, Width, Height?
« Reply #5 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?

Offline MLCS

  • Newbie
  • *
  • Posts: 28
  • Karma: +3/-0
    • View Profile
    • My Little Crystal Shop
Re: Showing Length, Width, Height?
« Reply #6 on: August 21, 2012, 08:37:44 PM »
anybody???

Offline abantecart

  • Administrator
  • Hero Member
  • *****
  • Posts: 4358
  • Karma: +298/-10
    • View Profile
    • Ideal Open Source Ecommerce Solution
Re: Showing Length, Width, Height?
« Reply #7 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 } ?>
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

Offline MLCS

  • Newbie
  • *
  • Posts: 28
  • Karma: +3/-0
    • View Profile
    • My Little Crystal Shop
Re: Showing Length, Width, Height?
« Reply #8 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?!?!
« Last Edit: August 26, 2012, 03:03:47 PM by MLCS »

Offline Nimitz1061

  • Full Member
  • ***
  • Posts: 190
  • Karma: +22/-0
  • No matter where you go, there you are...
    • View Profile
Re: Showing Length, Width, Height?
« Reply #9 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

Offline abantecart

  • Administrator
  • Hero Member
  • *****
  • Posts: 4358
  • Karma: +298/-10
    • View Profile
    • Ideal Open Source Ecommerce Solution
Re: Showing Length, Width, Height?
« Reply #10 on: August 27, 2012, 06:30:07 PM »
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

Offline MLCS

  • Newbie
  • *
  • Posts: 28
  • Karma: +3/-0
    • View Profile
    • My Little Crystal Shop
Re: Showing Length, Width, Height?
« Reply #11 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?
« Last Edit: August 30, 2012, 08:32:36 AM by MLCS »

 

Powered by SMFPacks Social Login Mod