Jump to content
Sign in to follow this  
Chandra

Option Type Feature v1.6 (for osc 2.2 MS2)

Recommended Posts

I have a somewhat similar problem as some people in this thread have described.

 

The options that I have show up twice, once with the correct option type and a second time with just a regular radio button. When they appear with the correct option type, it only shows the first item in that group, but not the second one's. But as they are shown the second time, the radio button one's show all of the options that I have listed. I am fairly certain its an issue with my product_info.php file. I just cant pinpoint it.

 

Any suggestions?

 

<?php
/*
 $Id: product_info.php,v 1.97 2003/07/01 14:34:54 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_PRODUCT_INFO);

 $product_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
 $product_check = tep_db_fetch_array($product_check_query);
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<?php
// BOF: Header Tag Controller v2.6.0
if ( file_exists(DIR_WS_INCLUDES . 'header_tags.php') ) {
 require(DIR_WS_INCLUDES . 'header_tags.php');
} else {
?> 
 <title><?php echo TITLE; ?></title>
<?php
}
// EOF: Header Tag Controller v2.6.0
?>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<script language="javascript">
function popupWindow(url) {
 window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,res
izable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,le
ft=150')
}
/* DDB - 041031 - Form Field Progress Bar */
/***********************************************
* Form Field Progress Bar- By Ron Jonk- http://www.euronet.nl/~jonkr/
* Modified by Dynamic Drive for minor changes
* Script featured/ available at Dynamic Drive- http://www.dynamicdrive.com
* Please keep this notice intact
***********************************************/
function textCounter(field,counter,maxlimit,linecounter) {
// text width//
var fieldWidth =  parseInt(field.offsetWidth);
var charcnt = field.value.length;		
// trim the extra text
if (charcnt > maxlimit) { 
	field.value = field.value.substring(0, maxlimit);
} else { 
// progress bar percentage
var percentage = parseInt(100 - (( maxlimit - charcnt) * 100)/maxlimit);
document.getElementById(counter).style.width =  parseInt((fieldWidth*percentage)/100)+"px";
document.getElementById(counter).innerHTML="Limit: "+percentage+"%"
// color correction on style from CCFFF -> CC0000
setcolor(document.getElementById(counter),percentage,"background-color");
}
}
function setcolor(obj,percentage,prop){
obj.style[prop] = "rgb(80%,"+(100-percentage)+"%,"+(100-percentage)+"%)";
}
</script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="3" cellpadding="3">
 <tr>
