Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Add quantity box on product page 2.3.1


peteravu

Recommended Posts

See how it looks now via the link below in my signature.

 

1. Like to make a grid to list it nice. But need help

2. Like to add a plus minus button to each box. But need help

 

 

I modified Multi Attribute (combination) entry boxes in product info page. to this:

 


============================================
1) In the includes/application_top.php file:
============================================

=====
Find:
=====
// Shopping cart actions
 if (isset($HTTP_GET_VARS['action'])) {

====================
ABOVE that code ADD:
====================
	  /////////////////////////////////////////////////////////////////////////						
	  //BOF Multi Attribute (combination) entry boxes in product info page v2.0
	  //Count how many options a product owns
	  $products_options_total_query = tep_db_query("
	  select count(DISTINCT options_id) as total
	  from " . TABLE_PRODUCTS_ATTRIBUTES . "
	  where products_id='" . (int)$HTTP_GET_VARS['products_id'] . "'");
	  $products_options_total = tep_db_fetch_array($products_options_total_query);
	  // $products_options_total['total'] ;
	  //EOF Multi Attribute (combination) entry boxes in product info page v2.0
	  /////////////////////////////////////////////////////////////////////////


========
Now find:
========
$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $attributes))+1, $attributes);

=======================
REPLACE that code with:
=======================

/////////////////////////////////////////////////////////////////////////						
  //BOF Multi Attribute (combination) entry boxes in product info page v2.0						
if ($products_options_total['total'] != 1) {
  //standard add to cart function when 0 or more than 1 option with attributes									  
  $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id'])) + $HTTP_POST_VARS['cart_quantity'], $HTTP_POST_VARS['id']);

} else {

 // Code segment includes/modified for Multiple product option lines.
// maintainance and Qns : Harishyam :> [email="[email protected]"][email protected][/email]
for($i=0;$i<99;$i++)
  {
  $qty_str = $i.'_quantity';
  $arr = array();
  $arr = $HTTP_POST_VARS[$i.'_id'];
  $qty = $HTTP_POST_VARS[$i.'_quantity'];
  $opt = $i.'_id';
//When having an attribute with zero quantity it would still be added to the cart, we don't want this.
  if ($qty != 0) {
  $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $arr))+$qty, $arr);
  }
  //end of that fix
  }
 // End of Code segment includes/modified for Multiple product option lines.
// maintainance and Qns : Harishyam :> [email="[email protected]"][email protected][/email]	  


}   //EOF Multi Attribute (combination) entry boxes in product info page v2.0		
 /////////////////////////////////////////////////////////////////////////


=============
Save the file
=============


================================
2) Open catalog/product_info.php
================================

=====
Find:
=====
<p><?php echo TEXT_PRODUCT_OPTIONS; ?></p>
<p>
<?php

============
REPLACE with
============

<p><?php echo TEXT_PRODUCT_OPTIONS; ?></p>
<p>
<!--
		// Code segment includes/modified for Multiple product option lines.
 // maintainance and Qns : Harishyam :> [email="[email protected]"][email protected][/email]
-->
<?php	
	if ($products_options_total['total'] == 1) {
  for($i=0;$i<$products_attributes['total'];$i++)
  {



=============================
Find the code
=============================

if (is_string($HTTP_GET_VARS['products_id']) && 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;
	}
?>

================================================
Add after
================================================
  <tr>
	 <td class="main"><?php echo $products_options_name['products_options_name'] . ':'; ?></td>
	 <td class="main"><?php echo tep_draw_hidden_field($i.'_id[' . $products_options_name['products_options_id'] . ']', $products_options_array[$i]['id']) . $products_options_array[$i]['text']; ?></td>

<?php			

  // echo '<td><input type="text" name='.$i.'_quantity value="0" size="5"></td>';
  echo '<td><input type="text" name='.$i.'_quantity value="0" size="5"></td>';
  echo "</tr>";


 } } // End of loop
} else {
//do your regular thing


  $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 . "'");
	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;
	}
 }	  
?>

=============================
Find the code
=============================
<span class="buttonAction"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_draw_button(IMAGE_BUTTON_IN_CART, 'cart', null, 'primary'); ?></span>

============
REPLACE with
============
   <span class="buttonAction"><?php if ($products_options_total['total'] != 1) { echo 'Enter Quantity: ' . tep_draw_input_field('cart_quantity','1','size="3"') . ' ' ; } ?>
<?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_draw_button(IMAGE_BUTTON_IN_CART, 'cart', null, 'primary'); ?></span>


=====
DONE!
=====

Link to comment
Share on other sites

