Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Product Attributes - Option Type Feature v1.3


Guest

Recommended Posts

First let me say I love this contribution and that I really appreciate the creation of it.

 

I have installed Option Type Feature v. 2.0.1 (Complete Package)

 

http://www.oscommerce.com/community/contributions,160

 

both using the manual instruction on my current working installation of osCommerce and as a drop in on a clean installation of 2.2 as control.

 

My problem is that is the Attribute Option Type is set to text area, the contents are lost when the Shopping Cart is updated OR when the shopping cart attemps to pass the value on to payment processing ( in this case Google Checkout ). This is not the case with other Attribute Option Types.

 

 

It looks like I'm having the same problem that was described as fixed in:

 

Textarea remember attributes bigjat69 7 Aug 2007

 

( Which I assumed was included in the Option Type Feature v. 2.0.1 (Complete Package) - but which I have also attempted to install manually. It does seem that the problem is somewhere in product_info.php (which I have included below). Any help is much appreciated.

 

<?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>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<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')
}
// BOF Product Type Feature
/* 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)+"%)";
}
// EOF Product Type Feature
//--></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_DEFAULT) . '">' . 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 {
$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 . "'");
$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'])) {
  $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($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>';
} 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 class="pageHeading" valign="top"><?php echo $products_name; ?></td>
		<td class="pageHeading" align="right" valign="top"><?php echo $products_price; ?></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">
<script language="javascript"><!--
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>'; ?>');
//--></script>
<noscript>
<?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>'; ?>
</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
  // BOF Option Type Feature
  //$products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name 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)) {

  $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'] . ']" 
							   >' . $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;

  // EOF Option Type Feature 
	$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 
			// BOF Option Type Feature
			//echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute);
			echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array,   $selected_attribute) . $products_options_name['products_options_comment'];
			// EOF Option Type Feature
			?></td>
		</tr>
<?php
	// BOF Option Type Feature
	} // ends the switch clause
	// EOF Option Type Feature
  } 
  ?>
	  </table>
<?php
}
?>
	</td>
  </tr>
  <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'); ?>

Link to comment
Share on other sites

  • Replies 74
  • Created
  • Last Reply

Top Posters In This Topic

I may have slightly mis-stated my problem. It looks like none of the OTF values make it through an update but that all of them but the text area ones are sent on to Google Checkout. Really the only thing I'm trying to fix right now is the passing to the Google Checkout of the text-area values.

 

 

I am using the Google Checkout contribution:

 

 

http://code.google.com/p/google-checkout-oscommerce/

 

 

I'm nolonger sure the problem is in product_info (though that may be the problem with updating). There's an additional file in the Google Checkout package called gcheckout:

 

 

<?php
/*
 Copyright © 2007 Google Inc.

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

/* **GOOGLE CHECKOUT ** v1.4.5
* @version $Id: gcheckout.php 5499 2007-09-27 14:58:57Z ropu $
* Script invoked when Google Checkout payment option has been enabled
* It uses phpGCheckout library so it can work with PHP4 and PHP5
* Generates the cart xml, shipping and tax options and adds them as hidden fields
* along with the Checkout button

* A disabled button is displayed in the following cases:
* 1. If merchant id or merchant key is not set 
* 2. If there are multiple shipping options selected and they use different shipping tax tables
*  or some dont use tax tables
*/
//error_reporting(E_ALL);
//require_once('admin/includes/configure.php');
//require_once('includes/configure.php');
require_once('includes/languages/'. $language .'/modules/payment/googlecheckout.php');
require_once('includes/modules/payment/googlecheckout.php');

// Function which returns the current URL.
function gc_selfURL() {
$s = empty($_SERVER['HTTPS']) ? '' : ($_SERVER['HTTPS'] == 'on') ? 's' : '';
$protocol = gc_strleft(strtolower($_SERVER['SERVER_PROTOCOL']), '/') . $s;
$port = ($_SERVER['SERVER_PORT'] == '80') ? '' : (':'. $_SERVER['SERVER_PORT']);
return $protocol . '://' . $_SERVER['SERVER_NAME'] . $port . $_SERVER['REQUEST_URI'];
}

// Used by selfURL.
function gc_strleft($s1, $s2) {
return substr($s1, 0, strpos($s1, $s2));
}

// Functions used to prevent SQL injection attacks.
function gc_makeSqlString($str) {
return addcslashes(stripcslashes($str), "\"'\\..\37!@\@\177..\377");
}

function gc_makeSqlInteger($val) {
return ((settype($val, 'integer')) ? ($val) : 0);
}

function gc_makeSqlFloat($val) {
return ((settype($val, 'float')) ? ($val) : 0);
}

// Custom Function to store configuration values (shipping default values)  
function gc_compare($key, $data, $sep="_VD:", $def_ret='1')
{
 foreach($data as $value) {
   list($key2, $valor) = explode($sep, $value);
   if($key == $key2)   
     return $valor;
 }
 return $def_ret;
}

$googlepayment = new googlecheckout();
$total_weight = $cart->show_weight();
$total_count = $cart->count_contents();

require('googlecheckout/library/googlecart.php');
require('googlecheckout/library/googleitem.php');
require('googlecheckout/library/googleshipping.php');
require('googlecheckout/library/googletax.php');

$Gcart = new googlecart($googlepayment->merchantid,
                       $googlepayment->merchantkey,  
                       MODULE_PAYMENT_GOOGLECHECKOUT_MODE==
                         'https://sandbox.google.com/checkout/'
                         ?"sandbox":"production",
                       DEFAULT_CURRENCY);
$Gwarnings = array();
if(MODULE_PAYMENT_GOOGLECHECKOUT_MODE=='https://sandbox.google.com/checkout/'){
 $Gwarnings[] = GOOGLECHECKOUT_STRING_WARN_USING_SANDBOX;
}
// Check installed Version
if(MODULE_PAYMENT_GOOGLECHECKOUT_VERSION != GOOGLECHECKOUT_FILES_VERSION) {
 $Gcart->SetButtonVariant(false);
 $Gwarnings[] = sprintf(GOOGLECHECKOUT_STRING_WARN_MIX_VERSIONS, 
                         MODULE_PAYMENT_GOOGLECHECKOUT_VERSION, 
                         GOOGLECHECKOUT_FILES_VERSION);
}

if (($googlepayment->merchantid == '') || ($googlepayment->merchantkey == '')) {
 $Gcart->SetButtonVariant(false);
 $Gwarnings[] = GOOGLECHECKOUT_STRING_WARN_NO_MERCHANT_ID_KEY;
}

$products = $cart->get_products();
require_once(DIR_WS_CLASSES . 'order.php');
$order = new order;
$order_items = $order->products;

if(MODULE_PAYMENT_GOOGLECHECKOUT_VIRTUAL_GOODS == 'True' 
             && $cart->get_content_type() != 'physical' ) {
 $Gcart->SetButtonVariant(false);
 $Gwarnings[] = GOOGLECHECKOUT_STRING_WARN_VIRTUAL;
} 

if (sizeof($products) == 0) {
 $Gcart->SetButtonVariant(false);
 $Gwarnings[] = GOOGLECHECKOUT_STRING_WARN_EMPTY_CART;
}

