Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Add customer/note input field


alberti

Recommended Posts

Posted

Hi there,

 

I need help in figuring out how to send values from a text input box on the product_listings.php to the the shopping_cart.php page where there already is a working code for the notes code, which is what I'm attemping to do.

 

I've managed to add the input box to where I want it displayed, however I don't know how to get it to function.

 

I want a user to add their comment/note into the notes input field so that when they press 'add to cart' their note will be saved and should appear within the notes box next the item they added on the shopping cart page.

 

The notes serve a purpose to communicate with customers, because it's whole sale they could add their comment that I want only 10 lighters out of the 20 in the package, while making orders, so they won't have to call or email these questions in.

 

Please see the code below. of (product_listing.php)

 

<?php
/*
 $Id: product_listing.php 1739 2007-12-20 00:52:16Z hpdl $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/
?>
<?php echo tep_draw_title_top();?>

			<?php echo $breadcrumb->trail(' » ')?>

<?php echo tep_draw_title_bottom();?>	

<?php echo tep_draw3_top();?>

<?php
 $listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_SEARCH_RESULTS, 'p.products_id');

 if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {
?>

<?php echo tep_draw_result1_top(); ?>

	<table border="0" cellspacing="0" cellpadding="0" class="result result_top_padd">
         <tr>
           <td><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
           <td class="result_right" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
         </tr>
       </table>

<?php echo tep_draw_result1_bottom();  ?> 


<?php
 }

$info_box_contents = array();
 $list_box_contents = array();
$my_row = 0;
$my_col = 0;


 for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
   switch ($column_list[$col]) {
     case 'PRODUCT_LIST_MODEL':
       $lc_text = TABLE_HEADING_MODEL;
       $lc_align = '';
       break;
     case 'PRODUCT_LIST_NAME':
       $lc_text = TABLE_HEADING_PRODUCTS;
       $lc_align = '';
       break;
     case 'PRODUCT_LIST_MANUFACTURER':
       $lc_text = TABLE_HEADING_MANUFACTURER;
       $lc_align = '';
       break;
     case 'PRODUCT_LIST_PRICE':
       $lc_text = TABLE_HEADING_PRICE;
       $lc_align = 'right';
       break;
     case 'PRODUCT_LIST_QUANTITY':
       $lc_text = TABLE_HEADING_QUANTITY;
       $lc_align = 'right';
       break;
     case 'PRODUCT_LIST_WEIGHT':
       $lc_text = TABLE_HEADING_WEIGHT;
       $lc_align = 'right';
       break;
     case 'PRODUCT_LIST_IMAGE':
       $lc_text = TABLE_HEADING_IMAGE;
       $lc_align = 'center';
       break;
       case 'PRODUCT_LIST_BUY_NOW':
       $lc_text = '<table cellSpacing="0" cellPadding="0" width="100%"><tr><td class="productListing-heading" align="right" width="25%">' . ' ' . TABLE_HEADING_QUANTITY  . ' ' . '</td><td class="productListing-heading" align="center" width="75%" valign="absmiddle">' . ' ' . TABLE_HEADING_BUY_NOW . ' ' . '</td></tr></table>';
       $lc_align = 'right';
       break;

// BOF Product Sort
  case 'PRODUCT_SORT_ORDER':
	$lc_text = TABLE_HEADING_PRODUCT_SORT;
	$lc_align = 'center';
	break;
// EOF Product Sort

   }

   if ( ($column_list[$col] != 'PRODUCT_LIST_BUY_NOW') && ($column_list[$col] != 'PRODUCT_LIST_IMAGE') ) {
     $lc_text = tep_create_sort_heading($HTTP_GET_VARS['sort'], $col+1, $lc_text);
   }

   $list_box_contents[0][] = array('align' => $lc_align,
                                   'params' => 'class="productListing-heading"',
                                   'text' => ' ' . $lc_text . ' ');
 }

 if ($listing_split->number_of_rows > 0) {
   $rows = 0;
   $listing_query = tep_db_query($listing_split->sql_query);
   while ($listing = tep_db_fetch_array($listing_query)) {
     $rows++;

     if (($rows/2) == floor($rows/2)) {
       $list_box_contents[] = array('params' => 'class="productListing-even"');
     } else {
       $list_box_contents[] = array('params' => 'class="productListing-odd"');
     }

     $cur_row = sizeof($list_box_contents) - 1;

     for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
       $lc_align = '';

       switch ($column_list[$col]) {
         case 'PRODUCT_LIST_MODEL':
           $lc_align = '';

           $p_model = '<tr>
						<td><b><font>'.TABLE_HEADING_MODEL.' :</font></b></td>
						<td align="right"><font>' . $listing['products_model'] . '</font></td>
					</tr>';
           break;
         case 'PRODUCT_LIST_NAME':
           $lc_align = '';
           if (isset($HTTP_GET_VARS['manufacturers_id'])) {
           $p_name = $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>';
           } else {
           $p_name = $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>';
           }
           break;
         case 'PRODUCT_LIST_MANUFACTURER':
           $lc_align = '';
           $p_manufact = '<tr>
						<td><b><font>'.TABLE_HEADING_MANUFACTURER.' :</font></b></td>
						<td align="right"><font><a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing['manufacturers_id']) . '">' . $listing['manufacturers_name'] . '</a></font></td>
					</tr>';
           break;
         case 'PRODUCT_LIST_PRICE':
           $lc_align = 'right';
           if (tep_not_null($listing['specials_new_products_price'])) {
          $p_price = $lc_text = '<s>' .  $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s>   <span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span>';
           } else {
          $p_price = $lc_text = '<span class="productSpecialPrice">' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span>';
           }
           break;
         case 'PRODUCT_LIST_QUANTITY':
           $lc_align = 'right';
           $p_qty = '<tr>
						<td><b><font>'.TABLE_HEADING_QUANTITY.' :</font></b></td>
						<td align="right"><font>' . $listing['products_quantity'] . '</font></td>
					</tr>';
           break;
         case 'PRODUCT_LIST_WEIGHT':
           $lc_align = 'right';
           $p_weight = '<tr>
						<td><b><font>'.TABLE_HEADING_WEIGHT.' :</font></b></td>
						<td align="right"><font>' . $listing['products_weight'] . '</font></td>
					</tr>';
           break;
         case 'PRODUCT_LIST_IMAGE':
           $lc_align = 'center';
           if (isset($HTTP_GET_VARS['manufacturers_id'])) {
             $p_pic = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';
           } else {
             $p_pic = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';
           }
           break;

		// BOF Product Sort
	  case 'PRODUCT_SORT_ORDER';
           $lc_align = 'center';
           $lc_text = ' ' . $listing['products_sort_order'] . ' ';
           break;
// EOF Product Sort

           case 'PRODUCT_LIST_BUY_NOW':
           $lc_align = 'right';
           $lc_text = tep_draw_form('buy_now', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id='. $listing['products_id']), 'POST') . '<table cellSpacing="0" cellPadding="0" width="100%"><tr><td align="right" width="25%">' . tep_draw_input_field('buyqty', '1', 'size=2 maxlength=2') . '</td><td align="center" width="75%" valign="absmiddle">' . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART, 'align=absmiddle') . '</td></tr></table></form>';
           break;


       }

$product_query = tep_db_query("select products_description, products_id from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$listing['products_id'] . "' and language_id = '" . (int)$languages_id . "'");
     $product = tep_db_fetch_array($product_query);
      	$p_desc = substr(strip_tags($product['products_description']), 0, MAX_DESCR_1).'...<br>';

  if (PRODUCT_LIST_MODEL != 0 || PRODUCT_LIST_MANUFACTURER != 0 || PRODUCT_LIST_QUANTITY != 0 || PRODUCT_LIST_WEIGHT != 0) {
	$p_listing = '<table cellpadding="0" cellspacing="0" border="0" class="listing">'.$p_model.''.$p_manufact.'' . ''.$p_qty.'' . ''.$p_weight.'</table>';
	}

       $p_id = $product['products_id'];

/*		$list_box_contents[$cur_row][] = array('align' => $lc_align,
                                              'params' => '',
                                              'text'  => $lc_text); */

}
        $my_sid    = tep_session_id();
	$sqlquery  = "select * from notes_track where sesskey  ='$my_sid'"; 
	$res_query = mysql_query($sqlquery);
	$row_res   = mysql_fetch_array($res_query);
	$postdata  = unserialize($row_res['value']);
       $notevalue = 'notes_'.$products[$i]['id'];
       $notevalue = $postdata[$notevalue];

 $p_details = '<a href="' . tep_href_link('product_info.php?products_id='.$p_id) . '">'.tep_image_button('button_details.gif', '', ' class="btn1"').'</a>';
 //$p_notez = tep_draw_textarea_field('notes_'.$products[$i]['id'],'soft', 10, 1,$notevalue) . tep_draw_hidden_field('products_id[]', $products[$i]['id']);
 $p_buy_now = tep_draw_form('buy_now', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id='. $listing['products_id']), 'POST') . '<table cellSpacing="0" cellPadding="0" width="100%"><tr><td align="right" width="25%">' . tep_draw_input_field('buyqty', '1', 'size=2 maxlength=2') . '</td><td align="center" class="btn1" width="75%" valign="absmiddle">' . tep_image_submit('button_add_to_cart1.gif', IMAGE_BUTTON_IN_CART, 'align=absmiddle') . '</td></tr></table></form>' . tep_draw_textarea_field('notes_'.$products[$i]['id'],'soft', 10, 1,$notevalue) . tep_draw_hidden_field('products_id[]', $products[$i]['id']);
 //$p_buy_now = '<a href="'.tep_href_link("products_new.php","action=buy_now&products_id=".$p_id).'">'.tep_image_button('button_add_to_cart1.gif', '', ' class="btn1"') . '<table cellSpacing="0" cellPadding="0" width="100%"><tr><td align="right" width="25%">' . tep_draw_input_field('buyqty', '1', 'size=2 maxlength=2') . '</td><td align="center" width="75%" valign="absmiddle">' . '</td></tr></table></form>'.'</a>';


$info_box_contents[$my_row][$my_col] = array('align' => 'center',
                                          'params' => ' style="width:1px;"',
                                          'text' => ''.tep_draw_prod2_top().'
<table cellpadding="0" cellspacing="0" border="0"><tr><td class="pic2_padd">'.tep_draw_prod_pic_top().''.$p_pic.''.tep_draw_prod_pic_bottom().'</td></tr></table>
<table cellpadding="0" cellspacing="0" border="0" class="wrapper_box">
	<tr><td class="price2_padd"><b>'.PRICE.':</b> '.$p_price.'</td></tr>
	<tr><td class="name name2_padd">'.$p_name.'</td></tr>
	<tr><td class="desc desc2_padd">'.$p_desc.'</td></tr>	
	<tr><td class="listing2_padd">'.$p_listing.'</td></tr>				

	<tr><td class="button2_padd">
		<table cellpadding="0" cellspacing="0" border="0">
			<tr>
			    <td>'.$p_notez.'</td>
				<td>'.$p_buy_now .'</td>
			</tr>
		</table>
	</td></tr>
</table>									   
'.tep_draw_prod2_bottom().'');

   $my_col ++;
   if ($my_col > 2) {
     $my_col = 0;
	$my_row ++;
     }
   }
new contentBox($info_box_contents); 
//    new productListingBox($list_box_contents);
} else {  ?>
<?php echo tep_draw1_top(); ?>

			<table cellpadding="0" cellspacing="0" class="main">
				<tr><td style="padding:25px 20px 20px 20px;"><?php echo TEXT_NO_PRODUCTS ?></td></tr>
			</table>

<?php echo tep_draw1_bottom();?>                

<?php			
}
?>

<?php
 if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
?>

<?php echo tep_draw_result2_top(); ?> 

	<table border="0" cellspacing="0" cellpadding="0" class="result result_bottom_padd">
         <tr>
           <td><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
           <td class="result_right" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
         </tr>
       </table>

<?php echo tep_draw_result2_bottom(); ?> 

<?php
 }
?>
<?php echo tep_draw3_bottom();?>

  • 3 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...