Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

Posted

Hi,

 

I've been looking for a contribution that will be suitable for my cart. I need to be able to have a quantity box next to each attribute and so far I haven't found an attribute that is suitable. I did however find this contribution;

 

Multi Attribute (combination) entry boxes in product info page. for osCommerce Online Merchant v2.2

 

which adds 1 quantity box for all attributes, it's supposed to be so users can select each attribute and then add to cart(so for example colour;pink size;large giftwrap;yes) but what I would like is a quantity box next to each attribute, at the moment it looks like this;

 

 

Colour [options] size [options] Gift wrap [options] [qty box]

 

and I'd like it to look like this;

 

 

Colour [options] [qty box]

Size [options] [qty box]

Gift wrap [options] [qty box]

 

I'm not very good with PHP so I'd appreciate it if someone could advise me on how to do this, here are the code snippets for the contribution;

 

catalog/product_info;

 

<?php
		for($i=0;$i<5;$i++)
		{
	      echo "<tr>";
	 $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_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 . "'");
		   $j =0;
	   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;
	  }
?>
	      <td class="main"><?php echo $products_options_name['products_options_name'] . ':'; ?></td>
	      <td class="main"><?php echo tep_draw_pull_down_menu($i.'_id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?></td>

<?php         	   
	 }
	  echo '<td><input type="text" name='.$i.'_quantity value="0" size="5"></td>';
		  echo "</tr>";
		} // display 5 times loop
?>
	  </table>

 

 

catalog/includes/application_top;

 

for($i=0;$i<5;$i++)
	{
	 $qty_str = $i.'_quantity';
	 $arr = array();
	 $arr = $HTTP_POST_VARS[$i.'_id'];
	 $qty = $HTTP_POST_VARS[$i.'_quantity'];
//echo " the quantity and option " . $i . " is: ".. ' and qty  is: ' . $qty . 'or ' .$HTTP_POST_VARS[$i.'_quantity'];
	 $opt = $i.'_id';
	 $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $arr))+$qty, $arr);
	}

Posted

Just bumping this up again as I really need help with this, thanks :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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...