Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Product Listing w/attirbutes


queasyprawn

Recommended Posts

Hello All,

 

I figure I would try to ask my question in a different way. How would I take the code below and create a table with three columns. The first column will have the attributes table (nested inside the first column), the next will have the Qty box and the last will ahve the buy now button.

 

So as you might have guessed, I'm not too good with php code. Just not sure how to properly put in the table tags into the PHP.

 

Please let me know.

 

Thanks in advance,

 

txcrew

 

 // Begin Buy Now button with attributes and quantity mod 
	  case 'PRODUCT_LIST_BUY_NOW': 
		$lc_align = 'center'; 
		$lc_text = '<form name="buy_now_' . $listing['products_id'] . '" method="post" action="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now_form', 'NONSSL') . '">';
		$lc_text .= 'Qty: <input type="text" name="cart_quantity" value="1" maxlength="6" size="4">'; 
		$lc_text .= '<input type="hidden" name="products_id" value="' . $listing['products_id'] . '">' . tep_image_submit('button_buy_now.gif', TEXT_BUY . $listing['products_name'] . TEXT_NOW) . ' '; 
		$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 = '" . $listing['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "'"); 
		$product_info = tep_db_fetch_array($product_info_query); 
		$products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . $listing['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'"); 
		$products_attributes = tep_db_fetch_array($products_attributes_query); 
		if ($products_attributes['total'] > 0) { 
		$lc_text .= '<table border="0" cellpadding="0" cellspacing"0">'; 
		$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='" . $listing['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'"); 
		while ($products_options_name = tep_db_fetch_array($products_options_name_query)) { 
		$selected = 0; 
		$products_options_array = array(); 
		$lc_text .= '<tr><td class="main">' . $products_options_name['products_options_name'] . ':</td><td>' . "\n"; 
		$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 = '" . $listing['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 . "'"); 
		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'])) .') '; 
	  } 
	} 
	$lc_text .= tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']]); 
	$lc_text .= '</td></tr>'; 
  } 
  $lc_text .= '</table>'; 
} 
  $lc_text .= '</form>'; 
		break; 
// End Buy Now button mod

Link to comment
Share on other sites

Ok figured it out, here is my code if anyone else wants it:

case 'PRODUCT_LIST_BUY_NOW': 
		$lc_align = 'right'; 
		$lc_text = '<form name="buy_now_' . $listing['products_id'] . '" method="post" action="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now_form', 'NONSSL') . '">';
		$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 = '" . $listing['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "'"); 
		$product_info = tep_db_fetch_array($product_info_query); 
		$products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . $listing['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'"); 
		$products_attributes = tep_db_fetch_array($products_attributes_query); 
		if ($products_attributes['total'] > 0) { 
		$lc_text .= '<table border="0"><tr><td><table border="0" cellpadding="0" cellspacing"0">'; 
		$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='" . $listing['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'"); 
		while ($products_options_name = tep_db_fetch_array($products_options_name_query)) { 
		$selected = 0; 
		$products_options_array = array(); 
			 //$lc_text .= '<td class="main">' . $products_options_name['products_options_name'] . ':</td><td>' . "\n"; 
		$lc_text .= '<td style="padding-bottom:3px; padding-top:3px; padding-right:10px;">' . "\n"; 
		$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 = '" . $listing['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 . "'"); 
		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'])) .') '; 
	  } 
	} 
	$lc_text .= tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']]); 
	$lc_text .= '</td></tr>'; 
  } 
  $lc_text .= '</table>'; 
} 
  $lc_text .= '</td><td>Qty:<input type="text" name="cart_quantity" value="1" maxlength="6" size="4"></td><td><input type="hidden" name="products_id" value="' . $listing['products_id'] . '">' . tep_image_submit('button_buy_now.gif', TEXT_BUY . $listing['products_name'] . TEXT_NOW) . ' </td></tr></table></form>'; 
		break;

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