1. Like to make a grid to list it nice like in 2 or 3 columns. But need help

2. Like to add a plus minus button to each box. But need help

 

See how the product page looks now via the link below in my signature.

Link to comment
Share on other sites

1. Like to make a grid to list it nice like in 2 or 3 columns. But need help

2. Like to add a plus minus button to each box. But need help

 

See how the product page looks now via the link below in my signature.

Link to comment
Share on other sites

See how it looks now via the link below in my signature.

 

1. Like to make a grid to list it nice. But need help

2. Like to add a plus minus button to each box. But need help

See how it looks now via the link below in my signature.

 

1. Like to make a grid to list it nice. But need help

2. Like to add a plus minus button to each box. But need help

 

 

I modified Multi Attribute (combination) entry boxes in product info page. to this:

 


============================================
1) In the includes/application_top.php file:
============================================

=====
Find:
=====
// Shopping cart actions
 if (isset($HTTP_GET_VARS['action'])) {

====================
ABOVE that code ADD:
====================
	  /////////////////////////////////////////////////////////////////////////						
	  //BOF Multi Attribute (combination) entry boxes in product info page v2.0
	  //Count how many options a product owns
	  $products_options_total_query = tep_db_query("
	  select count(DISTINCT options_id) as total
	  from " . TABLE_PRODUCTS_ATTRIBUTES . "
	  where products_id='" . (int)$HTTP_GET_VARS['products_id'] . "'");
	  $products_options_total = tep_db_fetch_array($products_options_total_query);
	  // $products_options_total['total'] ;
	  //EOF Multi Attribute (combination) entry boxes in product info page v2.0
	  /////////////////////////////////////////////////////////////////////////


========
Now find:
========
$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $attributes))+1, $attributes);

=======================
REPLACE that code with:
=======================

/////////////////////////////////////////////////////////////////////////						
  //BOF Multi Attribute (combination) entry boxes in product info page v2.0						
if ($products_options_total['total'] != 1) {
  //standard add to cart function when 0 or more than 1 option with attributes									  
  $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id'])) + $HTTP_POST_VARS['cart_quantity'], $HTTP_POST_VARS['id']);

} else {

 // Code segment includes/modified for Multiple product option lines.
// maintainance and Qns : Harishyam :> [email="[email protected]"][email protected][/email]
for($i=0;$i<99;$i++)
  {
  $qty_str = $i.'_quantity';
  $arr = array();
  $arr = $HTTP_POST_VARS[$i.'_id'];
  $qty = $HTTP_POST_VARS[$i.'_quantity'];
  $opt = $i.'_id';
//When having an attribute with zero quantity it would still be added to the cart, we don't want this.
  if ($qty != 0) {
  $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $arr))+$qty, $arr);
  }
  //end of that fix
  }
 // End of Code segment includes/modified for Multiple product option lines.
// maintainance and Qns : Harishyam :> [email="[email protected]"][email protected][/email]	  


}   //EOF Multi Attribute (combination) entry boxes in product info page v2.0		
 /////////////////////////////////////////////////////////////////////////


=============
Save the file
=============


================================
2) Open catalog/product_info.php
================================

=====
Find:
=====
<p><?php echo TEXT_PRODUCT_OPTIONS; ?></p>
<p>
<?php

============
REPLACE with
============

<p><?php echo TEXT_PRODUCT_OPTIONS; ?></p>
<p>
<!--
		// Code segment includes/modified for Multiple product option lines.
 // maintainance and Qns : Harishyam :> [email="[email protected]"][email protected][/email]
-->
<?php	
	if ($products_options_total['total'] == 1) {
  for($i=0;$i<$products_attributes['total'];$i++)
  {



=============================
Find the code
=============================

if (is_string($HTTP_GET_VARS['products_id']) && 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;
	}
?>

================================================
Add after
================================================
  <tr>
	 <td class="main"><?php echo $products_options_name['products_options_name'] . ':'; ?></td>
	 <td class="main"><?php echo tep_draw_hidden_field($i.'_id[' . $products_options_name['products_options_id'] . ']', $products_options_array[$i]['id']) . $products_options_array[$i]['text']; ?></td>

<?php			

  // echo '<td><input type="text" name='.$i.'_quantity value="0" size="5"></td>';
  echo '<td><input type="text" name='.$i.'_quantity value="0" size="5"></td>';
  echo "</tr>";


 } } // End of loop
} else {
//do your regular thing


  $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 . "'");
	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;
	}
 }	  
?>

=============================
Find the code
=============================
<span class="buttonAction"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_draw_button(IMAGE_BUTTON_IN_CART, 'cart', null, 'primary'); ?></span>