<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
</table></td>
<!-- body_text //-->
<td width="100%" valign="top"><?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product')); ?><table border="0" width="100%" cellspacing="0" cellpadding="0">
<?php
 if ($product_check['total'] < 1) {
?>
  <tr>
	<td><?php new infoBox(array(array('text' => TEXT_PRODUCT_NOT_FOUND))); ?></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
  <tr>
	<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
	  <tr class="infoBoxContents">
		<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
		  <tr>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
			<td align="right"><?php echo '<a href="' . tep_href_link(FILENAME_HOME) . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
		  </tr>
		</table></td>
	  </tr>
	</table></td>
  </tr>
<?php
 } else {
//BOF UltraPics
//BOF Original
/*
$product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
*/
//EOF Original
$product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, p.products_image_med, p.products_image_lrg, p.products_image_sm_1, p.products_image_xl_1, p.products_image_sm_2, p.products_image_xl_2, p.products_image_sm_3, p.products_image_xl_3, p.products_image_sm_4, p.products_image_xl_4, p.products_image_sm_5, p.products_image_xl_5, p.products_image_sm_6, p.products_image_xl_6, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
//EOF UltraPics
$product_info = tep_db_fetch_array($product_info_query);

tep_db_query("update " . TABLE_PRODUCTS_DESCRIPTION . " set products_viewed = products_viewed+1 where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and language_id = '" . (int)$languages_id . "'");

if ($new_price = tep_get_products_special_price($product_info['products_id'])) {

  //GroupDiscount start
  $products_price = '<s>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price_nodiscount($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>';
  //GroupDiscount end

} else {
  $products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']));
}

if (tep_not_null($product_info['products_model'])) {
  $products_name = $product_info['products_name'] . '<br><span class="smallText">[' . $product_info['products_model'] . ']</span>';
} else {
  $products_name = $product_info['products_name'];
}
?>
  <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
	  <tr>
		<td valign="top"><h1><?php echo $products_name; ?></h1></td>
		<td align="right" valign="top"><h1><?php echo $products_price; ?></h1></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
  <tr>
	<td class="main">
<?php
if (tep_not_null($product_info['products_image'])) {
?>
	  <table border="0" cellspacing="0" cellpadding="2" align="right">
		<tr>
		  <td align="center" class="smallText">
<!--BOF UltraPics-->
<?php
if ($product_info['products_image_med']!='') {
	$new_image = $product_info['products_image_med'];
	$image_width = MEDIUM_IMAGE_WIDTH;
	$image_height = MEDIUM_IMAGE_HEIGHT;
} else {
	$new_image = $product_info['products_image'];
	$image_width = SMALL_IMAGE_WIDTH;
	$image_height = SMALL_IMAGE_HEIGHT;
}

?>
<!--EOF UltraPics-->
<script language="javascript"><!--
//BOF UltraPics
//BOF Original
/*
document.write('<?php echo '<a href="java script:popupWindow(\\\'' . tep_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $product_info['products_id']) . '\\\')">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], addslashes($product_info['products_name']), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?>');
*/
//EOF Original
document.write('<?php echo '<a href="java script:popupWindow(\\\'' . tep_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $product_info['products_id'] . 'ℑ=0') . '\\\')">' . tep_image(DIR_WS_IMAGES . $new_image, addslashes($product_info['products_name']), $image_width, $image_height, 'hspace="5" vspace="5"') . '<br>' . tep_image_button('image_enlarge.gif', TEXT_CLICK_TO_ENLARGE) . '</a>'; ?>');
//EOF UltraPics
//--></script>
<noscript>
<!--BOF UltraPics-->
<!--BOF Original--><!--
<?php echo '<a href="' . tep_href_link(DIR_WS_IMAGES . $product_info['products_image']) . '" target="_blank">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], $product_info['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?>
--><!--EOF Original-->
<?php echo '<a href="' . tep_href_link(DIR_WS_IMAGES . $product_info['products_image_med']) . '">' . tep_image(DIR_WS_IMAGES . $new_image . 'ℑ=0', addslashes($product_info['products_name']), $image_width, $image_height, 'hspace="5" vspace="5"') . '<br>' . tep_image_button('image_enlarge.gif', TEXT_CLICK_TO_ENLARGE) . '</a>'; ?>
<!--EOF UltraPics-->
</noscript>
		  </td>
		</tr>
	  </table>
<?php
}
?>
	  <p><?php echo stripslashes($product_info['products_description']); ?></p>
<?php 

$products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'");
$products_attributes = tep_db_fetch_array($products_attributes_query);
if ($products_attributes['total'] > 0) {
?>
	  <table border="0" cellspacing="0" cellpadding="2">
		<tr>
		  <td class="main" colspan="2"><?php echo TEXT_PRODUCT_OPTIONS; ?></td>
		</tr>
<?php
		//clr 030714 update query to pull option_type
  $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name, popt.products_options_type, popt.products_options_length, popt.products_options_comment from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' order by popt.products_options_name");
  while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
			//clr 030714 add case statement to check option type
	switch ($products_options_name['products_options_type']) {
	  case PRODUCTS_OPTIONS_TYPE_TEXT:
		//CLR 030714 Add logic for text option
		$products_attribs_query = tep_db_query("select distinct patrib.options_values_price, patrib.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = '" . $products_options_name['products_options_id'] . "'");
		$products_attribs_array = tep_db_fetch_array($products_attribs_query);
		$tmp_html = '<input type="text" name ="id[' . TEXT_PREFIX . $products_options_name['products_options_id'] . ']" size="' . $products_options_name['products_options_length'] .'" maxlength="' . $products_options_name['products_options_length'] . '" value="' . $cart->contents[$HTTP_GET_VARS['products_id']]['attributes_values'][$products_options_name['products_options_id']] .'">  ' . $products_options_name['products_options_comment'];
		if ($products_attribs_array['options_values_price'] != '0') {
		  $tmp_html .= '(' . $products_attribs_array['price_prefix'] . $currencies->display_price($products_attribs_array['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .')';
		}
?>
		<tr>
		  <td class="main"><?php echo $products_options_name['products_options_name'] . ':'; ?></td>
		  <td class="main"><?php echo $tmp_html;  ?></td>
		</tr>
<?php
		break;

	  case PRODUCTS_OPTIONS_TYPE_TEXTAREA:
		//CLR 030714 Add logic for text option
		$products_attribs_query = tep_db_query("select distinct patrib.options_values_price, patrib.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = '" . $products_options_name['products_options_id'] . "'");
		$products_attribs_array = tep_db_fetch_array($products_attribs_query);
	$tmp_html = '<textarea onKeyDown="textCounter(this,\'progressbar' . $products_options_name['products_options_id'] . '\',' . $products_options_name['products_options_length'] . ')" 
							   onKeyUp="textCounter(this,\'progressbar' . $products_options_name['products_options_id'] . '\',' . $products_options_name['products_options_length'] . ')" 
							   onFocus="textCounter(this,\'progressbar' . $products_options_name['products_options_id'] . '\',' . $products_options_name['products_options_length'] . ')" 
							   wrap="soft" 
							   name="id[' . TEXT_PREFIX . $products_options_name['products_options_id'] . ']" 
							   rows=5 
							   id="id[' . TEXT_PREFIX . $products_options_name['products_options_id'] . ']" 
							   value="' . $cart->contents[$HTTP_GET_VARS['products_id']]['attributes_values'][$products_options_name['products_options_id']] . '"></textarea>
					<div id="progressbar' . $products_options_name['products_options_id'] . '" class="progress"></div>
					<script>textCounter(document.getElementById("id[' . TEXT_PREFIX . $products_options_name['products_options_id'] . ']"),"progressbar' . $products_options_name['products_options_id'] . '",' . $products_options_name['products_options_length'] . ')</script>';?>	<!-- DDB - 041031 - Form Field Progress Bar //-->
		<tr>
<?php
		if ($products_attribs_array['options_values_price'] != '0') {
?>
		  <td class="main"><?php echo $products_options_name['products_options_name'] . '<br>(' . $products_options_name['products_options_comment'] . ' ' . $products_attribs_array['price_prefix'] . $currencies->display_price($products_attribs_array['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . ')'; ?></td>
<?php	   } else {
?>
		  <td class="main"><?php echo $products_options_name['products_options_name'] . '<br>(' . $products_options_name['products_options_comment'] . ')'; ?></td>
<?php		}
?>
		  <td class="main"><?php echo $tmp_html;  ?></td>
		</tr>
<?php
		break;

	  case PRODUCTS_OPTIONS_TYPE_RADIO:
		//CLR 030714 Add logic for radio buttons
		$tmp_html = '<table>';
		$products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . $products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "'");
		$checked = true;
		while ($products_options_array = tep_db_fetch_array($products_options_query)) {
		  $tmp_html .= '<tr><td class="main">';
		  $tmp_html .= tep_draw_radio_field('id[' . $products_options_name['products_options_id'] . ']', $products_options_array['products_options_values_id'], $checked);
		  $checked = false;
		  $tmp_html .= $products_options_array['products_options_values_name'];
		  $tmp_html .=$products_options_name['products_options_comment'];
		  if ($products_options_array['options_values_price'] != '0') {
			$tmp_html .= '(' . $products_options_array['price_prefix'] . $currencies->display_price($products_options_array['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
		  }
		  $tmp_html .= '</tr></td>';
		}
		$tmp_html .= '</table>';
?>
		<tr>
		  <td class="main"><?php echo $products_options_name['products_options_name'] . ':'; ?></td>
		  <td class="main"><?php echo $tmp_html;  ?></td>
		</tr>
<?php
		break;
	  case PRODUCTS_OPTIONS_TYPE_CHECKBOX:
		//CLR 030714 Add logic for checkboxes
		$products_attribs_query = tep_db_query("select distinct patrib.options_values_id, patrib.options_values_price, patrib.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = '" . $products_options_name['products_options_id'] . "'");
		$products_attribs_array = tep_db_fetch_array($products_attribs_query);
		echo '<tr><td class="main">' . $products_options_name['products_options_name'] . ': </td><td class="main">';
		echo tep_draw_checkbox_field('id[' . $products_options_name['products_options_id'] . ']', $products_attribs_array['options_values_id']);
		echo $products_options_name['products_options_comment'];
		if ($products_attribs_array['options_values_price'] != '0') {
		  echo '(' . $products_attribs_array['price_prefix'] . $currencies->display_price($products_attribs_array['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
		}
		echo '</td></tr>';
		break;
	  default:
		//clr 030714 default is select list
		//clr 030714 reset selected_attribute variable
		$selected_attribute = false;
	$products_options_array = array();
	$products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'");
	while ($products_options = tep_db_fetch_array($products_options_query)) {
	  $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']);
	  if ($products_options['options_values_price'] != '0') {
		$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
	  }
	}

	if (isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) {
	  $selected_attribute = $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']];
	} else {
	  $selected_attribute = false;
	}
?>
		<tr>
		  <td class="main"><?php echo $products_options_name['products_options_name'] . ':'; ?></td>
		  <td class="main"><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute) . $products_options_name['products_options_comment'];  ?></td>
		</tr>
<?php
	}  //clr 030714 end switch
  } //clr 030714 end while
?>
	  </table>
<?php

//Options as Images. This whole php clause needs to be added
if (OPTIONS_AS_IMAGES_ENABLED == 'true') include ('options_images.php'); 
}
?>
	</td>
  </tr>
<!--BOF UltraPics-->
<?php
if (ULTIMATE_ADDITIONAL_IMAGES == 'enable') include(DIR_WS_MODULES . 'additional_images.php');
?> 
<!--EOF UltraPics-->
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
<?php
$reviews_query = tep_db_query("select count(*) as count from " . TABLE_REVIEWS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");
$reviews = tep_db_fetch_array($reviews_query);
if ($reviews['count'] > 0) {
?>
  <tr>
	<td class="main"><?php echo TEXT_CURRENT_REVIEWS . ' ' . $reviews['count']; ?></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
<?php
}

if (tep_not_null($product_info['products_url'])) {
?>
  <tr>
	<td class="main"><?php echo sprintf(TEXT_MORE_INFORMATION, tep_href_link(FILENAME_REDIRECT, 'action=url&goto=' . urlencode($product_info['products_url']), 'NONSSL', true, false)); ?></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
<?php
}

if ($product_info['products_date_available'] > date('Y-m-d H:i:s')) {
?>
  <tr>
	<td align="center" class="smallText"><?php echo sprintf(TEXT_DATE_AVAILABLE, tep_date_long($product_info['products_date_available'])); ?></td>
  </tr>
<?php
} else {
?>
  <tr>
	<td align="center" class="smallText"><?php echo sprintf(TEXT_DATE_ADDED, tep_date_long($product_info['products_date_added'])); ?></td>
  </tr>
<?php
}
?>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
  <tr>
	<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
	  <tr class="infoBoxContents">
		<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
		  <tr>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
			<td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params()) . '">' . tep_image_button('button_reviews.gif', IMAGE_BUTTON_REVIEWS) . '</a>'; ?></td>
			<td class="main" align="right"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
		  </tr>
		</table></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
  <tr>
	<td>
<?php
if ((USE_CACHE == 'true') && empty($SID)) {
  echo tep_cache_also_purchased(3600);
} else {
  include(DIR_WS_MODULES . FILENAME_ALSO_PURCHASED_PRODUCTS);
}
 }
?>
	</td>
  </tr>
</table></form></td>
<!-- body_text_eof //-->
<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
<!-- right_navigation_eof //-->
</table></td>
 </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

Thanks for your help!!

 

-Thomp

Share this post


Link to post
Share on other sites

Hi there!

Im so thankfull for this great contribution.

 

I was wondering over one thing, is it possible to change or set some parameters for the input text.

For example if I dont want that number less than 1 to be typed in or certain words thats not so ethical.

When trying to add the product there should be some kind of popup.

 

 

Thanks in advance

Share this post


Link to post
Share on other sites
OK got it working. Am using multistore, so had to file compare and merge ,for days on end... :rolleyes: :rolleyes: :rolleyes: :rolleyes: :rolleyes:

 

Thanks to all that put this together

:D

 

OK ... so I have the Attribute Copy & Sort and the Option Type Feature installed. I worked off of your code and FINALLY got it to sort the attributes in the drop down lists in the order that I assigned them in the Attribute Copy & Sort. I can't guarantee that this will work for you, but it's worth a shot since so many of you are asking for it. Keep in mind that I am not a programmer of any kind, but I seem to have some ability to understand the logic, even with code I don't necessarily understand.

 

I personally hate to scroll through lines and lines of code in the support forums, but here is my product_info.php code I changed from the original file that came with Option Type Feature 7.1.2:

 

Find:

$products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'" );

 

Replace with:

$products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "' order by pa.products_options_sort_order, pov.products_options_values_name ASC" );

 

Hope this helps someone!!

 

Scott

Share this post


Link to post
Share on other sites
i'm having the same problem. i add a product to the cart, then click on it from the cart to update something in a textarea and when i get the the product info page the textarea box is blank BUt all the textboxes are still filled in... then when i reenter info in the textarea and hit add to cart a completely new item is entered into the cart and i have to remove the first item i wanted to edit.
I noticed a bug in the code for the text area in product_info.php which causes this. The instructions show this code:

		$tmp_html = '<textarea onKeyDown="textCounter(this,\'progressbar' . $products_options_name['products_options_id'] . '\',' . $products_options_name['products_options_length'] . ')" 
							   onKeyUp="textCounter(this,\'progressbar' . $products_options_name['products_options_id'] . '\',' . $products_options_name['products_options_length'] . ')" 
							   onFocus="textCounter(this,\'progressbar' . $products_options_name['products_options_id'] . '\',' . $products_options_name['products_options_length'] . ')" 
							   wrap="soft" 
							   name="id[' . TEXT_PREFIX . $products_options_name['products_options_id'] . ']" 
							   rows=5 
							   id="id[' . TEXT_PREFIX . $products_options_name['products_options_id'] . ']" 
							   value="' . $cart->contents[$HTTP_GET_VARS['products_id']]['attributes_values'][$products_options_name['products_options_id']] . '"></textarea>

The problem with that is that there is no value attribute for a text area (unlike the input field). The attribute value should be echo'ed in between the textarea tags like:

		$tmp_html = '<textarea onKeyDown="textCounter(this,\'progressbar' . $products_options_name['products_options_id'] . '\',' . $products_options_name['products_options_length'] . ')" 
							   onKeyUp="textCounter(this,\'progressbar' . $products_options_name['products_options_id'] . '\',' . $products_options_name['products_options_length'] . ')" 
							   onFocus="textCounter(this,\'progressbar' . $products_options_name['products_options_id'] . '\',' . $products_options_name['products_options_length'] . ')" 
							   name="id[' . TEXT_PREFIX . $products_options_name['products_options_id'] . ']" 
							   rows="5" 
							   id="id[' . TEXT_PREFIX . $products_options_name['products_options_id'] . ']">' . $cart->contents[$HTTP_GET_VARS['products_id']]['attributes_values'][$products_options_name['products_options_id']] .'</textarea>

Note that the wrap attribute is gone also, according to the w3c validator is not a valid attribute (any more apparently because in my 1999 copy of Web Design in a Nutshell it was). Id's with a bracket in it "[" are not valid also according to that validator, but there is nothing that can be done about that.

Share this post


Link to post
Share on other sites

I have a question about the instructions for your Product Attributes - Option Type Feature. It is for the instructions for the file: /catalog/includes/classes/shopping_cart.php

 

These are the instructions I'm confused about:

______________________________________________________________

FIND: (around line 88)

 

$products_id_string = tep_get_uprid($products_id, $attributes);

$products_id = tep_get_prid($products_id_string);

 

if (is_numeric($products_id) && is_numeric($qty)) {

$check_product_query = tep_db_query("select products_status from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");

$check_product = tep_db_fetch_array($check_product_query);

 

if (($check_product !== false) && ($check_product['products_status'] == '1')) {

 

REPLACE with

 

$products_id = tep_get_uprid($products_id, $attributes);

______________________________________________________________

 

Because in my file it has some extra code which I pasted below (extra code in bold):

______________________________________________________________

$products_id_string = tep_get_uprid($products_id, $attributes);

$products_id = tep_get_prid($products_id_string);

 

$attributes_pass_check = true;

 

if (is_array($attributes)) {

reset($attributes);

while (list($option, $value) = each($attributes)) {

if (!is_numeric($option) || !is_numeric($value)) {

$attributes_pass_check = false;

break;

}

}

}

 

if (is_numeric($products_id) && is_numeric($qty) && ($attributes_pass_check == true)) {

$check_product_query = tep_db_query("select products_status from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");

$check_product = tep_db_fetch_array($check_product_query);

 

if (($check_product !== false) && ($check_product['products_status'] == '1')) {

______________________________________________________________

 

Any idea what to do here? I'm not sure why my file has extra code, as I have not installed any other modules yet.

 

Thanks so much and I'm really excited about getting this module up and running!

Share this post


Link to post
Share on other sites

Also, in the same file, I cannot find this line of code:

________________________________________________________________

 

FIND: (around line 126)

 

if (is_numeric($products_id) && isset($this->contents[$products_id_string]) && is_numeric($quantity)) {

$this->contents[$products_id_string] = array('qty' => $quantity);

 

REPLACE with

 

$this->contents[$products_id] = array('qty' => $quantity);

Share this post


Link to post
Share on other sites
Also, in the same file, I cannot find this line of code:

________________________________________________________________

 

FIND: (around line 126)

 

if (is_numeric($products_id) && isset($this->contents[$products_id_string]) && is_numeric($quantity)) {

$this->contents[$products_id_string] = array('qty' => $quantity);

 

REPLACE with

 

$this->contents[$products_id] = array('qty' => $quantity);

 

Oh wait here it is.. and it has more extra code! More of that attributes pass check true stuff.!

____________________________________

if (is_numeric($products_id) && isset($this->contents[$products_id_string]) && is_numeric($quantity) && ($attributes_pass_check == true)) {

$this->contents[$products_id_string] = array('qty' => $quantity);

Share this post


Link to post
Share on other sites
Also, in the same file, I cannot find this line of code:
The instructions haven't been updated after the latest osC update of August 17, 2006. Especially in the shopping cart, the function add_cart that is very confusing since $products_id and $products_id_string are used differently in the two versions...

Share this post


Link to post
Share on other sites
The instructions haven't been updated after the latest osC update of August 17, 2006. Especially in the shopping cart, the function add_cart that is very confusing since $products_id and $products_id_string are used differently in the two versions...

 

What does that mean, that this module will not work? I'm still editing the files right now to try and get it to install; for now I made note of the two instructions with extra code found in my shopping cart file and just deleted even the extra code I found inbetween and replaced with the code found in the instructions. Maybe this isn't a good idea (and it's a good thing I did a backup before I started all this).

 

Man, I would LOVE to get this thing working ASAP...

Share this post


Link to post
Share on other sites
What does that mean, that this module will not work?
It can work, but the code needs to be changed for the update. I had the challenge recently of mixing an update of SPPC with Option Type Feature and boy what a headache.

 

Maybe you can use this (I think I cleaned it from the SPPC code in there, no guarantees). I made an additional change to not let empty attribute values (so input fields that have nothing in them still end up in the products_id) get into the products_id string. Only a small, but crucial change is needed for that in /catalog/includes/functions/general.php. The function tep_get_uprid is changed to allow the add_cart from product_info.php to update the product quantity when any text attributes have been left empty. In this "version" of OTF empty text attributes are *not* appended to the products_id and also do not end up in the database. This is different from the standard Option Type Feature.

  function tep_get_uprid($prid, $params) {
$uprid = $prid;
if ( (is_array($params)) && (!strstr($prid, '{')) ) {
  while (list($option, $value) = each($params)) {
			if ($value == '') { continue; } 
			// because empty text attributes will not be added to the products_id_string
			// we need to get rid of them here when application_top is doing add_product and is looking
			// for the quantity of the product with attributes
	//CLR 030714 Add processing around $value. This is needed for text attributes.
	$uprid = $uprid . '{' . $option . '}' . htmlspecialchars(stripslashes(trim($value)), ENT_QUOTES);
  }
//CLR 030228 Add else stmt to process product ids passed in by other routines.
} else {
  $uprid = htmlspecialchars(stripslashes($uprid), ENT_QUOTES);
}
return $uprid;
 }

The code for the includes/classes/shopping_cart.php that I propose is (two functions, for the rest [ == restore_contents] use the instructions of OTF):

	function add_cart($products_id, $qty = '1', $attributes = '', $notify = true) {
  global $new_products_id_in_cart, $customer_id;

  $products_id_string = tep_get_uprid($products_id, $attributes);
  $products_id = tep_get_prid($products_id_string);

  $attributes_pass_check = true;

  if (is_array($attributes)) {
	reset($attributes);
			$change_products_id = 0;
	while (list($option, $value) = each($attributes)) {
				// Option Type Feature 1.7.2: let text attributes pass
				if (strstr($option, TEXT_PREFIX)) { 
					if (trim($value) == NULL) {
						// remove empty text attributes
						unset($attributes[$option]);
					}
				continue; 
				} // end if (strstr($option, TEXT_PREFIX))
	  if (!is_numeric($option) || !is_numeric($value)) {
		$attributes_pass_check = false;
		break;
	  }
	}
  }
// since empty attribute values have been deleted make the $products_id_string again
			$products_id_string = tep_get_uprid($products_id, $attributes);

  if (is_numeric($products_id) && is_numeric($qty) && ($attributes_pass_check == true)) {
	$check_product_query = tep_db_query("select products_status from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
	$check_product = tep_db_fetch_array($check_product_query);

	if (($check_product !== false) && ($check_product['products_status'] == '1')) {
	  if ($notify == true) {
		$new_products_id_in_cart = $products_id_string;
		tep_session_register('new_products_id_in_cart');
	  }

	  if ($this->in_cart($products_id_string)) {
		$this->update_quantity($products_id, $qty, $attributes);
	  } else {
					// BOF Option Type Feature, old osC
					// $this->contents[] = array($products_id);
					// EOF Option Type Feature
		$this->contents[$products_id_string] = array('qty' => $qty);
// insert into database
		if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id_string) . "', '" . (int)$qty . "', '" . date('Ymd') . "')");

		if (is_array($attributes)) {
		  reset($attributes);
	  while (list($option, $value) = each($attributes)) {
		//CLR 020606 check if input was from text box.  If so, store additional attribute information
		//CLR 020708 check if text input is blank, if so do not add to attribute lists
		//CLR 030228 add htmlspecialchars processing.  This handles quotes and other special chars in the user input.
		  $attr_value = NULL;
		  $blank_value = FALSE;
		  if (strstr($option, TEXT_PREFIX)) {
			if (trim($value) == NULL)
			  {
				$blank_value = TRUE;
			 } else {
				$option = substr($option, strlen(TEXT_PREFIX));
				$attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES);
				$value = PRODUCTS_OPTIONS_VALUE_TEXT_ID;
				$this->contents[$products_id_string]['attributes_values'][$option] = $attr_value;
			  }
			}

			if (!$blank_value)
			{
		  $this->contents[$products_id_string]['attributes'][$option] = $value;
// insert into database
			//CLR 020606 update db insert to include attribute value_text. This is needed for text attributes.
			//CLR 030228 add tep_db_input() processing
			  if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id, products_options_value_text) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id_string) . "', '" . (int)$option . "', '" . (int)$value . "', '" . tep_db_input($attr_value) . "')");
			}
		  }
		}
	  }

	  $this->cleanup();

// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure
	  $this->cartID = $this->generate_cart_id();
	}
  }
}

function update_quantity($products_id, $quantity = '', $attributes = '') {
  global $customer_id;

  $products_id_string = tep_get_uprid($products_id, $attributes);
  $products_id = tep_get_prid($products_id_string);

  $attributes_pass_check = true;

  if (is_array($attributes)) {
	reset($attributes);
	while (list($option, $value) = each($attributes)) {
				// Option Type Feature 1.7.2: let text attributes pass
				if (strstr($option, TEXT_PREFIX)) { continue; }
	  if (!is_numeric($option) || !is_numeric($value)) {
		$attributes_pass_check = false;
		break;
	  }
	}
  }

  if (is_numeric($products_id) && isset($this->contents[$products_id_string]) && is_numeric($quantity) && ($attributes_pass_check == true)) {

	$this->contents[$products_id_string] = array('qty' => $quantity);
// update database
	if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . (int)$quantity . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id_string) . "'");

	if (is_array($attributes)) {
	  reset($attributes);
	  while (list($option, $value) = each($attributes)) {
				// BOF Option Type Feature, reversing of products_id and $products_id_string as in the original
				// contribution (version 1.7.2 at least) is not added here
	  //CLR 020606 check if input was from text box.  If so, store additional attribute information
	  //CLR 030108 check if text input is blank, if so do not update attribute lists
	  //CLR 030228 add htmlspecialchars processing.  This handles quotes and other special chars in the user input.
	  $attr_value = NULL;
	  $blank_value = FALSE;
	  if (strstr($option, TEXT_PREFIX)) {
		if (trim($value) == NULL)
		{
		  $blank_value = TRUE;
		} else {
		  $option = substr($option, strlen(TEXT_PREFIX));
		  $attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES);
		  $value = PRODUCTS_OPTIONS_VALUE_TEXT_ID;
		  $this->contents[$products_id_string]['attributes_values'][$option] = $attr_value;
		}
	  }

	  if (!$blank_value) {
		$this->contents[$products_id_string]['attributes'][$option] = $value;
// update database
		if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " set products_options_value_id = '" . (int)$value . "', products_options_value_text = '" . tep_db_input($attr_value) . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id_string) . "' and products_options_id = '" . (int)$option . "'");
				  } // end if (!$blank_value) EOF Option Type Feature
	  }
	}
  }
}

