Zen Cart Logo
Forums / Setting Up Categories, Products, Attributes / tpl_modules_attributes - modification

tpl_modules_attributes - modification

Views: 566

Results 1 to 6 of 6
1 Feb 2013, 11:59 PM
#1
krnl avatar

krnl

New Zenner

Join Date:
Feb 2013
Location:
Vancouver, British Columbia, Canada
Posts:
3
Plugin Contributions:
0

tpl_modules_attributes - modification

Hello,

I have a page that has been modified by a person during the original build. The site is for a contact lens company opticalnow.ca

The modification made sense when the site was built as every product had needs a prescription. We now have a new product that doesn't so the code on the tpl_modules_attributes is causing an issue.

I need to keep the code for the prescription for every product except this one.

I've managed to get the product attribute to display on the page by adding another line with it's attribute but it isn't right.

This is the page - http://opticalnow.ca/adlens-hemisphere®-p-86.html?cPath=32

Here is the code I added to the rest to get it to show

case 'Colour':
                    $result['Colour']['right'][] = $options_menu[$i];
                    break;

My php is not great - thanks for the help

This is the rest of the page code.

<?php
/**
 * Module Template
 *
 * Template used to render attribute display/input fields
 *
 * @package templateSystem
 * @copyright Copyright 2009 Glenn Herbert
 * @copyright Copyright 2003-2005 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.gnu.org/licenses/ GNU Public License V3.0
 * @version $Id: tpl_modules_attributes.php 3208 2006-03-19 16:48:57Z birdbrain $
 * Modified for Flexible Attributes by Glenn Herbert (gjh42)  20091228
 */
?>
<div id="productAttributes">
<?php if ($zv_display_select_option > 0) { ?>
<h3 id="attribsOptionsText"><?php //echo TEXT_PRODUCT_OPTIONS; ?>Enter your Prescription:</h3>
<?php } // show please select unless all are readonly ?>

<?php
    $html = '<table id="products_attributes_table">';
    $result = array();
    for($i=0;$i<sizeof($options_name);$i++) 
    {
            switch( strip_tags($options_name[$i]))
            {
                case 'BC (mm) / Dia (mm)':
                    $result['BC / DIA']['right'][] = $options_menu[$i];
                    break;
                case '2 BC (mm) / Dia (mm)':
                    $result['BC / DIA']['left'][] = $options_menu[$i];
                    break;
                
                case 'Power Range (D)':
                    $result['Power']['right'][] = $options_menu[$i];
                    break;
                case '2 Power Range (D)':
                    $result['Power']['left'][] = $options_menu[$i];
                    break;
                    
                case 'Cyl':
                    $result['Cyl']['right'][] = $options_menu[$i];
                    break;
                case '2 Cyl':
                    $result['Cyl']['left'][] = $options_menu[$i];
                    break;
                
                case 'Axes':
                    $result['Axes']['right'][] = $options_menu[$i];
                    break;
                case '2 axes':
                    $result['Axes']['left'][] = $options_menu[$i];
                    break;
                
                case 'Adds':
                    $result['Adds']['right'][] = $options_menu[$i];
                    break;
                case '2 adds':
                    $result['Adds']['left'][] = $options_menu[$i];
                    break;
                
                case 'quantity':
                    $result['Qty']['right'][] = $options_menu[$i];
                    break;
                case '2 quantity':
                    $result['Qty']['left'][] = $options_menu[$i];
                    break;
                case 'Colour':
                    $result['Colour']['right'][] = $options_menu[$i];
                    break;
                default:
                    echo 'not found: '.$options_name[$i];
            }
    }
    $heading = "";
    $left = '';
    $right = '';
    $body = '';
    $count = 0;
    foreach( $result as $key => $value )
    {
        if( $count == 0 )
        {
            $heading .= '<th colspan="2" align="right">'.$key.'</th>';
        }
        else
        {
            $heading .= '<th>'.$key.'</th>';
        }
        $count++;
        foreach( $value['left'] as $leftValues )
        {
            $left .= '<td>'.$leftValues.'</td>';
        }
        foreach( $value['right'] as $rightValues )
        {
            $right .= '<td>'.$rightValues.'</td>';
        }
    }
?>

<?php
    for($i=0;$i<sizeof($options_name);$i++) {
?>
<div class="wrapperAttribsOptions" id="<?php echo $options_wrapper_id[$i];//gjh42 ?>">
<?php
  if ($options_comment[$i] != '' and $options_comment_position[$i] == '0') {
?>
<h3 class="attributesComments"><?php echo $options_comment[$i]; ?></h3>
<?php
  }
?>



<?php if ($options_comment[$i] != '' and $options_comment_position[$i] == '1') { ?>
    <div class="ProductInfoComments"><?php echo $options_comment[$i]; ?></div>
<?php } ?>
</div>

<?php
if ($options_attributes_image[$i] != '') {
?>
<?php echo $options_attributes_image[$i]; ?>
<?php
}
?>

<div class="clearBoth"></div>
<?php
    }
?>