============
REPLACE with
============
   <span class="buttonAction"><?php if ($products_options_total['total'] != 1) { echo 'Enter Quantity: ' . tep_draw_input_field('cart_quantity','1','size="3"') . ' ' ; } ?>
<?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_draw_button(IMAGE_BUTTON_IN_CART, 'cart', null, 'primary'); ?></span>


=====
DONE!
=====

See how it looks now via the link below in my signature.

 

1. Like to make a grid to list it nice. But need help

2. Like to add a plus minus button to each box. But need help

Link to comment
Share on other sites

Ok now it is listing nearly like I want it.

How to split the attributes after 15 and list them in a new column?

 

this is the code now

echo '<tr><li><td><input type="text" name='.$i.'_quantity value="" style="text-align:right;" size="3"></td> ';
echo tep_draw_hidden_field($i.'_id[' . $products_options_name['products_options_id'] . ']', $products_options_array[$i]['id']) . $products_options_array[$i]['text'];  
  echo "</li></tr>";

Link to comment
Share on other sites

Ok now it is listing nearly like I want it.

How to split the attributes after 15 and list them in a new column?

 

this is the code now

echo '<tr><li><td><input type="text" name='.$i.'_quantity value="" style="text-align:right;" size="3"></td> ';
echo tep_draw_hidden_field($i.'_id[' . $products_options_name['products_options_id'] . ']', $products_options_array[$i]['id']) . $products_options_array[$i]['text'];  
  echo "</li></tr>";

I really like to split this list up for every 15 attributes, but still not find the way to do it!!!

When that is done I will upload this as a new contribution for 2.3.1

Link to comment
Share on other sites

I did not read the topic, so just 2 comments

 

1) I don't this that this <tr><li><td> is a correct html. The <li> has nothing to do after the <tr>. If you need an unordered list somewhere it has to start and end with <ul></ul> and you can place it within a <td></td>

 

2) To do something after 15 rows you need to count them first.

 

Before the loop start you need to say $my_counter = 0;

Then within the loop, (each row) add 1 to the counter $my_counter = ++

Then check if the counter has reached a point

 

if ($my_counter == 15) {

$my_counter = 0;

// anything else you want to do

}

Link to comment
Share on other sites

Tanks George

I tried this, but I don’t have much knowledge of coding.

So I don’t know “// anything else you want to do” will be what?

Also when I add the <ul> they make a space between each row on 3 mm that I don’t want and I can’t find out how to get take away that space.

 

This is what I come up with so far, what is missing?

if ($products_options_name == 15) {
$products_options_name = 0;
// anything else you want to do
}
 echo '<tr><td><ul><li style="list-style: none; "><input type="text" name='.$i.'_quantity value="" style="text-align:right;" size="3"> ';
echo tep_draw_hidden_field($i.'_id[' . $products_options_name['products_options_id'] . ']', $products_options_array[$i]['id']) . $products_options_array[$i]['text'];   
  echo "</li></ul></td></tr>";

Link to comment
Share on other sites

If I do like this it show only atribute number 15 (not 1-14)

 

  if ($products_options_array[$i]['id'] == 15) {
$products_options_array[$i]['id'] = 0;
// anything else you want to do
 echo '<tr><td><ul><li style="list-style: none; "><input type="text" name='.$i.'_quantity value="" style="text-align:right;" size="3"> ';
echo tep_draw_hidden_field($i.'_id[' . $products_options_name['products_options_id'] . ']', $products_options_array[$i]['id']) . $products_options_array[$i]['text'];   
  echo "</li></ul></td></tr>";


}  } }

Need to show attribute 1-15 than split the listing so row 16-30 come in new column split again and show the next 15 atributes

Link to comment
Share on other sites

Need to show attribute 1-15 than split the listing so row 16-30 come in new column split again and show the next 15 atributes

What is wrong in this code