Share this post


Link to post
Share on other sites

What about getting the original author to update the instructions? I just can't seem to figure it out and I tried to send him/her a personal message and this system would not let me.

 

 

It can work, but the code needs to be changed for the update. I had the challenge recently of mixing an update of SPPC with Option Type Feature and boy what a headache.

 

Maybe you can use this (I think I cleaned it from the SPPC code in there, no guarantees). I made an additional change to not let empty attribute values (so input fields that have nothing in them still end up in the products_id) get into the products_id string. Only a small, but crucial change is needed for that in /catalog/includes/functions/general.php. The function tep_get_uprid is changed to allow the add_cart from product_info.php to update the product quantity when any text attributes have been left empty. In this "version" of OTF empty text attributes are *not* appended to the products_id and also do not end up in the database. This is different from the standard Option Type Feature.

  function tep_get_uprid($prid, $params) {
$uprid = $prid;
if ( (is_array($params)) && (!strstr($prid, '{')) ) {
  while (list($option, $value) = each($params)) {
			if ($value == '') { continue; } 
			// because empty text attributes will not be added to the products_id_string
			// we need to get rid of them here when application_top is doing add_product and is looking
			// for the quantity of the product with attributes
	//CLR 030714 Add processing around $value. This is needed for text attributes.
	$uprid = $uprid . '{' . $option . '}' . htmlspecialchars(stripslashes(trim($value)), ENT_QUOTES);
  }
//CLR 030228 Add else stmt to process product ids passed in by other routines.
} else {
  $uprid = htmlspecialchars(stripslashes($uprid), ENT_QUOTES);
}
return $uprid;
 }