$tax_array = array();
$tax_name_array = array();
$flagAnyOutOfStock = false;
$product_list = '';
$resticted_categories = split('([ ]?[,][ ]?)',MODULE_PAYMENT_GOOGLECHECKOUT_RESTRICTED_CATEGORIES);
for ($i = 0, $n = sizeof($products); $i < $n; $i++) {
 $product_virtual = false;  
if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
	while (list($option, $value) = each($products[$i]['attributes'])) {
		$attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, "
								              ."pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS
                               ." popt, ". TABLE_PRODUCTS_OPTIONS_VALUES ." poval, ". TABLE_PRODUCTS_ATTRIBUTES
                               ." pa where pa.products_id = '" . gc_makeSqlInteger($products[$i]['id']) . "' "
								              ."and pa.options_id = '" . gc_makeSqlString($option) . "' and pa.options_id = "
                               ."popt.products_options_id and pa.options_values_id = '" . gc_makeSqlString($value) . "' "
								              ."and pa.options_values_id = poval.products_options_values_id and "
                               ."popt.language_id = '" . $languages_id . "' and poval.language_id = '" 
                               . $languages_id . "'");
		$attributes_values = tep_db_fetch_array($attributes);
		$attr_value = $attributes_values['products_options_values_name'];
		$products[$i][$option]['products_options_name'] = $attributes_values['products_options_name'];
		$products[$i][$option]['options_values_id'] = $value;
		$products[$i][$option]['products_options_values_name'] = $attr_value;
		$products[$i][$option][' products_options_value_text text'] = $attr_value;
		$products[$i][$option]['options_values_price'] = $attributes_values['options_values_price'];
		$products[$i][$option]['price_prefix'] = $attributes_values['price_prefix'];
     if(DOWNLOAD_ENABLED == 'true') {
       $virtual_check_query = tep_db_query("select count(*) as total from " . 
                                TABLE_PRODUCTS_ATTRIBUTES . " pa, " . 
                                TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . 
                                " pad where pa.products_id = '" . (int)$products[$i]['id'] . 
                                "' and pa.options_values_id = '" . (int)$value . 
                                "' and pa.products_attributes_id = pad.products_attributes_id");
       $virtual_check = tep_db_fetch_array($virtual_check_query);
       if ($virtual_check['total'] > 0){
         $product_virtual = true;
       }
     }
    }
}
$products_name = $products[$i]['name'];
$products_description = tep_db_fetch_array(tep_db_query("select products_description from "
                          . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . $products[$i]['id']
                            ."' and language_id = '" . $languages_id . "'"));
$products_description = $products_description['products_description'];
$tax_result = tep_db_query("select tax_class_title from ". TABLE_TAX_CLASS 
                           ." where tax_class_id = ". gc_makeSqlInteger($products[$i]['tax_class_id']));
$tax = tep_db_fetch_array($tax_result);
$tt = $tax['tax_class_title'];
if (!empty($tt) && !in_array($products[$i]['tax_class_id'], $tax_array)) {
	$tax_array[] = $products[$i]['tax_class_id'];
	$tax_name_array[] = $tt;
}
if (isset ($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
	reset($products[$i]['attributes']);
	while (list($option, $value) = each($products[$i]['attributes'])) {
		$products_name .= "\n- ". $products[$i][$option]['products_options_name'] .' '
		                . $products[$i][$option]['products_options_values_name'];
	}
}
 // refactor
 $Gitem = new GoogleItem($products_name,
                         $products_description,
                         $products[$i]['quantity'], 
                         $currencies->get_value(DEFAULT_CURRENCY) * $products[$i]['final_price'],
                                      'LB', $products[$i]['weight']);                          
//                          $currencies->get_value(DEFAULT_CURRENCY) * $products[$i]['final_price']);
 $Gitem->SetMerchantPrivateItemData(
         new MerchantPrivateItemData(array(
//                              'item_old' =>  base64_encode(serialize($products[$i])),
                               'item' =>
                               base64_encode(serialize($order_items[$i])))));


 $Gitem->SetMerchantItemId($products[$i]['id']);
 if(!empty($tt)) {
   $Gitem->SetTaxTableSelector($tt);
 }
 if($product_virtual) {
   $digital_url = str_replace("&", "&", 
                              tep_href_link('checkout_success.php'));
   $Gitem->SetURLDigitalContent($digital_url, '', $products_name . " " .
                                                  $products_description . "<br />".
                                                  GOOGLECHECKOUT_STRING_EXTRA_DIGITAL_CONTENT);
 }
 $Gcart->AddItem($Gitem);
// Stock Check
 if (STOCK_CHECK == 'true') {
   if (tep_check_stock($products[$i]['id'], $products[$i]['quantity'])) {
     $flagAnyOutOfStock = true;
   }
 }
 $product_list .= ";".(int)$products[$i]['id'];  
 $category_id = tep_db_fetch_array(tep_db_query("select categories_id from " . 
                          TABLE_PRODUCTS_TO_CATEGORIES . 
                          " where products_id = '" . (int)$products[$i]['id']  ."'"));

 if(in_array($category_id['categories_id'], $resticted_categories)) {
   $Gcart->SetButtonVariant(false);
   $Gwarnings[] = GOOGLECHECKOUT_STRING_WARN_RESTRICTED_CATEGORY;
   break;
 }
}
// Coustom Order Totals

require_once(DIR_WS_CLASSES . 'order_total.php');
$order_total_modules = new order_total();
$order_totals = $order_total_modules->process();

$ot_used = false;
foreach($order_totals as $order_total){
 if(!in_array($order_total['code'], $googlepayment->ot_ignore)){

// Cant used this since the OT is passed as an item, and tax cant be calculated
   $tax_class_id = @constant("MODULE_ORDER_TOTAL_" . substr(strtoupper($order_total['code']), 3) . "_TAX_CLASS");
   $tax =  tep_db_fetch_array(tep_db_query("select tax_class_title 
                        from " . TABLE_TAX_CLASS . " 
                        where tax_class_id = " . 
                        (int)$tax_class_id ));
   $tt = @$tax['tax_class_title'];
   if(!empty($tt) && !in_array($tax_class_id, $tax_array)) {
     $tax_array[] = $tax_class_id;
     $tax_name_array[] = $tt;
   }
   $ot_value = $order_total['value'] * (strrpos($order_total['text'], '-')===false?1:-1);//($order_total['text']{0}=='-'?-1:1);
   $Gitem = new GoogleItem($order_total['title'],
                           '',
                           '1', 
                           $currencies->get_value(DEFAULT_CURRENCY) * $products[$i]['final_price'],
                           'LB', 0);                          

////                            number_format(($amount) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency))
//                            $currencies->get_value(DEFAULT_CURRENCY) * $ot_value);
   $Gitem->SetMerchantPrivateItemData(
           new MerchantPrivateItemData(array('order_total' =>
                            base64_encode(serialize($order_total)))));
   if(!empty($tt)) {
     $Gitem->SetTaxTableSelector($tt);
   }
// TaxTable with 0% Rate
//    $Gitem->SetTaxTableSelector('_OT_cero_tax');

//  This is a hack to avoid showing shipping when cart is virtual and an OT is added
   if(DOWNLOAD_ENABLED == 'true' && $cart->get_content_type() == 'virtual') {
     $Gitem->SetEmailDigitalDelivery('true');
   }

   $Gcart->AddItem($Gitem);
   $ot_used = true;
 }
}

//if($ot_used) {
//  $GAtaxTable_OT = new GoogleAlternateTaxTable('_OT_cero_tax');
//  $GAtaxRule = new GoogleAlternateTaxRule('0');
//  $GAtaxRule->SetWorldArea();
//  $GAtaxTable_OT->AddAlternateTaxRules($GAtaxRule);
//  $Gcart->AddAlternateTaxTables($GAtaxTable_OT);  
//}
// Out of Stock
if ( (STOCK_ALLOW_CHECKOUT != 'true') && ($flagAnyOutOfStock == true) ) {
 $Gcart->SetButtonVariant(false);
 $Gwarnings[] = GOOGLECHECKOUT_STRING_WARN_OUT_OF_STOCK;
}

$private_data = tep_session_id() .';'. tep_session_name();
$Gcart->SetMerchantPrivateData(
              new MerchantPrivateData(array('session-data' => $private_data)));
$Gcart->AddRoundingPolicy(MODULE_PAYMENT_GOOGLECHECKOUT_TAXMODE, 
                         MODULE_PAYMENT_GOOGLECHECKOUT_TAXRULE);
$continue_shopping_url = ($googlepayment->continue_url=='gc_return.php')?
                     $googlepayment->continue_url . '?products_id=' . 
                     implode(',', explode(';', !empty($product_list)?
                     trim($product_list,';'):'-1')):$googlepayment->continue_url;
$Gcart->SetEditCartUrl(tep_href_link('shopping_cart.php'));
$Gcart->SetContinueShoppingUrl(tep_href_link($continue_shopping_url));
$Gcart->SetRequestBuyerPhone('true');