$count	  = 0;
$maxPerList = 15;
echo '<ul style="list-style: none; padding-left: 0px; margin: 0px; "><li style="list-style: none; "><input type="text" name='.$i.'_quantity value="" style="text-align:right;" size="3"> ';
echo tep_draw_hidden_field($i.'_id[' . $products_options_name['products_options_id'] . ']', $products_options_array[$i]['id']) . $products_options_array[$i]['text'];  
echo "<ul>";
foreach($products_options_name as $currValue) {
if($count == $maxPerList) {
echo "</ul>";
echo "<ul>";
$count = 0;
}  
echo "</li>";	
$count++;
echo "</ul>";

this is the whole file

<?php
/*
 $Id$
 adapted for Separate Pricing Per Customer v4.2 2007/06/23
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com
 Copyright (c) 2010 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);
// BOF Separate Pricing per Customer
 if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '0') {
$customer_group_id = $_SESSION['sppc_customer_group_id'];
 } else {
$customer_group_id = '0';
 }
// EOF Separate Pricing per Customer
 require(DIR_WS_INCLUDES . 'template_top.php');
 if ($product_check['total'] < 1) {
?>
<div class="contentContainer">
 <div class="contentText">
<?php echo TEXT_PRODUCT_NOT_FOUND; ?>
 </div>
 <div style="float: right;">
<?php echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'triangle-1-e', tep_href_link(FILENAME_DEFAULT)); ?>
 </div>
</div>
<?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'])) {
// BOF Separate Pricing per Customer
  if ($customer_group_id > 0) { // only need to check products_groups if customer is not retail
	$scustomer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id']. "' and customers_group_id =  '" . $customer_group_id . "'");
	if ($scustomer_group_price = tep_db_fetch_array($scustomer_group_price_query)) {
	  $product_info['products_price']= $scustomer_group_price['customers_group_price'];
   }
  } // end if ($customer_group_id > 0)
// EOF Separate Pricing per Customer
  $products_price = '<del>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</del> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>';
} else {
// BOF Separate Pricing per Customer
  if ($customer_group_id > 0) { // only need to check products_groups if customer is not retail
	$scustomer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id']. "' and customers_group_id =  '" . $customer_group_id . "'");
	if ($scustomer_group_price = tep_db_fetch_array($scustomer_group_price_query)) {
 $product_info['products_price']= $scustomer_group_price['customers_group_price'];
}
  } // end if ($customer_group_id > 0)
// EOF Separate Pricing per Customer
  $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'];
}
?>
<?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product')); ?>
<div>
 <style="float: right;"><?php echo $products_price; ?>
 <h1><?php echo $products_name; ?></h1>
</div>
<div class="contentContainer">
 <div class="contentText">
<?php
if (tep_not_null($product_info['products_image'])) {
  $pi_query = tep_db_query("select image, htmlcontent from " . TABLE_PRODUCTS_IMAGES . " where products_id = '" . (int)$product_info['products_id'] . "' order by sort_order");
  if (tep_db_num_rows($pi_query) > 0) {
?>
<div id="piGal" style="float: right;">
  <ul>
<?php
	$pi_counter = 0;
	while ($pi = tep_db_fetch_array($pi_query)) {
	  $pi_counter++;
	  $pi_entry = '		<li><a href="';
	  if (tep_not_null($pi['htmlcontent'])) {
		$pi_entry .= '#piGalimg_' . $pi_counter;
	  } else {
		$pi_entry .= tep_href_link(DIR_WS_IMAGES . $pi['image']);
	  }
	  $pi_entry .= '" target="_blank" rel="fancybox">' . tep_image(DIR_WS_IMAGES . $pi['image']) . '</a>';
	  if (tep_not_null($pi['htmlcontent'])) {
		$pi_entry .= '<div style="display: none;"><div id="piGalimg_' . $pi_counter . '">' . $pi['htmlcontent'] . '</div></div>';
	  }
	  $pi_entry .= '</li>';
	  echo $pi_entry;
	}
?>
  </ul>
</div>
<script type="text/javascript">
$('#piGal ul').bxGallery({
 maxwidth: 300,
 maxheight: 200,
 thumbwidth: <?php echo (($pi_counter > 1) ? '75' : '0'); ?>,
 thumbcontainer: 300,
 load_image: 'ext/jquery/bxGallery/spinner.gif'
});
</script>
<?php
  } else {
?>
<div id="piGal" style="float: right;">
  <?php echo '<a href="' . tep_href_link(DIR_WS_IMAGES . $product_info['products_image']) . '" target="_blank" rel="fancybox">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], addslashes($product_info['products_name']), null, null, 'hspace="5" vspace="5"') . '</a>'; ?>
</div>
<?php
  }
?>
<script type="text/javascript">
$("#piGal a[rel^='fancybox']").fancybox({
 cyclic: true
});
</script>
<?php
}
?>
<?php echo stripslashes($product_info['products_description']); ?>
<?php
// BOF SPPC Hide attributes from customer groups
$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 . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 ");
$products_attributes = tep_db_fetch_array($products_attributes_query);
if ($products_attributes['total'] > 0) {
?>
<p><?php echo TEXT_PRODUCT_OPTIONS; ?></p>
<p>
<!--
		// Code segment includes/modified for Multiple product option lines.
 // maintainance and Qns : Harishyam :> [email protected]
-->
<?php	
	if ($products_options_total['total'] == 1) {
  for($i=0;$i<$products_attributes['total'];$i++)
  {
  $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 . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 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, pa.products_attributes_id 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 . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0");
$list_of_prdcts_attributes_id = '';
$products_options = array(); // makes sure this array is empty again
	while ($_products_options = tep_db_fetch_array($products_options_query)) {
 $products_options[] = $_products_options;
 $list_of_prdcts_attributes_id .= $_products_options['products_attributes_id'].",";
}
if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0') {
  $select_list_of_prdcts_attributes_ids = "(" . substr($list_of_prdcts_attributes_id, 0 , -1) . ")";
  $pag_query = tep_db_query("select products_attributes_id, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " where products_attributes_id IN " . $select_list_of_prdcts_attributes_ids . " AND customers_group_id = '" . $customer_group_id . "'");
  while ($pag_array = tep_db_fetch_array($pag_query)) {
   $cg_attr_prices[] = $pag_array;
  }

  // substitute options_values_price and prefix for those for the customer group (if available)
  if ($customer_group_id != '0' && tep_not_null($cg_attr_prices)) {
   for ($n = 0 ; $n < count($products_options); $n++) {
	for ($i = 0; $i < count($cg_attr_prices) ; $i++) {
	 if ($cg_attr_prices[$i]['products_attributes_id'] == $products_options[$n]['products_attributes_id']) {
	  $products_options[$n]['price_prefix'] = $cg_attr_prices[$i]['price_prefix'];
	  $products_options[$n]['options_values_price'] = $cg_attr_prices[$i]['options_values_price'];
	 }
	} // end for ($i = 0; $i < count($cg_att_prices) ; $i++)
   }
  } // end if ($customer_group_id != '0' && (tep_not_null($cg_attr_prices))
 } // end if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0')
 for ($n = 0 ; $n < count($products_options); $n++) {
  $products_options_array[] = array('id' => $products_options[$n]['products_options_values_id'], 'text' => $products_options[$n]['products_options_values_name']);
  if ($products_options[$n]['options_values_price'] != '0') {
   $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options[$n]['price_prefix'] . $currencies->display_price($products_options[$n]['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
  }
 }
// EOF SPPC attributes mod
	if (is_string($HTTP_GET_VARS['products_id']) && 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;
}
?>


<?php			
$count	  = 0;
$maxPerList = 15;
echo '<ul style="list-style: none; padding-left: 0px; margin: 0px; "><li style="list-style: none; "><input type="text" name='.$i.'_quantity value="" style="text-align:right;" size="3"> ';
echo tep_draw_hidden_field($i.'_id[' . $products_options_name['products_options_id'] . ']', $products_options_array[$i]['id']) . $products_options_array[$i]['text'];  
echo "<ul>";
foreach($products_options_name as $currValue) {
if($count == $maxPerList) {
echo "</ul>";
echo "<ul>";
$count = 0;
}  
echo "</li>";	
$count++;
echo "</ul>";
 } } // End of loop
} else {
//do your regular thing


  $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 . "'");
	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;
	}
 }	  
?>
  <strong><?php echo $products_options_name['products_options_name'] . ':'; ?></strong><br /><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?><br />
<?php
  }
?>
</p>
<?php
}
?>
<div style="clear: both;"></div>
<?php
if ($product_info['products_date_available'] > date('Y-m-d H:i:s')) {
?>
<p style="text-align: center;"><?php echo sprintf(TEXT_DATE_AVAILABLE, tep_date_long($product_info['products_date_available'])); ?></p>
<?php
}	
?>
 </div>
<?php
$reviews_query = tep_db_query("select count(*) as count from " . TABLE_REVIEWS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and reviews_status = 1");
$reviews = tep_db_fetch_array($reviews_query);
?>
 <div class="buttonSet">
<span class="buttonAction"><?php if ($products_options_total['total'] != 1) { echo 'Enter Quantity: ' . tep_draw_input_field('cart_quantity','1','size="3" style="text-align:right;"') . ' ' ; } ?>
<?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_draw_button(IMAGE_BUTTON_IN_CART, 'cart', null, 'primary'); ?></span>
</div>
<?php
if ((USE_CACHE == 'true') && empty($SID)) {
  echo tep_cache_also_purchased(3600);
} else {
  include(DIR_WS_MODULES . FILENAME_ALSO_PURCHASED_PRODUCTS);
}
?>
</div>
</form>
<?php
 }
 require(DIR_WS_INCLUDES . 'template_bottom.php');
 require(DIR_WS_INCLUDES . 'application_bottom.php');
?>

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...