The code for the includes/classes/shopping_cart.php that I propose is (two functions, for the rest [ == restore_contents] use the instructions of OTF):

	function add_cart($products_id, $qty = '1', $attributes = '', $notify = true) {
  global $new_products_id_in_cart, $customer_id;

  $products_id_string = tep_get_uprid($products_id, $attributes);
  $products_id = tep_get_prid($products_id_string);

  $attributes_pass_check = true;

  if (is_array($attributes)) {
	reset($attributes);
			$change_products_id = 0;
	while (list($option, $value) = each($attributes)) {
				// Option Type Feature 1.7.2: let text attributes pass
				if (strstr($option, TEXT_PREFIX)) { 
					if (trim($value) == NULL) {
						// remove empty text attributes
						unset($attributes[$option]);
					}
				continue; 
				} // end if (strstr($option, TEXT_PREFIX))
	  if (!is_numeric($option) || !is_numeric($value)) {
		$attributes_pass_check = false;
		break;
	  }
	}
  }
// since empty attribute values have been deleted make the $products_id_string again
			$products_id_string = tep_get_uprid($products_id, $attributes);

  if (is_numeric($products_id) && is_numeric($qty) && ($attributes_pass_check == true)) {
	$check_product_query = tep_db_query("select products_status from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
	$check_product = tep_db_fetch_array($check_product_query);

	if (($check_product !== false) && ($check_product['products_status'] == '1')) {
	  if ($notify == true) {
		$new_products_id_in_cart = $products_id_string;
		tep_session_register('new_products_id_in_cart');
	  }

	  if ($this->in_cart($products_id_string)) {
		$this->update_quantity($products_id, $qty, $attributes);
	  } else {
					// BOF Option Type Feature, old osC
					// $this->contents[] = array($products_id);
					// EOF Option Type Feature
		$this->contents[$products_id_string] = array('qty' => $qty);
// insert into database
		if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id_string) . "', '" . (int)$qty . "', '" . date('Ymd') . "')");

		if (is_array($attributes)) {
		  reset($attributes);
	  while (list($option, $value) = each($attributes)) {
		//CLR 020606 check if input was from text box.  If so, store additional attribute information
		//CLR 020708 check if text input is blank, if so do not add to attribute lists
		//CLR 030228 add htmlspecialchars processing.  This handles quotes and other special chars in the user input.
		  $attr_value = NULL;
		  $blank_value = FALSE;
		  if (strstr($option, TEXT_PREFIX)) {
			if (trim($value) == NULL)
			  {
				$blank_value = TRUE;
			 } else {
				$option = substr($option, strlen(TEXT_PREFIX));
				$attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES);
				$value = PRODUCTS_OPTIONS_VALUE_TEXT_ID;
				$this->contents[$products_id_string]['attributes_values'][$option] = $attr_value;
			  }
			}

			if (!$blank_value)
			{
		  $this->contents[$products_id_string]['attributes'][$option] = $value;
// insert into database
			//CLR 020606 update db insert to include attribute value_text. This is needed for text attributes.
			//CLR 030228 add tep_db_input() processing
			  if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id, products_options_value_text) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id_string) . "', '" . (int)$option . "', '" . (int)$value . "', '" . tep_db_input($attr_value) . "')");
			}
		  }
		}
	  }

	  $this->cleanup();

// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure
	  $this->cartID = $this->generate_cart_id();
	}
  }
}

function update_quantity($products_id, $quantity = '', $attributes = '') {
  global $customer_id;

  $products_id_string = tep_get_uprid($products_id, $attributes);
  $products_id = tep_get_prid($products_id_string);

  $attributes_pass_check = true;

  if (is_array($attributes)) {
	reset($attributes);
	while (list($option, $value) = each($attributes)) {
				// Option Type Feature 1.7.2: let text attributes pass
				if (strstr($option, TEXT_PREFIX)) { continue; }
	  if (!is_numeric($option) || !is_numeric($value)) {
		$attributes_pass_check = false;
		break;
	  }
	}
  }

  if (is_numeric($products_id) && isset($this->contents[$products_id_string]) && is_numeric($quantity) && ($attributes_pass_check == true)) {

	$this->contents[$products_id_string] = array('qty' => $quantity);
// update database
	if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . (int)$quantity . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id_string) . "'");

	if (is_array($attributes)) {
	  reset($attributes);
	  while (list($option, $value) = each($attributes)) {
				// BOF Option Type Feature, reversing of products_id and $products_id_string as in the original
				// contribution (version 1.7.2 at least) is not added here
	  //CLR 020606 check if input was from text box.  If so, store additional attribute information
	  //CLR 030108 check if text input is blank, if so do not update attribute lists
	  //CLR 030228 add htmlspecialchars processing.  This handles quotes and other special chars in the user input.
	  $attr_value = NULL;
	  $blank_value = FALSE;
	  if (strstr($option, TEXT_PREFIX)) {
		if (trim($value) == NULL)
		{
		  $blank_value = TRUE;
		} else {
		  $option = substr($option, strlen(TEXT_PREFIX));
		  $attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES);
		  $value = PRODUCTS_OPTIONS_VALUE_TEXT_ID;
		  $this->contents[$products_id_string]['attributes_values'][$option] = $attr_value;
		}
	  }

	  if (!$blank_value) {
		$this->contents[$products_id_string]['attributes'][$option] = $value;
// update database
		if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " set products_options_value_id = '" . (int)$value . "', products_options_value_text = '" . tep_db_input($attr_value) . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id_string) . "' and products_options_id = '" . (int)$option . "'");
				  } // end if (!$blank_value) EOF Option Type Feature
	  }
	}
  }
}