if(MODULE_PAYMENT_GOOGLECHECKOUT_EXPIRATION != 'NONE') {
//  2007-12-31T11:59:59-05:00
 $Gcart->SetCartExpiration(date('Y-m-d\TH:i:s\Z', time() 
           + MODULE_PAYMENT_GOOGLECHECKOUT_EXPIRATION*60 - date('Z', time())));
}
//Shipping options
$tax_class = array ();
$shipping_arr = array ();
$tax_class_unique = array ();

if(DOWNLOAD_ENABLED != 'true' || $cart->get_content_type() != 'virtual') {
 $options = explode(", ", MODULE_PAYMENT_GOOGLECHECKOUT_SHIPPING);
 // Get the properties of the shipping methods.
 $module_directory = DIR_FS_CATALOG . DIR_WS_MODULES . 'shipping/';
 if(!file_exists($module_directory)) {
   $Gcart->SetButtonVariant(false);
   $Gwarnings[] = sprintf(GOOGLECHECKOUT_STRING_WARN_WRONG_SHIPPING_CONFIG, $module_directory);
 }  

 $file_extension = substr($PHP_SELF, strrpos($PHP_SELF, '.'));
 $directory_array = array();
 if ($dir = @ dir($module_directory)) {
 	while ($file = $dir->read()) {
 		if (!is_dir($module_directory . $file)) {
 			if (substr($file, strrpos($file, '.')) == $file_extension) {
 				$directory_array[] = $file;
 			}
 		}
 	}
 	sort($directory_array);
 	$dir->close();
 }

 $check_query = tep_db_fetch_array(tep_db_query("select countries_iso_code_2 
                              from " . TABLE_COUNTRIES . " 
                              where countries_id = 
                              '" . SHIPPING_ORIGIN_COUNTRY . "'"));
 $shipping_origin_iso_code_2 = $check_query['countries_iso_code_2'];

 $module_info = array();
 $module_info_enabled = array();
 for ($i = 0, $n = sizeof($directory_array); $i < $n; $i++) {
 	$file = $directory_array[$i];

 	include_once (DIR_FS_CATALOG .DIR_WS_LANGUAGES . $language . '/modules/shipping/' . $file);
 	include_once ($module_directory . $file);

 	$class = substr($file, 0, strrpos($file, '.'));
 	$module = new $class;
   $curr_ship = strtoupper($module->code);
   switch($curr_ship){
     case 'FEDEXGROUND':
       $curr_ship = 'FEDEX_GROUND';
       break; 
     case 'FEDEXEXPRESS':
       $curr_ship = 'FEDEX_EXPRESS';
       break; 
     case 'UPSXML':
       $curr_ship = 'UPSXML_RATES';
       break; 
     case 'DHLAIRBORNE':
       $curr_ship = 'AIRBORNE';
       break; 
     default:
       break;
   }
  	if (@constant('MODULE_SHIPPING_' . $curr_ship . '_STATUS') == 'True') {
 	  $module_info_enabled[$module->code] = array('enabled' => true);
 	}
 	if ($module->check() == true) {
 		$module_info[$module->code] = array(
       'code' => $module->code,
 			'title' => $module->title,
 			'description' => $module->description,
 			'status' => $module->check());
 	}
 }

// check if there is a shipping module activated that is not flat rate
 // to enable Merchan Calculations
 // if there are flat and MC, both will be MC
 $ship_calculation_mode = MODULE_PAYMENT_GOOGLECHECKOUT_CARRIER_CALCULATED_ENABLED=='True'?false:
                         (count(array_keys($module_info_enabled)) 
                         > count(array_intersect($googlepayment->shipping_support
                         , array_keys($module_info_enabled)))) ? true : false;

 $key_values = explode(", ", MODULE_PAYMENT_GOOGLECHECKOUT_SHIPPING);
 $shipping_config_errors = '';
 $free_shipping = false;
 foreach ($module_info as $key => $value) {
 	// Check if the shipping method is activated.
 	$module_name = $module_info[$key]['code'];
 	$curr_ship = strtoupper($module_name);
   switch($curr_ship){
     case 'FEDEXGROUND':
       $curr_ship = 'FEDEX_GROUND';
       break; 
     case 'FEDEXEXPRESS':
       $curr_ship = 'FEDEX_EXPRESS';
       break; 
     case 'UPSXML':
       $curr_ship = 'UPSXML_RATES';
       break; 
     case 'DHLAIRBORNE':
       $curr_ship = 'AIRBORNE';
       break; 
     default:
       break;
   }

   $common_string = "MODULE_SHIPPING_" . $curr_ship . "_";
   @$zone =  constant($common_string . "ZONE");
   @$enable =  constant($common_string . "STATUS");
   @$curr_tax_class =  constant($common_string . "TAX_CLASS");
   @$price =  constant($common_string . "COST");
   @$handling =  constant($common_string . "HANDLING");
   @$table_mode =  constant($common_string . "MODE");

   $allowed_restriction_state = $allowed_restriction_country = array();
   // Exception for enabling shipping modules
   if(defined('MODULE_SHIPPING_FREESHIPPER_STATUS') 
       && MODULE_SHIPPING_FREESHIPPER_STATUS == "True"){
     switch ($curr_ship) {
       case 'FREESHIPPER':
         if($cart->free_shipping_items() != $cart->count_contents()){
           $enable = "False";
           unset($module_info_enabled['freeshipper']);
         }
         else {
           $enable = "True";
           $free_shipping = true;
         }
         break;
       default:
         if($cart->free_shipping_items() == $cart->count_contents()){
           $enable = "False";
           unset($module_info_enabled['freeshipper']);
         }
         break;
     }
   }

   //    Disable any merchant-calculation module if Carrier calculated is enabled
 //    This will allow only flat-rate shippings
   if(MODULE_PAYMENT_GOOGLECHECKOUT_CARRIER_CALCULATED_ENABLED == 'True'
       && !in_array($module_name, $googlepayment->shipping_support)){
     $enable = 'False';
     unset($module_info_enabled['freeshipper']);
   }
   if ($enable == "True") {
   	if ($zone != '') {
   		$zone_result = tep_db_query("SELECT countries_name, coalesce(zone_code, 'All Areas') zone_code, countries_iso_code_2
                                     FROM " . TABLE_GEO_ZONES . " AS gz
                                     inner join ". TABLE_ZONES_TO_GEO_ZONES ." AS ztgz on gz.geo_zone_id = ztgz.geo_zone_id
                                     inner join ". TABLE_COUNTRIES ." AS c on ztgz.zone_country_id = c.countries_id
                                     left join ". TABLE_ZONES ." AS z on ztgz.zone_id = z.zone_id
                                     WHERE gz.geo_zone_id = '". $zone ."'");


   		$allowed_restriction_state = $allowed_restriction_country = array();
   		// Get all the allowed shipping zones.
   		while($zone_answer = tep_db_fetch_array($zone_result)) {
   			$allowed_restriction_state[] = $zone_answer['zone_code'];
   			$allowed_restriction_country[] = array($zone_answer['countries_name'], $zone_answer['countries_iso_code_2']);
   		}
   	}

   	if ($curr_tax_class != 0 && $curr_tax_class != '') {
   		$tax_class[] = $curr_tax_class;
   		if (!in_array($curr_tax_class, $tax_class_unique))
   			$tax_class_unique[] = $curr_tax_class;
   	}
     if (is_array($googlepayment->mc_shipping_methods[$key])) {
   		foreach($googlepayment->mc_shipping_methods[$key] as $type => $shipping_type){
   			foreach($shipping_type as $method => $name){
           $total_weight = $cart->show_weight();
           $total_count = $cart->count_contents();
   //	['domestic_types']
           $shipping_name = $googlepayment->mc_shipping_methods_names[$module_info[$key]['code']] . ': ' . $name;
   				if(!in_array($module_info[$key]['code'], $googlepayment->shipping_support)) {
             $default_value = gc_compare($module_info[$key]['code'].$method . $type ,$key_values);
             $shipping_price = $currencies->get_value(DEFAULT_CURRENCY) * $default_value;
   				}
   				// flat rate shipping
   				else {
             $default_value = 1;
   					$module = new $module_name;
   					$quote = $module->quote($method);
   					$price = $quote['methods'][0]['cost'];
             $shipping_price = $currencies->get_value(DEFAULT_CURRENCY) * ($price>=0?$price:0);
   				}
           $Gfilter = new GoogleShippingFilters();
           if(MODULE_PAYMENT_GOOGLECHECKOUT_USPOBOX == 'False') {
             $Gfilter->SetAllowUsPoBox('false');
           }
           if(!empty($allowed_restriction_country)){
               foreach($allowed_restriction_state as $state_key => $state) {
                 if($allowed_restriction_country[$state_key][1] == 'US') {
                   if($state == 'All Areas') {
                     $Gfilter->SetAllowedCountryArea('ALL');
                   }
                   else {
                     $Gfilter->AddAllowedStateArea($state);
                   }
                 }
                 else {
                   // TODO here should go the non us area (not implemented in GC)
                   // now just the country
                   $Gfilter->AddAllowedPostalArea($allowed_restriction_country[$state_key][1]);
                 }
               }      
           }
           else {
             switch($type) {
               case 'domestic_types':
                 if('US' == $shipping_origin_iso_code_2) {
                   $Gfilter->SetAllowedCountryArea('ALL');
                 }else{
                   $Gfilter->AddAllowedPostalArea($shipping_origin_iso_code_2);
                 }
                break;
               case 'international_types':
                   $Gfilter->SetAllowedWorldArea(true);
                 if('US' == SHIPPING_ORIGIN_COUNTRY) {
                   $Gfilter->SetExcludedCountryArea('ALL');
                 }else{
                   $Gfilter->AddExcludedPostalArea($shipping_origin_iso_code_2);
                 }
                break;
               default:
               // should never reach here!
                 $Gfilter->SetAllowedWorldArea(true);
                break;
             }
           }
   				if ($ship_calculation_mode == 'True') {
             if($default_value != 0) {    				  
               $Gshipping = new GoogleMerchantCalculatedShipping($shipping_name, $shipping_price);
               $Gshipping->AddShippingRestrictions($Gfilter);
               $Gshipping->AddAddressFilters($Gfilter);
               $Gcart->AddShipping($Gshipping);
             }
           } 
   				else {
             $Gshipping = new GoogleFlatRateShipping($shipping_name, $shipping_price);
             $Gshipping->AddShippingRestrictions($Gfilter);
             $Gcart->AddShipping($Gshipping);
   				}
   			}
   		}
     }
     else {
       $shipping_config_errors .= $key ." (ignored)<br />";
     }
 	}
 }
 if(MODULE_PAYMENT_GOOGLECHECKOUT_CARRIER_CALCULATED_ENABLED == 'True' && !$free_shipping){
   $Gshipping = new GoogleCarrierCalculatedShipping('Carrier_shipping');
   $country_code = defined('SHIPPING_ORIGIN_COUNTRY')?SHIPPING_ORIGIN_COUNTRY:STORE_COUNTRY;
   $zone_name = tep_get_zone_code($country_code, STORE_ZONE, '');
   $countries_array = tep_get_countries(SHIPPING_ORIGIN_COUNTRY, true);
   $ship_from = new GoogleShipFrom('Store_origin',
                                   '',
                                   $countries_array['countries_iso_code_2'],
                                   SHIPPING_ORIGIN_ZIP,
                                   $zone_name);
   $GSPackage = new GoogleShippingPackage($ship_from,1,1,1,'IN');
   $Gshipping->addShippingPackage($GSPackage);
   $carriers_config = explode(', ', MODULE_PAYMENT_GOOGLECHECKOUT_CARRIER_CALCULATED);
//    print_r($googlepayment->cc_shipping_methods);die;
   foreach($googlepayment->cc_shipping_methods_names as $CCSCode => $CCSName){
     foreach($googlepayment->cc_shipping_methods[$CCSCode] as $type => $methods) {
       foreach($methods as $method => $method_name) {        
         $values = explode('|', gc_compare($CCSCode . $method. $type , $carriers_config, "_CCS:", '0|0|0'));
         if($values[0] != '0') {
           $CCSoption = new GoogleCarrierCalculatedShippingOption($values[0], $CCSName, $method,$values[1], $values[2], 'REGULAR_PICKUP');
           $Gshipping->addCarrierCalculatedShippingOptions($CCSoption);
         }
       }
     }
   }
   $Gcart->AddShipping($Gshipping);
 }
}

if($ship_calculation_mode == 'True') {

 if (MODULE_PAYMENT_GOOGLECHECKOUT_MODE == 'https://sandbox.google.com/checkout/'
     && MODULE_PAYMENT_GOOGLECHECKOUT_MC_MODE == 'http') {
   $url = HTTP_SERVER . DIR_WS_CATALOG .'googlecheckout/responsehandler.php';
 }
 else {
   $url = HTTPS_SERVER . DIR_WS_CATALOG .'googlecheckout/responsehandler.php';
}
 $Gcart->SetMerchantCalculations($url, 'false', 'false', 'false');
}

if(MODULE_PAYMENT_GOOGLECHECKOUT_3RD_PARTY_TRACKING != 'NONE') {
// Third party tracking 
 $tracking_attr_types = array(
                             'buyer-id' => 'buyer-id',
                             'order-id' => 'order-id',
                             'order-subtotal' => 'order-subtotal',
                             'order-subtotal-plus-tax' => 'order-subtotal-plus-tax',
                             'order-subtotal-plus-shipping' => 'order-subtotal-plus-shipping',
                             'order-total' => 'order-total',
                             'tax-amount' => 'tax-amount',
                             'shipping-amount' => 'shipping-amount',
                             'coupon-amount' => 'coupon-amount',
                             'coupon-amount' => 'coupon-amount',
                             'billing-city' => 'billing-city',
                             'billing-region' => 'billing-region',
                             'billing-postal-code' => 'billing-postal-code',
                             'billing-country-code' => 'billing-country-code',
                             'shipping-city' => 'shipping-city',
                             'shipping-region' => 'shipping-region',
                             'shipping-postal-code' => 'shipping-postal-code',
                             'shipping-country-code' => 'shipping-country-code',
                           );
 $Gcart->AddThirdPartyTracking(MODULE_PAYMENT_GOOGLECHECKOUT_3RD_PARTY_TRACKING,
                                                         $tracking_attr_types);
}
//Tax options	
if (sizeof($tax_class_unique) == 1 && sizeof($module_info_enabled) == sizeof($tax_class)) {
 $tax_rates_result = tep_db_query("select countries_name, coalesce(zone_code, 'All Areas') zone_code, tax_rate, countries_iso_code_2
                                from " . TABLE_TAX_RATES . " as tr " .
                                " inner join " . TABLE_ZONES_TO_GEO_ZONES . " as ztgz on tr.tax_zone_id = ztgz.geo_zone_id " .
                                " inner join " . TABLE_COUNTRIES . " as c on ztgz.zone_country_id = c.countries_id " .
                                " left join " . TABLE_ZONES . " as z on ztgz.zone_id=z.zone_id
                                where tr.tax_class_id= '" .  $tax_class_unique[0] ."'");
$num_rows = tep_db_num_rows($tax_rates_result);
$tax_rule = array();
for ($j = 0; $j < $num_rows; $j++) {
	$tax_result = tep_db_fetch_array($tax_rates_result);
	$rate = ((double) ($tax_result['tax_rate'])) / 100.0;
   $GDtaxRule = new GoogleDefaultTaxRule($rate, 'true');
   if($tax_result['countries_iso_code_2'] == 'US') {
     if($tax_result['zone_code'] == 'All Areas') {
       $GDtaxRule->SetCountryArea('ALL');
     }
     else {
       $GDtaxRule->SetStateAreas($tax_result['zone_code']);
     }
   }
   else {
     $GDtaxRule->AddPostalArea($tax_result['countries_iso_code_2']);
   }           
   $Gcart->AddDefaultTaxRules($GDtaxRule);
}
}
else {
 $GDtaxRule = new GoogleDefaultTaxRule(0, 'false');
 $GDtaxRule->SetWorldArea(true);
 $Gcart->AddDefaultTaxRules($GDtaxRule);
}

if(sizeof($tax_class_unique) > 1 || (sizeof($tax_class_unique) == 1 && 
  sizeof($module_info_enabled) != sizeof($tax_class) ))  {
 $Gcart->SetButtonVariant(false);
 $Gwarnings[] = GOOGLECHECKOUT_STRING_WARN_MULTIPLE_SHIP_TAX;
}
$i = 0;
$tax_tables = array ();
foreach ($tax_array as $tax_table) {
 $tax_rates_result = tep_db_query("select countries_name, coalesce(zone_code, 'All Areas') zone_code, tax_rate, countries_iso_code_2
                                from " . TABLE_TAX_RATES . " as tr " .
                                " inner join " . TABLE_ZONES_TO_GEO_ZONES . " as ztgz on tr.tax_zone_id = ztgz.geo_zone_id " .
                                " inner join " . TABLE_COUNTRIES . " as c on ztgz.zone_country_id = c.countries_id " .
                                " left join " . TABLE_ZONES . " as z on ztgz.zone_id=z.zone_id
                                where tr.tax_class_id= '" . $tax_array[$i] ."'");
$num_rows = tep_db_num_rows($tax_rates_result);

$tax_rule = array ();
 $GAtaxTable = new GoogleAlternateTaxTable((!empty($tax_name_array[$i])?$tax_name_array[$i]:'none'), 'false');

for ($j = 0; $j < $num_rows; $j++) {
	$tax_result = tep_db_fetch_array($tax_rates_result);
	$rate = ((double) ($tax_result['tax_rate'])) / 100.0;

   $GAtaxRule = new GoogleAlternateTaxRule($rate);
   if($tax_result['countries_iso_code_2'] == 'US') {

     if($tax_result['zone_code'] == 'All Areas') {
       $GAtaxRule->SetCountryArea('ALL');
     }
     else {
       $GAtaxRule->SetStateAreas($tax_result['zone_code']);
     }
   }
	else {
	  // TODO here should go the non use area
     $GAtaxRule->AddPostalArea($tax_result['countries_iso_code_2']);
	}
   $GAtaxTable->AddAlternateTaxRules($GAtaxRule);
}
$i++;
 $Gcart->AddAlternateTaxTables($GAtaxTable);  
}

if(!(MODULE_PAYMENT_GOOGLECHECKOUT_ANALYTICS == 'NONE')) {
 $Gcart->AddGoogleAnalyticsTracking(MODULE_PAYMENT_GOOGLECHECKOUT_ANALYTICS);
}
?>
<div align="right">
<?php 
 echo '<div style="width: 180px; text-align: center;"><b>' . MODULE_PAYMENT_GOOGLECHECKOUT_TEXT_OPTION . '</b></div>';
?>
</div>
<div align="right">
   <?php
   echo $Gcart->CheckoutButtonCode();
   ?>
   <?php
     foreach($Gwarnings as $Gwarning) {
       echo '<div style="font-size:11px; color: red; width: 180px; text-align: center;"> * ' . $Gwarning . '</div>';
     }
     if($shipping_config_errors != ''){
       echo '<div style="font-size:11px; color: red; width: 180px; text-align: center;"><b>' . GOOGLECHECKOUT_STRING_ERR_SHIPPING_CONFIG . '</b><br />';
       echo $shipping_config_errors;
       echo '</div>';
     }
   ?>
</div>
<?php
//echo $Gcart->CheckoutHTMLButtonCode();
//echo "<xmp>".$Gcart->GetXML()."</xmp>";
?>
<!-- ** END GOOGLE CHECKOUT ** -->

 

 

I think there may be a problem with the way this php calls from the mySQL specifically regarding the ADDed columns for OTF:

 

ALTER TABLE products_options

 ADD products_options_type INT( 5 ) NOT NULL ,

 ADD products_options_length SMALLINT( 2 ) DEFAULT '32' NOT NULL ,

 ADD products_options_comment VARCHAR( 32 );



ALTER TABLE customers_basket_attributes

 ADD products_options_value_text text;

 

Any help is very much appreciated.

Link to comment
Share on other sites

in the Product Options list, the option name field is missing. The header row has ID, Option Name, Option Type, Length etc, however the actual data in the table has the values for ID in the ID column, but then option type appears under the Option Name column, Length under the Option Values column and so on.

 

If anyone else gets stuck with this, i.e. in the products_attributes screen in admin under Product Options where the information for Option Name is missing, here's the fix:

 

in /catalog/admin/products_attributes.php, find the following around line 440:

 

// EOF Product Option Type

 

?>

<td align="center" class="smallText"> <?php echo $options_values["products_options_id"]; ?> </td>

 

 

<!-- BOF Product Option Type -->

 

 

The problem is the second cell is missing. Change it to this:

 

 

 

// EOF Product Option Type

 

?>

<td align="center" class="smallText"> <?php echo $options_values["products_options_id"]; ?> </td>

<td class="smallText"><?php echo $options_values['products_options_name']; ?></td>

 

 

<!-- BOF Product Option Type -->

 

 

and it should all work!

 

Greg

Edited by gregp
Link to comment
Share on other sites

Can anyone help me with this:

 

I have installed this fine, and everything works brilliantly, however ive just noticed that when i hit UPDATE in the shopping cart all the attributes are lost for each of the products!

 

Anyone able to point me in the right direction?

Link to comment
Share on other sites

I am using osc ms2.2 and when I add product attributes I get this line in the drop-down option box:

 

full (+<span class=currency_symbol>$</span>20.00<span class=currency_symbol></span>)

 

Instead of: full + $20.00

 

I already looked at the product_info.php page but could not find anything like it.

 

Any one have this issue or know how to fix it?

 

Thanks in advance.

 

Tim

Link to comment
Share on other sites

Can anyone help me with this:

 

I have installed this fine, and everything works brilliantly, however ive just noticed that when i hit UPDATE in the shopping cart all the attributes are lost for each of the products!

 

Anyone able to point me in the right direction?

 

:'( I'm having the same problem.... if you do know the solution from elsewhere, please let me know

Link to comment
Share on other sites

Hi, I ran into a problem installing Product Attributes - Option Type Feature. Im not sure what I did wrong.

 

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /****/includes/classes/shopping_cart.php:1) in /****/includes/functions/sessions.php on line 97

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /****/includes/classes/shopping_cart.php:1) in /****/includes/functions/sessions.php on line 97

 

 

 

shopping_cart.php

<?php
/*
 $Id: shopping_cart.php,v 1.73 2003/06/09 23:03:56 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_SHOPPING_CART);

 $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_SHOPPING_CART));
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</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="0" cellpadding="0">
 <tr>
  <td valign="top">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
</td>
<!-- body_text //-->
<td width="100%" valign="top"><?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_SHOPPING_CART, 'action=update_product')); ?><table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
	<td>

<?php tep_draw_heading_top();?>

<? new contentBoxHeading_ProdNew($info_box_contents);?>

<?php tep_draw_heading_top_1();?>

<?php
 if ($cart->count_contents() > 0) {
?>
<?php
$info_box_contents = array();
$info_box_contents[0][] = array('align' => 'center',
								'params' => 'class="shop_card_txt" style="width:15%"',
								'text' => ''.TABLE_HEADING_REMOVE.'');

$info_box_contents[0][] = array('params' => 'class="shop_card_txt" style="width:50%""',
								'text' => ''.TABLE_HEADING_PRODUCTS.'');

$info_box_contents[0][] = array('align' => 'center',
								'params' => 'class="shop_card_txt" style="width:15%""',
								'text' => ''.TABLE_HEADING_QUANTITY.'');

$info_box_contents[0][] = array('align' => 'center',
								'params' => 'class="shop_card_txt " style="width:20%""',
								'text' => ''.TABLE_HEADING_TOTAL.'');

$any_out_of_stock = 0;
$products = $cart->get_products();
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
// Push all attributes information in an array
  if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
	while (list($option, $value) = each($products[$i]['attributes'])) {
// OTF contrib begins
//echo tep_draw_hidden_field('id[' . $products[$i]['id'] . '][' . $option . ']', $value);
// OTF contrib ends
	  $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix
								  from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa
								  where pa.products_id = '" . (int)$products[$i]['id'] . "'
								   and pa.options_id = '" . (int)$option . "'
								   and pa.options_id = popt.products_options_id
								   and pa.options_values_id = '" . (int)$value . "'
								   and pa.options_values_id = poval.products_options_values_id
								   and popt.language_id = '" . (int)$languages_id . "'
								   and poval.language_id = '" . (int)$languages_id . "'");
	  $attributes_values = tep_db_fetch_array($attributes);
				// OTF contrib begins
	  if ($value == PRODUCTS_OPTIONS_VALUE_TEXT_ID) {					   

		$attr_value = $products[$i]['attributes_values'][$option] . 
		  tep_draw_hidden_field('id[' . $products[$i]['id'] . '+++' .
		  $i . '][' . TEXT_PREFIX . $option . ']',  
		  $products[$i]['attributes_values'][$option]);
		$attr_name_sql_raw = 'SELECT po.products_options_name FROM ' .
		  TABLE_PRODUCTS_OPTIONS . ' po, ' .
		  TABLE_PRODUCTS_ATTRIBUTES . ' pa WHERE ' .
		  ' pa.products_id="' . tep_get_prid($products[$i]['id']) . '" AND ' .
		  ' pa.options_id="' . $option . '" AND ' .
		  ' pa.options_id=po.products_options_id AND ' .
		  ' po.language_id="' . $languages_id . '" ';
		$attr_name_sql = tep_db_query($attr_name_sql_raw);
		if ($arr = tep_db_fetch_array($attr_name_sql)) {
		  $attr_name  = $arr['products_options_name'];
		}

	  } else {


		$attr_value = $attributes_values['products_options_values_name'] . 
		  tep_draw_hidden_field('id[' . $products[$i]['id'] . '+++' . 
		  $i. '][' . $option . ']', $value);
		$attr_name  = $attributes_values['products_options_name'];

	  }
	  // OTF contrib ends

	  // OTF contrib begins
	  //$products[$i][$option]['products_options_name'] = $attributes_values['products_options_name'];
	  $products[$i][$option]['products_options_name'] = $attr_name;
	  // OTF contrib ends
	  $products[$i][$option]['options_values_id'] = $value;

	  // OTF contrib begins
	  //$products[$i][$option]['products_options_values_name'] = $attributes_values['products_options_values_name'];
	  $products[$i][$option]['products_options_values_name'] = $attr_value;
	  // OTF contrib ends
	  $products[$i][$option]['options_values_price'] = $attributes_values['options_values_price'];
	  $products[$i][$option]['price_prefix'] = $attributes_values['price_prefix'];
	}
  }
}

for ($i=0, $n=sizeof($products); $i<$n; $i++) {
  if (($i/2) == floor($i/2)) {
	$info_box_contents[] = array('params' => 'class=""');
  } else {
	$info_box_contents[] = array('params' => 'class=""');
  }

  $cur_row = sizeof($info_box_contents) - 1;

  $info_box_contents[$cur_row][] = array('align' => 'center',
										 'params' => 'class="" valign="top"',
										 'text' => '<br style="line-height:1px;"><br style="line-height:44px;">' .tep_draw_checkbox_field('cart_delete[]', $products[$i]['id']));

  $products_name = '
														<table cellpadding="0" cellspacing="0" border="0" style=" width:290px;">
															<tr>
																<td height="168"><img src="images/spacer.gif" width="7" height="1" alt=""></td>
																<td class="pic"><br style="line-height:11px"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">' . tep_image(DIR_WS_IMAGES . $products[$i]['image'], $products[$i]['name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br></td>
																<td><img src="images/spacer.gif" width="7" height="1" alt=""></td>												
																  <td width="100%" ><br style="line-height:13px">
																<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">' . substr($products[$i]['name'],0,MAX_DESCR_NAME_SHOPPCART) . '</a>';



  if (STOCK_CHECK == 'true') {
	$stock_check = tep_check_stock($products[$i]['id'], $products[$i]['quantity']);
	if (tep_not_null($stock_check)) {
	  $any_out_of_stock = 1;

	  $products_name .= $stock_check;
	}
  }

  if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
	reset($products[$i]['attributes']);
	while (list($option, $value) = each($products[$i]['attributes'])) {
	  $products_name .= '<br><small><i> - ' . $products[$i][$option]['products_options_name'] . ' ' . $products[$i][$option]['products_options_values_name'] . '</i></small>';
	}
  }	
	$products_name .= '</td>

															</tr>
														</table>

							';








  $info_box_contents[$cur_row][] = array('params' => 'class=""',
										 'text' => '<br style="line-height:1px">'.$products_name);

  $info_box_contents[$cur_row][] = array('align' => 'center',
										 'params' => ' class="form_1" valign="top"',
										 'text' => '<br style="line-height:1px;"><br style="line-height:44px">'.tep_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="4" id="input3"') . tep_draw_hidden_field('products_id[]', $products[$i]['id']));

  $info_box_contents[$cur_row][] = array('align' => 'center',
										 'params' => 'class="" valign="top"',
										 'text' => '<br style="line-height:1px;"><br style="line-height:44px"><span>' . $currencies->display_price($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</span>');
}

new productListingBox($info_box_contents);
?>

<?php
if ($any_out_of_stock == 1) {
  if (STOCK_ALLOW_CHECKOUT == 'true') {
?>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
  <tr>
	<td class="stockWarning" align="center"><br><?php echo OUT_OF_STOCK_CAN_CHECKOUT; ?></td>
  </tr>
</table>
<?php
  } else {
?>
 <table cellpadding="0" cellspacing="0" border="0" width="100%">
  <tr>
	<td class="stockWarning" align="center"><br><?php echo OUT_OF_STOCK_CANT_CHECKOUT; ?></td>
  </tr>
 </table>
 <table cellpadding="0" cellspacing="0" border="0" width="100%">
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '1'); ?></td>
  </tr>
 </table>

<?php
  }
}
?>
											<table cellspacing="0" cellpadding="0" border="0" class="product">
												<tr><td class="bg16" colspan="2"></td></tr>
												<tr>
													<td width="82%" align="right" height="45" style=" vertical-align:middle;"><?php echo tep_draw_separator('pixel_trans.gif', '97', '1'); ?><br><strong><?php echo SUB_TITLE_SUB_TOTAL; ?></strong>   <br>
												  </td>
													<td width="18%" height="45" align="center" style=" vertical-align:middle;">														
														<span><?php echo $currencies->format($cart->show_total()); ?></span>
													</td>
												</tr>
											</table>
											<table cellspacing="0" cellpadding="0" border="0" >
												<tr>
													<td width="499" height="22">
														<?php echo tep_draw_separator('pixel_trans.gif', '13', '1'); ?><?php echo tep_image_submit('button_update_cart.gif', IMAGE_BUTTON_UPDATE_CART); ?><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?><?php
$back = sizeof($navigation->path)-2;
if (isset($navigation->path[$back])) {
echo '<a href="' . tep_href_link($navigation->path[$back]['page'], tep_array_to_string($navigation->path[$back]['get'], array('action')), $navigation->path[$back]['mode']) . '">' . tep_image_button('button_continue_shopping1.gif', IMAGE_BUTTON_CONTINUE_SHOPPING) . '</a>'; 
}
?><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?><?php echo '<a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '">' . tep_image_button('button_checkout.gif', IMAGE_BUTTON_CHECKOUT) . '</a>'; ?><br>
													</td>
												</tr>
											</table>



<?php
 } else {
?>

<br style="line-height:1px;"><br style="line-height:5px;">


		<table border="0" width="100%" cellspacing="0" cellpadding="2">
		  <tr>
			  <td></td>
			<td align="center" class="main"><br><?php new infoBox_77(array(array('text' => TEXT_CART_EMPTY))); ?></td>
			<td></td>
		  </tr>
		  <tr>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
			<td align="right" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?><br><br></td>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
		  </tr>
		  <tr><td colspan="3" height="5"></td></tr>
		</table>



<?php
 }
?>

<?php tep_draw_heading_bottom_1();?>

<?php tep_draw_heading_bottom();?>

</table>



</form></td>

<!-- body_text_eof //-->
<td valign="top">
<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
<!-- right_navigation_eof //-->
</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'); ?>

 

sessions.php

<?php
/*
 $Id: sessions.php,v 1.19 2003/07/02 22:10:34 hpdl Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 if (STORE_SESSIONS == 'mysql') {
if (!$SESS_LIFE = get_cfg_var('session.gc_maxlifetime')) {
  $SESS_LIFE = 1440;
}

function _sess_open($save_path, $session_name) {
  return true;
}

function _sess_close() {
  return true;
}

function _sess_read($key) {
  $value_query = tep_db_query("select value from " . TABLE_SESSIONS . " where sesskey = '" . tep_db_input($key) . "' and expiry > '" . time() . "'");
  $value = tep_db_fetch_array($value_query);

  if (isset($value['value'])) {
	return $value['value'];
  }

  return false;
}

function _sess_write($key, $val) {
  global $SESS_LIFE;

  $expiry = time() + $SESS_LIFE;
  $value = $val;

  $check_query = tep_db_query("select count(*) as total from " . TABLE_SESSIONS . " where sesskey = '" . tep_db_input($key) . "'");
  $check = tep_db_fetch_array($check_query);

  if ($check['total'] > 0) {
	return tep_db_query("update " . TABLE_SESSIONS . " set expiry = '" . tep_db_input($expiry) . "', value = '" . tep_db_input($value) . "' where sesskey = '" . tep_db_input($key) . "'");
  } else {
	return tep_db_query("insert into " . TABLE_SESSIONS . " values ('" . tep_db_input($key) . "', '" . tep_db_input($expiry) . "', '" . tep_db_input($value) . "')");
  }
}

function _sess_destroy($key) {
  return tep_db_query("delete from " . TABLE_SESSIONS . " where sesskey = '" . tep_db_input($key) . "'");
}

function _sess_gc($maxlifetime) {
  tep_db_query("delete from " . TABLE_SESSIONS . " where expiry < '" . time() . "'");

  return true;
}

session_set_save_handler('_sess_open', '_sess_close', '_sess_read', '_sess_write', '_sess_destroy', '_sess_gc');
 }

 function tep_session_start() {
global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS;

$sane_session_id = true;

if (isset($HTTP_GET_VARS[tep_session_name()])) {
  if (preg_match('/^[a-zA-Z0-9]+$/', $HTTP_GET_VARS[tep_session_name()]) == false) {
	unset($HTTP_GET_VARS[tep_session_name()]);

	$sane_session_id = false;
  }
} elseif (isset($HTTP_POST_VARS[tep_session_name()])) {
  if (preg_match('/^[a-zA-Z0-9]+$/', $HTTP_POST_VARS[tep_session_name()]) == false) {
	unset($HTTP_POST_VARS[tep_session_name()]);

	$sane_session_id = false;
  }
} elseif (isset($HTTP_COOKIE_VARS[tep_session_name()])) {
  if (preg_match('/^[a-zA-Z0-9]+$/', $HTTP_COOKIE_VARS[tep_session_name()]) == false) {
	$session_data = session_get_cookie_params();

	setcookie(tep_session_name(), '', time()-42000, $session_data['path'], $session_data['domain']);

	$sane_session_id = false;
  }
}

if ($sane_session_id == false) {
  tep_redirect(tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false));
}

return session_start();
 }

 function tep_session_register($variable) {
global $session_started;

if ($session_started == true) {
  return session_register($variable);
} else {
  return false;
}
 }

 function tep_session_is_registered($variable) {
return session_is_registered($variable);
 }

 function tep_session_unregister($variable) {
return session_unregister($variable);
 }

 function tep_session_id($sessid = '') {
if (!empty($sessid)) {
  return session_id($sessid);
} else {
  return session_id();
}
 }

 function tep_session_name($name = '') {
if (!empty($name)) {
  return session_name($name);
} else {
  return session_name();
}
 }

 function tep_session_close() {
if (PHP_VERSION >= '4.0.4') {
  return session_write_close();
} elseif (function_exists('session_close')) {
  return session_close();
}
 }

 function tep_session_destroy() {
return session_destroy();
 }

 function tep_session_save_path($path = '') {
if (!empty($path)) {
  return session_save_path($path);
} else {
  return session_save_path();
}
 }

 function tep_session_recreate() {
if (PHP_VERSION >= 4.1) {
  $session_backup = $_SESSION;

  unset($_COOKIE[tep_session_name()]);

  tep_session_destroy();

  if (STORE_SESSIONS == 'mysql') {
	session_set_save_handler('_sess_open', '_sess_close', '_sess_read', '_sess_write', '_sess_destroy', '_sess_gc');
  }

  tep_session_start();

  $_SESSION = $session_backup;
  unset($session_backup);
}
 }
?>

Edited by Blackthorneppc
Link to comment
Share on other sites

Guys try this this seems to have solved my problem of attributes being lost after updating cart quantities, PLEASE BACKUP YOUR FILES FIRST THOUGH JUST IN CASE!!!!

 

 

in /catalog/includes/application_top.php

 

around line 360 find:

 

$attributes = ($HTTP_POST_VARS['id'][$HTTP_POST_VARS['products_id'][$i]]) ? $HTTP_POST_VARS['id'][$HTTP_POST_VARS['products_id'][$i]] : '';

 

 

 

and replace it with this:

 

//$attributes = ($HTTP_POST_VARS['id'][$HTTP_POST_VARS['products_id'][$i]]) ? $HTTP_POST_VARS['id'][$HTTP_POST_VARS['products_id'][$i]] : '';
$attributes =($HTTP_POST_VARS['id'][$HTTP_POST_VARS['products_id'][$i].'+++'.$i]) ? $HTTP_POST_VARS['id'][$HTTP_POST_VARS['products_id'][$i].'+++'.$i] : '';

 

 

Let me know if that works (original line is still there just commented out).

Edited by isl
Link to comment
Share on other sites

Glad to hear its working for you m8 :D

 

I noticed there was a fix for the original contribution which was posted in July 2007 but doesnt seem to have been included in the later release perhaps?

 

 

All credit should go to dracono for the "Broken quantity update after OTF" fix.

 

:thumbsup:

Link to comment
Share on other sites

My issue is bizzarre...Text box options only work if one and any select option is assigned to a product. If the select is missing, add the text option to the cart is gone. Perhaps dracono's fixes needs to be added to 2.01 quickly...im going through his diff file tonite...

Link to comment
Share on other sites

Anybody have an idea where I could have screwed up? All the attributes and their respective values show up fine in the shopping cart. I'm using PWA too, if that matters, but when I go to checkout_confirmation.php, my attribute names aren't showing up correctly, though all the values are showing up in their proper order. Does checkout_confirmation.php need to be edited in some way to properly display OTF?

 

- Membership Type: Test Membership (select)

- Do You Speak A Foreign Language?: Yes (radio)

- Do You Speak A Foreign Language?: Spanish (text area)

- Do You Speak A Foreign Language?: 1922 (text)

- Do You Speak A Foreign Language?: Sky Web Designs (text)

- Do You Speak A Foreign Language?: 1 Lake Avenue (text)

- Do You Speak A Foreign Language?: Lake River (text)

- Business State: OH (select)

- Business State: 44100 (text)

- Business State: 216xxx1665 (text)

- Business State: [email protected] (text)

- Want to Serve on a Committee?: No (radio)

 

Any hints as to where I may have gone wrong would be greatly appreciated. In the mean time, I'll keep scouring my code and the forums. Thanks. --Rich

Link to comment
Share on other sites

Anybody have an idea where I could have screwed up? All the attributes and their respective values show up fine in the shopping cart. I'm using PWA too, if that matters, but when I go to checkout_confirmation.php, my attribute names aren't showing up correctly, though all the values are showing up in their proper order. Does checkout_confirmation.php need to be edited in some way to properly display OTF?

 

- Membership Type: Test Membership (select)

- Do You Speak A Foreign Language?: Yes (radio)

- Do You Speak A Foreign Language?: Spanish (text area)

- Do You Speak A Foreign Language?: 1922 (text)

- Do You Speak A Foreign Language?: Sky Web Designs (text)

- Do You Speak A Foreign Language?: 1 Lake Avenue (text)

- Do You Speak A Foreign Language?: Lake River (text)

- Business State: OH (select)

- Business State: 44100 (text)

- Business State: 216xxx1665 (text)

- Business State: [email protected] (text)

- Want to Serve on a Committee?: No (radio)

 

Any hints as to where I may have gone wrong would be greatly appreciated. In the mean time, I'll keep scouring my code and the forums. Thanks. --Rich

I have no idea what I did to fix the problem, but it seems to be fixed. Phew. Thanks for the great contrib.

Link to comment
Share on other sites

  • 3 weeks later...

Hello

I had added this to my store and I just over wrote the files..

and add info to database I had attributes already there.. and just want to add ones the customer can add input.. but the one I added for customer input does not show up on the customer side of the catalog.. the original attributes show up put the new ones don't

any Idea thank you

 

Noppie

Link to comment
Share on other sites

Hi

 

This is a brilliant contribution as I really needed each order to be personalised.

 

What I need now is to make at least one of the text boxes I have added a mandatory field. I have looked at lots of java and php suggestions, but am struggling with this.

 

Any help very much appreciated.

Link to comment
Share on other sites

Hi, can anyone tell me how you go about adding a text box to your product?? Right now, I put in the Option name, length, select text as the type, and insert a comment. Then for the Option Value, I put TEXT. But when I add it to the product, on the product_info.php page, all I get is the usual drop box!!

 

I checked and triple checked the code for the pages. I made sure all new files were uploaded. And still nothing.

 

What am I doing wrong?!

Link to comment
Share on other sites

  • 3 weeks later...
  • 2 weeks later...

Hi, I've searched for this but can't work out the issue.

 

When I add a textarea (multiple line text box) attribute to a product, everything works as it shoud until you use line breaks in the textarea.

 

So, if I enter:

aa bb cc

 

Everything works - it is passed to the cart, and I can edit the entry with the values being put back into the textarea.

 

HOWEVER, if I enter:

aa

bb

cc

 

The values are passed to the cart, but when you edit that entry in the cart nothing shows up in the textarea.

 

I am using the latest version and have made sure the fix to application_top.php to stop values being lost is there.

 

Any help would be much appreciated! TIA.

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

 

I have been using this attribute for AGES!

Up until now, I have not had any problems either.

 

I have just tried to put in a text entry box and for some reason it is not passing the details onto the shopping cart when you add the item to cart.

 

I already have a selection of drop down boxes, check boxes and radio buttons on different items that all update but the text options aren’t.

 

Can anyone help?

 

 

Regards

 

Pete

Link to comment
Share on other sites

I'm trying to MERGE Option_Type_Feature_1[1].7.2.zip into my existing site and I am having difficulty figuring out what goes where on one file in particular...

catalog/includes/functions/general.php

 

My file looks nothing like the sample given. Is this a step I can skip? or can someone help me figure out what my custom updates are.

 

Here is a copy of the contribution tep_get_uprid

// 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;
 }

////
// Return a product ID from a product ID with attributes

 

Here is a copy of my tep_get_uprid.

// Return a product ID with attributes
 function tep_get_uprid($prid, $params) {
if (is_numeric($prid)) {
  $uprid = $prid;

  if (is_array($params) && (sizeof($params) > 0)) {
	$attributes_check = true;
	$attributes_ids = '';

	reset($params);
	while (list($option, $value) = each($params)) {
	  if (is_numeric($option) && is_numeric($value)) {
		$attributes_ids .= '{' . (int)$option . '}' . (int)$value;
	  } else {
		$attributes_check = false;
		break;
	  }
	}

	if ($attributes_check == true) {
	  $uprid .= $attributes_ids;
	}
  }
} else {
  $uprid = tep_get_prid($prid);

  if (is_numeric($uprid)) {
	if (strpos($prid, '{') !== false) {
	  $attributes_check = true;
	  $attributes_ids = '';

// strpos()+1 to remove up to and including the first { which would create an empty array element in explode()
	  $attributes = explode('{', substr($prid, strpos($prid, '{')+1));

	  for ($i=0, $n=sizeof($attributes); $i<$n; $i++) {
		$pair = explode('}', $attributes[$i]);

		if (is_numeric($pair[0]) && is_numeric($pair[1])) {
		  $attributes_ids .= '{' . (int)$pair[0] . '}' . (int)$pair[1];
		} else {
		  $attributes_check = false;
		  break;
		}
	  }

	  if ($attributes_check == true) {
		$uprid .= $attributes_ids;
	  }
	}
  } else {
	return false;
  }
}

return $uprid;
 }

////
// Return a product ID from a product ID with attributes

Link to comment
Share on other sites

Hi, I've searched for this but can't work out the issue.

 

When I add a textarea (multiple line text box) attribute to a product, everything works as it shoud until you use line breaks in the textarea.

 

So, if I enter:

aa bb cc

 

Everything works - it is passed to the cart, and I can edit the entry with the values being put back into the textarea.

 

HOWEVER, if I enter:

aa

bb

cc

 

The values are passed to the cart, but when you edit that entry in the cart nothing shows up in the textarea.

 

I am using the latest version and have made sure the fix to application_top.php to stop values being lost is there.

 

Any help would be much appreciated! TIA.

 

I don't know if this is the answer you need or not. But I noticed this note/code in the bottom of my catalog/includes/functions/general.php

 

// nl2br() prior PHP 4.2.0 did not convert linefeeds on all OSs (it only converted \n)
 function tep_convert_linefeeds($from, $to, $string) {
if ((PHP_VERSION < "4.0.5") && is_array($from)) {
  return ereg_replace('(' . implode('|', $from) . ')', $to, $string);
} else {
  return str_replace($from, $to, $string);
}
 }

 

Maybe try adding that function to see if it handles the linefeeds any better?

Link to comment
Share on other sites

I may have slightly mis-stated my problem. It looks like none of the OTF values make it through an update but that all of them but the text area ones are sent on to Google Checkout. Really the only thing I'm trying to fix right now is the passing to the Google Checkout of the text-area values.

I am using the Google Checkout contribution:

Any help is very much appreciated.

 

I think I have this fixed for use with google checkout now, here is my fix:

 

INTEGRATING GOOGLE CHECKOUT with PRODUCT ATTRIBUTES OPTION TYPE FEATURE

 

catalog/googlecheckout/gcheckout.php

 

FIND (line 142):

$attr_value = $attributes_values['products_options_values_name'];

 

CHANGE TO:

// Product Option Type

if ($value == PRODUCTS_OPTIONS_VALUE_TEXT_ID) {

 

$attr_value = $products[$i]['attributes_values'][$option] .

tep_draw_hidden_field('id[' . $products[$i]['id'] . '+++' .

$i . '][' . TEXT_PREFIX . $option . ']',

$products[$i]['attributes_values'][$option]);

 

} else {

$attr_value = $attributes_values['products_options_values_name'] .

tep_draw_hidden_field('id[' . $products[$i]['id'] . '+++' .

$i. '][' . $option . ']', $value);

}

// End Product Option Type

 

 

catalog/googlecheckout/responsehandler.php

 

FIND (line 631):

'products_options_values' => $attributes_values['products_options_values_name'],

 

CHANGE TO:

'products_options_values' => $order->products[$i]['attributes'][$j]['value'], // Product Options Changed

 

 

FIND (line 644)

$products_ordered_attributes .= "\n\t" . $attributes_values['products_options_name'] . ' ' . $attributes_values['products_options_values_name'];

 

CHANGE TO:

// Product Option Type contribution

$products_ordered_attributes .= "\n\t" . $attributes_values['products_options_name'] . ' ' . tep_decode_specialchars($order->products[$i]['attributes'][$j]['value']);

// $products_ordered_attributes .= "\n\t" . $attributes_values['products_options_name'] . ' ' . $attributes_values['products_options_values_name'];

Most Valuable OsCommerce Contributions:

Also Purchased (AP) Preselection (cuts this resource hogging query down to nothing) -- Contribution 3294

FedEx Automated Labels -- Contribution 2244

RMA Returns system -- Contribution 1136

Sort Products By Dropdown -- Contribution 4312

Ultimate SEO URLs -- Contribution 2823

Credit Class & Gift Voucher -- Contribution 282

Cross-Sell -- Contribution 5347

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...