Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

direct buy box


Guest

Recommended Posts

i would like to know how to have about 10 or 20 boxes where someone can key in the part numbers and quantity they want to buy, if not a right part number, it just flags the wrong one, others go into the shopping cart. would like to do it without the dropdown boxes which the direct buy contribution uses, any ideas?

 

http://www.oscommerce.com/community/contri...arch,direct+buy

 

here is some of the code:

for ($i=1; $i<21; $i++) {
    if (tep_not_null($directbuy_product[$i])){
        $directbuy_query = tep_db_query("select products_id, products_model from " . TABLE_PRODUCTS . " where products_model = '" . $directbuy_product[$i] . "'");
        if (!tep_db_num_rows($directbuy_query)) {
            $directbuy_query = tep_db_query("select products_id, products_model from " . TABLE_PRODUCTS . " where products_model LIKE '%" . $directbuy_product[$i] . "%'");
            }
        if (tep_db_num_rows($directbuy_query) != 1) {
            $error_str .= DIRECTBUY_ERROR_ONE . '<br>';
            }
        $directbuy = tep_db_fetch_array($directbuy_query);
        if (tep_has_product_attributes($directbuy['products_id'])) {
            $error_str .= DIRECTBUY_ERROR_TWO . '<br>';
            } else {
            $cart->add_cart($directbuy['products_id'], $cart->get_quantity($directbuy['products_id']) + $directbuy_qty[$i], false);
   }
     }
    }

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

 $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_DIRECTBUY));
?>
<!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="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"><table border="0" width="100%" cellspacing="0" cellpadding="0">
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
           <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_cart.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
         <tr>
           <td class="main"><?php echo TEXT_INFORMATION; ?></td>
         </tr>
       </table></td>
     </tr>
<tr>
       <td><br>
 <? echo tep_draw_form('directbuy', tep_href_link(FILENAME_DIRECTBUY, 'action=directbuy'), 'post'); ?>
 <table border="0" width="100%" cellspacing="0" cellpadding="2">
         <tr>
           <td class="main"><?php echo DIRECTBUY_QUANTITY; ?></td>
	 <td class="main"><?php echo DIRECTBUY_PRODUCT; ?></td>
	 <td class="main"> </td>
	 <td class="main"><?php echo DIRECTBUY_QUANTITY; ?></td>
	 <td class="main"><?php echo DIRECTBUY_PRODUCT; ?></td>
         </tr>
<?php 
for ($i=1; $i<21; $i++) {
?>
   <tr>
           <td class="main"><?php echo tep_draw_input_field('directbuy_qty[' . $i . ']', '', 'size="2" maxlength="5"'); ?></td>
	 <td class="main"><?php 	 
	 $products_array = array();
         $products_query = tep_db_query("select distinct products_model from " . TABLE_PRODUCTS . " p where p.products_status = '1' order by products_model");
      	 while ($products_values = tep_db_fetch_array($products_query)) {
        	 $products_array[] = array('id' => $products_values['products_model'], 'text' => $products_values['products_model']);
       }
	 if (count($products_array) > 0) {
        	 echo tep_draw_pull_down_menu('directbuy_product[' . $i . ']', $products_array);
 }
   ?>
   
	 </td>
	 <td class="main"> </td>
	 <?php $i++;?>
	 <td class="main"><?php echo tep_draw_input_field('directbuy_qty[' . $i . ']', '', 'size="2" maxlength="5"'); ?></td>
	 <td class="main"><?php
	 $products_array = array();
         $products_query = tep_db_query("select distinct products_model from " . TABLE_PRODUCTS . " p where p.products_status = '1' order by products_model");
      	 while ($products_values = tep_db_fetch_array($products_query)) {
        	 $products_array[] = array('id' => $products_values['products_model'], 'text' => $products_values['products_model']);
       }
	 if (count($products_array) > 0) {
        	 echo tep_draw_pull_down_menu('directbuy_product[' . $i . ']', $products_array);
 }
   ?>
   </td>
         </tr>
<?php }?>    
   <tr>
           <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '10'); ?></td>
         </tr>
       </table>
 </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 tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>
               <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
             </tr>
           </table></form></td>
         </tr>
       </table></td>
     </tr>
   </table></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>

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...