Share this post


Link to post
Share on other sites

I want to increase the height of the textarea,no matter how to change number in the 'rows=x',the textarea remain unchanged.

How to fix it?

Share this post


Link to post
Share on other sites
Hello Paul,

 

Did you find the solution ?

Because I have the same bug ...

 

Thanks a lot

 

Thierry

 

 

Options attributes sort:

 

I have found this solution to work for me in the customer history area. I'm sure that the exact same thing will work on the admin side:

 

In /catalog/includes/classes/order.php

 

Change this:(approx. line 115)

$attributes_query = tep_db_query("select products_options, products_options_values, options_values_price, price_prefix from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$order_id . "' and orders_products_id = '" . (int)$orders_products['orders_products_id'] . "'");

 

 

To this:

$attributes_query = tep_db_query("select popt.products_options, popt.products_options_values, popt.options_values_price, popt.price_prefix, popr.products_options_id from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " popt, " . TABLE_PRODUCTS_OPTIONS . " popr where popt.orders_id = '" . (int)$order_id . "' and popt.orders_products_id = '" . (int)$orders_products['orders_products_id'] . "' and popr.products_options_name = popt.products_options");

 

 

After doing this, you can verify in the customers order history. This will sort by product options id(The order in which you set up options on the admin side).

 

Now I'll be the first to admit that I'm not a SQL guru, so make sure you backup your file before trying this.

On the admin side there is an order.php in /catalog/admin/includes/classes and the process should be identical.


Troy Wilson

Keepsake-storybooks.com

Share this post


Link to post
Share on other sites

I am having a very hard time adding a text attribute.

 

Every time I do, it ends up a drop down....Help please!!

Edited by offnetrob

Share this post


Link to post
Share on other sites

I tried to use the javascript contribution for making the text boxes required but I could not really figure it out. Can anyone help me with making 2 textbox fields required??

Share this post


Link to post
Share on other sites

I hope that someone can spare me 5 mins to answer a quick question for me regarding this contribution.

 

We added the Option Type Feature to an online greeting card store so that customers could enter the text that they want to appear on their cards. It all seemed to work fine when we tested it and the site has been live for a while now.

 

However, what has been noticed is that a customer cannot purchase two versions of the same card and add seperate greetings for each card. The customer can only edit the greeting.

 

Is this how the contribution is designed to work or have we done something wrong with the installation? If it is the latter, then I have some work to do...

Share this post


Link to post
Share on other sites
However, what has been noticed is that a customer cannot purchase two versions of the same card and add seperate greetings for each card. The customer can only edit the greeting.

 

Is this how the contribution is designed to work or have we done something wrong with the installation? If it is the latter, then I have some work to do...

No, that is not the way the contribution is designed. Since the text that was typed in is added as an attribute to the products_id string, for example {text_7}text_that_was_added, different text makes a different product so it shouldn't be a problem.

Share this post


Link to post
Share on other sites
Since the text that was typed in is added as an attribute to the products_id string, for example {text_7}text_that_was_added, different text makes a different product so it shouldn't be a problem.

 

Many thanks for letting me know, this is driving me insane. Do you happen to know where the installation of this contribution might have gone wrong? The contribution was added to a heavily altered site and re-installing to an older version is not an option at this stage.

Share this post


Link to post
Share on other sites

I am using 1.7.2 of this contribution with OScommerce 2.2 MS2. It is working almost perfectly - apart from I also have held orders running - and with this contribution installed the held order is being deleted on checkout confirmation and the actual order not updated. Has anyone else stumbled on this? Is there a known fix?

Share this post


Link to post
Share on other sites
I hope that someone can spare me 5 mins to answer a quick question for me regarding this contribution.

 

We added the Option Type Feature to an online greeting card store so that customers could enter the text that they want to appear on their cards. It all seemed to work fine when we tested it and the site has been live for a while now.

 

However, what has been noticed is that a customer cannot purchase two versions of the same card and add seperate greetings for each card. The customer can only edit the greeting.

 

Is this how the contribution is designed to work or have we done something wrong with the installation? If it is the latter, then I have some work to do...

 

It sounds like you have the Imprint Text Option installed. We were using that until we noticed the exact same problem happening so we switched to the Option Type Feature and it works great so far!

Share this post


Link to post
Share on other sites
Do you happen to know where the installation of this contribution might have gone wrong? The contribution was added to a heavily altered site and re-installing to an older version is not an option at this stage.
The class shopping_cart.php seems the most likely place. Perhaps take a look at application_top.php too (look at the case 'action' code).

 

Perhaps you can try the shopping_cart code I posted on the previous page. Actually, the first part of that post should be changed a bit:

  function tep_get_uprid($prid, $params) {
    $uprid = $prid;
    if ( (is_array($params)) && (!strstr($prid, '{')) ) {
      while (list($option, $value) = each($params)) {
// if people add a space it wouldn't pass here so do a trim
//                if ($value == '') { continue; } 
                if (trim($value) == '') { continue; }

Share this post


Link to post
Share on other sites

Hi,

 

I tried to follow the manual installation instructions for this contribution and seem to have gone wrong somewhere. When I try to go to the Admin tool I get

 

Fatal error: Call to undefined function: tep_get_languages() in D:\cchosting\Dayo\catalog\admin\index.php on line 58

 

I can't figure out where I went wrong. Can anyone point me in the right direction?

 

Thank you!

Share this post


Link to post
Share on other sites
When I try to go to the Admin tool I get

 

Fatal error: Call to undefined function: tep_get_languages() in D:\cchosting\Dayo\catalog\admin\index.php on line 58

 

I can't figure out where I went wrong.

Probably something went wrong when you changed the function tep_get_uprid in admin/includes/functions/general.php. The function tep_get_languages is a few lines further down (around 490). Perhaps a } missing?

 

That section should look like this:

// Return a product ID with attributes
 function tep_get_uprid($prid, $params) {
$uprid = $prid;
if ( (is_array($params)) && (!strstr($prid, '{')) ) {
  while (list($option, $value) = each($params)) {
	//CLR 030714 Add processing around $value. This is needed for text attributes.
	$uprid = $uprid . '{' . $option . '}' . htmlspecialchars(stripslashes(trim($value)), ENT_QUOTES);
  }
//CLR 030228 Add else stmt to process product ids passed in by other routines.
} else {
  $uprid = htmlspecialchars(stripslashes($uprid), ENT_QUOTES);
}
return $uprid;
 }

 function tep_get_prid($uprid) {
$pieces = explode('{', $uprid);

return $pieces[0];
 }

 function tep_get_languages() {
$languages_query = tep_db_query("select languages_id, name, code, image, directory from " . TABLE_LANGUAGES . " order by sort_order");
while ($languages = tep_db_fetch_array($languages_query)) {
  $languages_array[] = array('id' => $languages['languages_id'],
							 'name' => $languages['name'],
							 'code' => $languages['code'],
							 'image' => $languages['image'],
							 'directory' => $languages['directory']);
}

return $languages_array;
 }

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×