<?php
  if ($show_onetime_charges_description == 'true') {
?>
    <div class="wrapperAttribsOneTime"><?php echo TEXT_ONETIME_CHARGE_SYMBOL . TEXT_ONETIME_CHARGE_DESCRIPTION; ?></div>
<?php } ?>


<?php
  if ($show_attributes_qty_prices_description == 'true') {
?>
    <div class="wrapperAttribsQtyPrices"><?php echo zen_image(DIR_WS_TEMPLATE_ICONS . 'icon_status_green.gif', TEXT_ATTRIBUTES_QTY_PRICE_HELP_LINK, 10, 10) . ' ' . '<a href="javascriptopupWindowPrice(\'' . zen_href_link(FILENAME_POPUP_ATTRIBUTES_QTY_PRICES, 'products_id=' . $_GET['products_id'] . '&products_tax_class_id=' . $products_tax_class_id) . '\')">' . TEXT_ATTRIBUTES_QTY_PRICE_HELP_LINK . '</a>'; ?></div>
<?php } ?>

<?php
    echo '<table cellpadding="0" cellspacing="0"><tr>'.$heading.'</tr><tr><td><span>Right Eye</span></td>'.$right.'</tr><tr class="empty"><td colspan="4"></tr><tr><td><span>Left Eye</span></td>'.$left.'</tr><tr class="empty"><td colspan="4"></tr></table>';
?>
</div>
2 Feb 2013, 12:25 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: tpl_modules_attributes - modification

I'm guessing that the answer is in the last section of code:```

<?php echo '<table cellpadding="0" cellspacing="0"><tr>'.$heading.'</tr><tr><td><span>Right Eye</span></td>'.$right.'</tr><tr class="empty"><td colspan="4"></tr><tr><td><span>Left Eye</span></td>'.$left.'</tr><tr class="empty"><td colspan="4"></tr></table>'; ?> </div> ``` I might try replacing those lines to use the following lines instead: ``` <?php echo '<table cellpadding="0" cellspacing="0"><tr>'.$heading.'</tr>'; if ($left == '<td></td>') { // if there is only a "Right" setting, then assume the choices apply for both eyes equally, ie: skip the "Right" label, and don't output the content for $left: echo '<tr><td><span>Selection</span></td>'.$right.'</tr><tr class="empty"><td colspan="4"></tr></table>'; } else { // otherwise, display both choices echo '<tr><td><span>Right Eye</span></td>'.$right.'</tr><tr class="empty"><td colspan="4"></tr><tr><td><span>Left Eye</span></td>'.$left.'</tr><tr class="empty"><td colspan="4"></tr></table>'; } ?> </div> ```
2 Feb 2013, 5:50 PM
#3
krnl avatar

krnl

New Zenner

Join Date:
Feb 2013
Location:
Vancouver, British Columbia, Canada
Posts:
3
Plugin Contributions:
0

Re: tpl_modules_attributes - modification

DrByte:

I'm guessing that the answer is in the last section of code:```

<?php echo '<table cellpadding="0" cellspacing="0"><tr>'.$heading.'</tr><tr><td><span>Right Eye</span></td>'.$right.'</tr><tr class="empty"><td colspan="4"></tr><tr><td><span>Left Eye</span></td>'.$left.'</tr><tr class="empty"><td colspan="4"></tr></table>'; ?> </div> ``` > I might try replacing those lines to use the following lines instead: > ``` <?php echo '<table cellpadding="0" cellspacing="0"><tr>'.$heading.'</tr>'; if ($left == '<td></td>') { // if there is only a "Right" setting, then assume the choices apply for both eyes equally, ie: skip the "Right" label, and don't output the content for $left: echo '<tr><td><span>Selection</span></td>'.$right.'</tr><tr class="empty"><td colspan="4"></tr></table>'; } else { // otherwise, display both choices echo '<tr><td><span>Right Eye</span></td>'.$right.'</tr><tr class="empty"><td colspan="4"></tr><tr><td><span>Left Eye</span></td>'.$left.'</tr><tr class="empty"><td colspan="4"></tr></table>'; } ?> </div> ```

Thanks - I tried that, same result though.

Was thinking this am - could the code about a not found be part of it?

case 'Colour':
$result['Colour']['right'][] = $options_menu[$i];
break;
default:
echo 'not found: '.$options_name[$i];
}

3 Feb 2013, 4:40 AM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: tpl_modules_attributes - modification

Oops. I should have checked for 'blank' as well.

Change this:

if ($left == '<td></td>') {
```to this:```
if ($left == '' || $left == '<td></td>') {
3 Feb 2013, 10:40 PM
#5
krnl avatar

krnl

New Zenner

Join Date:
Feb 2013
Location:
Vancouver, British Columbia, Canada
Posts:
3
Plugin Contributions:
0

Re: tpl_modules_attributes - modification

DrByte:

Oops. I should have checked for 'blank' as well.

Change this:

if ($left == '<td></td>') {
to this:
if ($left == '' || $left == '<td></td>') {


Thanks - worked perfect.

Just have to figure out why the option comes up as not found in the cart once you add it.
3 Feb 2013, 11:04 PM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: tpl_modules_attributes - modification

Guessing you've got some similar code elsewhere that needs updating as well.