Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Attributes problems in Multiple Products with plus/minus buttons


peteravu

Recommended Posts

I have installed Add Multiple Products with plus/minus buttons

 

 

Very nice add.

The only problem is products with Attributes, the Attributes do not show, and product with Attributes don not add to the Shopping Cart.

The minimum must be that Attributes is showed and add to the shopping cart.

The best would be that each Attributes was listed and could be added to the shopping cart with the plus and minus buttons.

But how to make that?

Link to comment
Share on other sites

Any body know how to get the attributes to work?

 

after trying to change product_listing_multi to work with Separate Pricing Per Customer I get

Parse error: syntax error, unexpected T_ELSE in C:\Program Files\EasyPHP-5.3.8.0\www\includes\modules\product_listing_multi.php on line 229

What is wrong?

case 'PRODUCT_LIST_BUY_NOW':
$lc_align = 'center';
//$lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing[$x]['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';
$lc_text = '<input type=button value=" -1" onclick="javascript:changeValue(document.getElementById(\'add_id_'.$listing[$x]['products_id'].'\'),-1);return false;"><input type="text" name="add_id['.$number_of_products.']" id="add_id_'.$listing[$x]['products_id'].'" value="0" size="4"><input type=button value="+1" onclick="javascript:changeValue(document.getElementById(\'add_id_'.$listing[$x]['products_id'].'\'),1);return false;">';
$lc_text .= '<input type="hidden" name="products_id['.$number_of_products.']" value="'.$listing[$x]['products_id'].'">';
break;
}
$list_box_contents[$cur_row][] = array('align' => $lc_align,
'params' => 'class="productListing-data"',
'text' => $lc_text);
}
}
new productListingBox($list_box_contents);
} else {
$list_box_contents = array();
$list_box_contents[0] = array('params' => 'class="productListing-odd"');
$list_box_contents[0][] = array('params' => 'class="productListing-data"',
'text' => TEXT_NO_PRODUCTS);
new productListingBox($list_box_contents);
}
if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
?>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
<td class="smallText" 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>
<br>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td align="right" class="main"><?php echo tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td>
</tr>
</table>
</form>
<?php

This is the whole file

<form name="cart_multi" method="post" action="<?php echo tep_href_link(FILENAME_SHOPPING_CART, tep_get_all_get_params(array('action')) . 'action=add_multi', 'NONSSL'); ?>">
<script language=javascript> function changeValue(textObject,delta){ var myVal = parseInt(textObject.value); if (myVal == NaN) { myVal = 0; } else { myVal = myVal + delta; } /* check that it is not negetive */ if (myVal < 0) { myVal = 0; } textObject.value = myVal; return; } </script>
<?php
/*
$Id: product_listing.php,v 1.44 2003/06/09 22:49:59 hpdl Exp $
adapted for Separate Pricing Per Customer v4.2 2007/08/23
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2003 osCommerce
Released under the GNU General Public License
*/
$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') ) ) {
?>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td align="right" class="main"><?php echo tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td>
</tr>
</table>
<br>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
<td class="smallText" 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
}
$list_box_contents = array();
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;
// START: display min. order. qty. mod
case 'PRODUCT_LIST_MIN_ORDER_QTY':
$lc_align = 'center';
$lc_text = ' ' . TABLE_HEADING_MIN_ORDER_QTY . ' ';
break;
// END: display min. order. qty. mod
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_HEADING_BUY_NOW;
$lc_align = 'center';
break;
}
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);
// BOF Separate Pricing per Customer
$no_of_listings = tep_db_num_rows($listing_query);
// global variable (session) $sppc_customer_group_id -> local variable customer_group_id
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';
}
while ($_listing = tep_db_fetch_array($listing_query)) {
$listing[] = $_listing;
$list_of_prdct_ids[] = $_listing['products_id'];
}
// next part is a debug feature, when uncommented it will print the info that this module receives
/*
echo '<pre>';
print_r($listing);
echo '</pre>';
*/
// get all product prices for products with the particular customer_group_id
// however not necessary for customer_group_id = 0
if ($customer_group_id != '0') {
$pg_query = tep_db_query("select pg.products_id, customers_group_price as price from " . TABLE_PRODUCTS_GROUPS . " pg where products_id in (" . implode(',', $list_of_prdct_ids) . ") and pg.customers_group_id = '" . $customer_group_id . "'");
// $no_of_pg_products = tep_db_num_rows($pg_query) ;
while ($pg_array = tep_db_fetch_array($pg_query)) {
$new_prices[] = array ('products_id' => $pg_array['products_id'], 'products_price' => $pg_array['price'], 'specials_new_products_price' => '', 'final_price' => $pg_array['price']);
}
for ($x = 0; $x < $no_of_listings; $x++) {
// replace products prices with those from customers_group table
if(!empty($new_prices)) {
for ($i = 0; $i < count($new_prices); $i++) {
if( $listing[$x]['products_id'] == $new_prices[$i]['products_id'] ) {
$listing[$x]['products_price'] = $new_prices[$i]['products_price'];
$listing[$x]['final_price'] = $new_prices[$i]['final_price'];
}
}
} // end if(!empty($new_prices)
$listing[$x]['specials_new_products_price'] = ''; // makes sure that a retail specials price doesn't carry over to another customer group
$listing[$x]['final_price'] = $listing[$x]['products_price']; // final price should not be the retail special price
} // end for ($x = 0; $x < $no_of_listings; $x++)
} // end if ($customer_group_id != '0')
// an extra query is needed for all the specials
$specials_query = tep_db_query("select products_id, specials_new_products_price from " . TABLE_SPECIALS . " where products_id in (" . implode(',', $list_of_prdct_ids) . ") and status = '1' and customers_group_id = '" . $customer_group_id . "'");
while ($specials_array = tep_db_fetch_array($specials_query)) {
$new_s_prices[] = array ('products_id' => $specials_array['products_id'], 'products_price' => '', 'specials_new_products_price' => $specials_array['specials_new_products_price'] , 'final_price' => $specials_array['specials_new_products_price']);
}
// add the correct specials_new_products_price and replace final_price
for ($x = 0; $x < $no_of_listings; $x++) {
if(!empty($new_s_prices)) {
for ($i = 0; $i < count($new_s_prices); $i++) {
if( $listing[$x]['products_id'] == $new_s_prices[$i]['products_id'] ) {
$listing[$x]['specials_new_products_price'] = $new_s_prices[$i]['specials_new_products_price'];
$listing[$x]['final_price'] = $new_s_prices[$i]['final_price'];
}
}
} // end if(!empty($new_s_prices)
// while ($listing = tep_db_fetch_array($listing_query)) { (was original code)
for ($x = 0; $x < $no_of_listings; $x++) {
$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 = '';
$lc_text = ' ' . $listing[$x]['products_model'] . ' ';
break;
case 'PRODUCT_LIST_NAME':
$lc_align = '';
if (isset($HTTP_GET_VARS['manufacturers_id'])) {
$lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a>';
} else {
$lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a> ';
}
break;
case 'PRODUCT_LIST_MANUFACTURER':
$lc_align = '';
$lc_text = ' <a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing[$x]['manufacturers_id']) . '">' . $listing[$x]['manufacturers_name'] . '</a> ';
break;
case 'PRODUCT_LIST_PRICE':
$lc_align = 'right';
if (tep_not_null($listing[$x]['specials_new_products_price'])) {
$lc_text = ' <s>' . $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($listing[$x]['specials_new_products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</span> ';
} else {
$lc_text = ' ' . $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . ' ';
}
break;
case 'PRODUCT_LIST_QUANTITY':
$lc_align = 'right';
$lc_text = ' ' . $listing[$x]['products_quantity'] . ' ';
break;
// START: display min. order. qty. mod
case 'PRODUCT_LIST_MIN_ORDER_QTY':
$lc_align = '';
$lc_text = ' ' . $listing[$x]['products_min_order_qty'] . ' ';
break;
// END: display min. order. qty. mod
case 'PRODUCT_LIST_WEIGHT':
$lc_align = 'right';
$lc_text = ' ' . $listing[$x]['products_weight'] . ' ';
break;
case 'PRODUCT_LIST_IMAGE':
$lc_align = 'center';
if (isset($HTTP_GET_VARS['manufacturers_id'])) {
$lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing[$x]['products_image'], $listing[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';
} else {
$lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing[$x]['products_image'], $listing[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a> ';
}
break;
case 'PRODUCT_LIST_BUY_NOW':
$lc_align = 'center';
//$lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing[$x]['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';
$lc_text = '<input type=button value=" -1" onclick="javascript:changeValue(document.getElementById(\'add_id_'.$listing[$x]['products_id'].'\'),-1);return false;"><input type="text" name="add_id['.$number_of_products.']" id="add_id_'.$listing[$x]['products_id'].'" value="0" size="4"><input type=button value="+1" onclick="javascript:changeValue(document.getElementById(\'add_id_'.$listing[$x]['products_id'].'\'),1);return false;">';
$lc_text .= '<input type="hidden" name="products_id['.$number_of_products.']" value="'.$listing[$x]['products_id'].'">';
break;
}
$list_box_contents[$cur_row][] = array('align' => $lc_align,
'params' => 'class="productListing-data"',
'text' => $lc_text);
}
}
new productListingBox($list_box_contents);
} else {
$list_box_contents = array();
$list_box_contents[0] = array('params' => 'class="productListing-odd"');
$list_box_contents[0][] = array('params' => 'class="productListing-data"',
'text' => TEXT_NO_PRODUCTS);
new productListingBox($list_box_contents);
}
if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
?>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
<td class="smallText" 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>
<br>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td align="right" class="main"><?php echo tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td>
</tr>
</table>
</form>
<?php
}
?>

Link to comment
Share on other sites

  • 2 weeks later...

I have installed Add Multiple Products with plus/minus buttons

 

 

Very nice add.

The only problem is products with Attributes, the Attributes do not show, and product with Attributes don not add to the Shopping Cart.

The minimum must be that Attributes is showed and add to the shopping cart.

The best would be that each Attributes was listed and could be added to the shopping cart with the plus and minus buttons.

But how to make that?

I have exactly the same problem, what should we do?

Link to comment
Share on other sites

I have exactly the same problem, what should we do?

I don’t know what we can do, I really hope somebody can help us. But it looks like this oscommerce forum is quiet now, 7 years ago it was very active and helpful. I hope it is because of summer holidays and it will be busier soon.

Link to comment
Share on other sites

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

 

1. Products with Attributes, the Attributes do not show,

2. Product with Attributes does not add to the Shopping Cart.

 

The minimum must be that Attributes is showed and add to the shopping cart.

3. Like each Attributes was listed and could be added to the shopping cart with the plus and minus buttons.

4. Need to change the add to cart button

5. Need to change the background color

To avoid “Parse error: syntax error, unexpected T_ELSE in C:\Program Files\EasyPHP-5.3.8.0\www\includes\modules\product_listing_multi.php on line 230”

I did change } else { to } //else { but I don’t think that is ok????

Link to comment
Share on other sites

<snipped>

I did change } else { to } //else { but I don’t think that is ok????

That is not OK. The error message indicates that you pasted something into the wrong place in the file. That needs to be corrected, not just commented out,

 

The main problem is that you are using an Addon intended for osCommerce 2.2 in a 2.3 site. That takes a bit more work than just blindly copying code. You should probably stick with Addons that are intended for 2.3.1 unless you are willing and able to do the work of converting the Addon.

 

Regards

Jim

Edited by kymation

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

That is not OK. The error message indicates that you pasted something into the wrong place in the file. That needs to be corrected, not just commented out,

 

The main problem is that you are using an Addon intended for osCommerce 2.2 in a 2.3 site. That takes a bit more work than just blindly copying code. You should probably stick with Addons that are intended for 2.3.1 unless you are willing and able to do the work of converting the Addon.

 

Regards

Jim

There are not many add-ons to 2.3.1 so you will recommend me to use 2.2?

I don’t have much knowledge of coding. but I hope someone can help and lead mw on the right track on the 2.3.1.

Link to comment
Share on other sites

If you do decide to use 2.2RC2a, the first thing you need to do is the security updates to that code. Read the pinned topics in the security forum for details. It also has problems with some of the newer version of PHP and MySQL that will have to be patched.

 

2.2RC2a lacks some of the features of 2.3.1 and is harder to work with. You will also be unable to use Addons designed for newer versions. With the (future) release of 2.4 you will be even further behind.

 

Upgrading the Addons that you want to 2.3.1 would be the best path to take. You may need to learn more about PHP to do this. Instructions for the basics of conversion are here, here, and here.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

I will use 2.3.1 and try me best to convert the old addons, I am just surprised how little help and respond there are, bacause I made one oscommerce in 2004 with many stranges futures and got u alot and unbeliveble fast help for this forum. but now it looks very quiret.

So I realy hope some one can help me with those problems.

Now I will look on the links you recomend and try to get more knowlage on PHP.

Do you know whats wrong with the else on line 230?

Link to comment
Share on other sites

You're right; there don't seem to be as many knowledgeable people on the forum as there were in 2004. I do what I can, but I have a very limited amount of time to spend here.

 

I suspect that the else on line 230 is in the wrong place. For reference, the finished code needs to look something like this:

if( $foo == 'something' ) {
// Some code goes here
} else {
// More code goes here
}

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Ok I try start from new, by using my old product_listing.php to make a new product_listing_multi.php

 

by findung the changes that was made on the 2003 product_listing.php to the product_listing_multi.php

 

 

This one I realy need help to translate in to 2.3.1

 

how to change from

$lc_text = '<input type=button value="  -1" onclick="javascript:changeValue(document.getElementById(\'add_id_'.$listing['products_id'].'\'),-1);return  false;"><input type="text" name="add_id['.$number_of_products.']"  id="add_id_'.$listing['products_id'].'" value="0" size="4"><input  type=button value="+1" onclick="javascript:changeValue(document.getElementById(\'add_id_'.$listing['products_id'].'\'),1);return  false;">';
$lc_text .= '<input type="hidden"  name="products_id['.$number_of_products.']"  value="'.$listing['products_id'].'">';

 

 

to the 2.3.1 that now says

case 'PRODUCT_LIST_BUY_NOW':
		$prod_list_contents .= '		<td align="center">' . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing[$x]['products_id'])) . '</td>';
		break;

Link to comment
Share on other sites

changes that I made now is:

 

Add on top of all on line 1 and 2

<form name="cart_multi" method="post" action="<?php echo tep_href_link
(FILENAME_SHOPPING_CART, tep_get_all_get_params(array('action')) . 'action=add_multi',
'NONSSL'); ?>">
<script language=javascript> function changeValue(textObject,delta){  var myVal = parseInt
(textObject.value);  if (myVal == NaN) {   myVal = 0;   } else {  myVal = myVal + delta;  }
/* check that it is not negetive */  if (myVal < 0) {  myVal = 0;  }  textObject.value =
myVal;  return; } </script>

 

 

//find//

 

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

// add after//

<table border="0" width="100%" cellspacing="0" cellpadding="0">
 <tr>
<td align="right" class="main"><?php echo tep_draw_button(IMAGE_BUTTON_IN_CART, 'cart',
null, 'primary'); ?></td>
 </tr>
</table>
<br>

 

 

//find//

 

case 'PRODUCT_LIST_QUANTITY':
	$lc_text = TABLE_HEADING_QUANTITY;
	$lc_align = 'right';
	break;

//add after//

 

	 case 'PRODUCT_LIST_MIN_ORDER_QTY':
	$lc_align = 'center';
	$lc_text = ' ' . TABLE_HEADING_MIN_ORDER_QTY . ' ';
	break;

 

 

//find//

case 'PRODUCT_LIST_QUANTITY':
		$prod_list_contents .= '		<td align="right">' . $listing[$x]
['products_quantity'] . '</td>';
		break;		  

//add after//

case 'PRODUCT_LIST_MIN_ORDER_QTY':
		$prod_list_contents .= '		<td align="right">' . $lc_text = ' ' .
$listing[$x]['products_min_order_qty'] . ' ';
		break;

 

 

 

//find//

 

case 'PRODUCT_LIST_BUY_NOW':
		$prod_list_contents .= '		<td align="center">' . tep_draw_button
(IMAGE_BUTTON_BUY_NOW, 'cart', tep_href_link(basename($PHP_SELF), tep_get_all_get_params
(array('action')) . 'action=buy_now&products_id=' . $listing[$x]['products_id'])) .
'</td>';
		break;

// change to?????//

//$lc_text = '<a href="' . tep_href_link(basename($PHP_SELF),  tep_get_all_get_params
(array('action')) .  'action=buy_now&products_id=' . $listing['products_id']) . '">'  .
tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) .  '</a> ';
$lc_text = '<input type=button value="  -1" onclick="javascript:changeValue
(document.getElementById(\'add_id_'.$listing['products_id'].'\'),-1);return  false;"><input
type="text" name="add_id['.$number_of_products.']"  id="add_id_'.$listing['products_id'].'"
value="0" size="4"><input  type=button value="+1" onclick="javascript:changeValue
(document.getElementById(\'add_id_'.$listing['products_id'].'\'),1);return  false;">';
$lc_text .= '<input type="hidden"  name="products_id['.$number_of_products.']"
value="'.$listing['products_id'].'">';

 

//find at the end//

 

<?php
 }
?>
 </div>

//add before//

<br>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
 <tr>
<td align="right" class="main"><?php echo tep_image_submit('button_in_cart.gif',
IMAGE_BUTTON_IN_CART); ?></td>
 </tr>
</table>
</form>

 

Now the add to cart botton are there and looks like it works even there are nothing to add.

Link to comment
Share on other sites

Ok I try start from new, by using my old product_listing.php to make a new product_listing_multi.php

 

by findung the changes that was made on the 2003 product_listing.php to the product_listing_multi.php

 

 

This one I realy need help to translate in to 2.3.1

 

how to change from

$lc_text = '<input type=button value="  -1" onclick="javascript:changeValue(document.getElementById(\'add_id_'.$listing['products_id'].'\'),-1);return  false;"><input type="text" name="add_id['.$number_of_products.']"  id="add_id_'.$listing['products_id'].'" value="0" size="4"><input  type=button value="+1" onclick="javascript:changeValue(document.getElementById(\'add_id_'.$listing['products_id'].'\'),1);return  false;">';
$lc_text .= '<input type="hidden"  name="products_id['.$number_of_products.']"  value="'.$listing['products_id'].'">';

 

 

to the 2.3.1 that now says

case 'PRODUCT_LIST_BUY_NOW':
		$prod_list_contents .= '		<td align="center">' . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing[$x]['products_id'])) . '</td>';
		break;

What is wrong in this code for the 2.3.1. all bottons only add to the top product and the add to cart botton dont add anything.

case 'PRODUCT_LIST_BUY_NOW':
		$prod_list_contents .= '		<td align="center">' . $lc_text = '<input type=button value="  -1" onclick="javascript:changeValue(document.getElementById(\'add_id_'.$listing['products_id'].'\'),-1);return  false;"><input type="text" name="add_id['.$number_of_products.']"  id="add_id_'.$listing['products_id'].'" value="0" size="4"><input  type=button value="+1" onclick="javascript:changeValue(document.getElementById(\'add_id_'.$listing['products_id'].'\'),1);return  false;">';
	  $lc_text .= '<input type="hidden"  name="products_id['.$number_of_products.']"  value="'.$listing['products_id'].'">';
	 break;

Link to comment
Share on other sites

Ok I try start from new, by using my old product_listing.php to make a new product_listing_multi.php

 

by finding the changes that was made on the 2003 product_listing.php to the product_listing_multi.php

 

 

This one I realy need help to translate in to 2.3.1

 

how to change from

$lc_text = '<input type=button value=" -1" onclick="javascript:changeValue(document.getElementById(\'add_id_'.$listing['products_id'].'\'),-1);return false;"><input type="text" name="add_id['.$number_of_products.']" id="add_id_'.$listing['products_id'].'" value="0" size="4"><input type=button value="+1" onclick="javascript:changeValue(document.getElementById(\'add_id_'.$listing['products_id'].'\'),1);return false;">';
$lc_text .= '<input type="hidden" name="products_id['.$number_of_products.']" value="'.$listing['products_id'].'">';

 

 

to the 2.3.1 that now says

case 'PRODUCT_LIST_BUY_NOW':
$prod_list_contents .= ' <td align="center">' . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing[$x]['products_id'])) . '</td>';
break;

What is wrong in this code for the 2.3.1. all bottons only add to the top product and the add to cart botton dont add anything.

case 'PRODUCT_LIST_BUY_NOW':
		$prod_list_contents .= '		<td align="center">' . $lc_text = '<input type=button value="  -1" onclick="javascript:changeValue(document.getElementById(\'add_id_'.$listing['products_id'].'\'),-1);return  false;"><input type="text" name="add_id['.$number_of_products.']"  id="add_id_'.$listing['products_id'].'" value="0" size="4"><input  type=button value="+1" onclick="javascript:changeValue(document.getElementById(\'add_id_'.$listing['products_id'].'\'),1);return  false;">';
	  $lc_text .= '<input type="hidden"  name="products_id['.$number_of_products.']"  value="'.$listing['products_id'].'">';
	 break;

What is wrong?
Link to comment
Share on other sites

What is wrong in this code for the 2.3.1. all bottons only add to the top product and the add to cart botton dont add anything.

case 'PRODUCT_LIST_BUY_NOW':
$prod_list_contents .= ' <td align="center">' . $lc_text = '<input type=button value=" -1" onclick="javascript:changeValue(document.getElementById(\'add_id_'.$listing['products_id'].'\'),-1);return false;"><input type="text" name="add_id['.$number_of_products.']" id="add_id_'.$listing['products_id'].'" value="0" size="4"><input type=button value="+1" onclick="javascript:changeValue(document.getElementById(\'add_id_'.$listing['products_id'].'\'),1);return false;">';
$lc_text .= '<input type="hidden" name="products_id['.$number_of_products.']" value="'.$listing['products_id'].'">';
break;

How to convert this to 2.3.1? Edited by peteravu
Link to comment
Share on other sites

now the plus and minus buttons works

But the add to card button do not add anything to the shopping cart, how to get it work?

 

	  case 'PRODUCT_LIST_BUY_NOW':
		$prod_list_contents .= '		<td align="center">' . $lc_text = '<input type=button value="  -1" onclick="javascript:changeValue(document.getElementById(\'add_id_'.$listing[$x]['products_id'].'\'),-1);return  false;"><input type="text" name="add_id['.$number_of_products.']"  id="add_id_'.$listing[$x]['products_id'].'" value="0" size="3"><input  type=button value="+1" onclick="javascript:changeValue(document.getElementById(\'add_id_'.$listing[$x]['products_id'].'\'),1);return  false;">';
	  $lc_text .= '<input type="hidden"  name="products_id['.$number_of_products.']"  value="'.$listing[$x]['products_id'].'">';
	 break;		  
	}
  }
  $prod_list_contents .= '	  </tr>';
}
$prod_list_contents .= '	</table>' .
					   '  </div>' .
					   '</div>';
echo $prod_list_contents;
 } else {
?>
<p><?php echo TEXT_NO_PRODUCTS; ?></p>
<?php
 }
 if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
?>
<br />
<div>
  <span style="float: right;"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></span>
  <span><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></span>
</div>
<br>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
 <tr>
<td align="right" class="main"><?php echo tep_draw_button(IMAGE_BUTTON_IN_CART, 'cart', null, 'primary'); ?></td>
 </tr>
</table>
</form>
<?php
 }
?>
 </div>

Edited by peteravu
Link to comment
Share on other sites

  • 3 weeks later...

How to get this button to add to cart? now it dont add anything

 

This is in line 26 and near the end at line 251

<td align="right" class="main"><?php echo tep_draw_button(IMAGE_BUTTON_IN_CART, 'cart', null, 'primary'); ?></td>

<form name="cart_multi" method="post" action="<?php echo tep_href_link(FILENAME_SHOPPING_CART, tep_get_all_get_params(array('action')) . 'action=add_multi', 'NONSSL'); ?>">
<script language=javascript> function changeValue(textObject,delta){  var myVal = parseInt(textObject.value);  if (myVal == NaN) {   myVal = 0;   } else {  myVal = myVal + delta;  }  /* check that it is not negetive */  if (myVal < 0) {  myVal = 0;  }  textObject.value = myVal;  return; } </script>
<?php
/*
 $Id$
 adapted for Separate Pricing Per Customer v4.2 2007/08/23
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com
 Copyright (c) 2010 osCommerce
 Released under the GNU General Public License
*/
 $listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_SEARCH_RESULTS, 'p.products_id');
?>

 <div class="contentText">
<?php
 if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {
?>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
 <tr>
<td align="right" class="main"><?php echo tep_draw_button(IMAGE_BUTTON_IN_CART, 'cart', null, 'primary'); ?></td>
 </tr>
</table>
<br>
<div>
  <span style="float: right;"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></span>
  <span><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></span>
</div>
<br />
<?php
 }
 $prod_list_contents = '<div class="ui-widget infoBoxContainer">' .
					'  <div class="ui-widget-header ui-corner-top infoBoxHeading">' .
					'	<table border="0" width="100%" cellspacing="0" cellpadding="2" class="productListingHeader">' .
					'	  <tr>';
 for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
$lc_align = '';
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_MIN_ORDER_QTY':
	$lc_align = 'center';
	$lc_text = ' ' . TABLE_HEADING_MIN_ORDER_QTY . ' ';
	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_HEADING_BUY_NOW;
	$lc_align = 'center';
	break;
}
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);
}
$prod_list_contents .= '		<td' . (tep_not_null($lc_align) ? ' align="' . $lc_align . '"' : '') . '>' . $lc_text . '</td>';
 }
 $prod_list_contents .= '	  </tr>' .
					 '	</table>' .
					 '  </div>';
 if ($listing_split->number_of_rows > 0) {
$rows = 0;
$listing_query = tep_db_query($listing_split->sql_query);
// BOF Separate Pricing per Customer
$no_of_listings = tep_db_num_rows($listing_query);
// global variable (session) $sppc_customer_group_id -> local variable customer_group_id
 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';
 }
while ($_listing = tep_db_fetch_array($listing_query)) {
$listing[] = $_listing;
$list_of_prdct_ids[] = $_listing['products_id'];
}
// next part is a debug feature, when uncommented it will print the info that this module receives
/*
  echo '<pre>';
  print_r($listing);
  echo '</pre>';
*/
// get all product prices for products with the particular customer_group_id
// however not necessary for customer_group_id = 0
if ($customer_group_id != '0') {
 $pg_query = tep_db_query("select pg.products_id, customers_group_price as price from " . TABLE_PRODUCTS_GROUPS . " pg where products_id in (" . implode(',', $list_of_prdct_ids) . ") and pg.customers_group_id = '" . $customer_group_id . "'");
//   $no_of_pg_products = tep_db_num_rows($pg_query) ;
while ($pg_array = tep_db_fetch_array($pg_query)) {
$new_prices[] = array ('products_id' => $pg_array['products_id'], 'products_price' => $pg_array['price'], 'specials_new_products_price' => '', 'final_price' => $pg_array['price']);
}
for ($x = 0; $x < $no_of_listings; $x++) {
// replace products prices with those from customers_group table
  if(!empty($new_prices)) {
	for ($i = 0; $i < count($new_prices); $i++) {
	 if( $listing[$x]['products_id'] == $new_prices[$i]['products_id'] ) {
	  $listing[$x]['products_price'] = $new_prices[$i]['products_price'];
	  $listing[$x]['final_price'] = $new_prices[$i]['final_price'];
	}
   }
 } // end if(!empty($new_prices)
$listing[$x]['specials_new_products_price'] = ''; // makes sure that a retail specials price doesn't carry over to another customer group
$listing[$x]['final_price'] = $listing[$x]['products_price']; // final price should not be the retail special price
  } // end for ($x = 0; $x < $no_of_listings; $x++)
} // end if ($customer_group_id != '0')
// an extra query is needed for all the specials
$specials_query = tep_db_query("select products_id, specials_new_products_price from " . TABLE_SPECIALS . " where products_id in (" . implode(',', $list_of_prdct_ids) . ") and status = '1' and customers_group_id = '" . $customer_group_id . "'");
while ($specials_array = tep_db_fetch_array($specials_query)) {
$new_s_prices[] = array ('products_id' => $specials_array['products_id'], 'products_price' => '', 'specials_new_products_price' => $specials_array['specials_new_products_price'] , 'final_price' => $specials_array['specials_new_products_price']);
}
// add the correct specials_new_products_price and replace final_price
for ($x = 0; $x < $no_of_listings; $x++) {
if(!empty($new_s_prices)) {
 for ($i = 0; $i < count($new_s_prices); $i++) {
  if( $listing[$x]['products_id'] == $new_s_prices[$i]['products_id'] ) {
  $listing[$x]['specials_new_products_price'] = $new_s_prices[$i]['specials_new_products_price'];
  $listing[$x]['final_price'] = $new_s_prices[$i]['final_price'];
  }
 }
  } // end if(!empty($new_s_prices)
} // end for ($x = 0; $x < $no_of_listings; $x++)
$prod_list_contents .= '  <div class="ui-widget-content ui-corner-bottom productListTable">' .
					   '	<table border="0" width="100%" cellspacing="0" cellpadding="2" class="productListingData">';
//	while ($listing = tep_db_fetch_array($listing_query)) { (was original code)
for ($x = 0; $x < $no_of_listings; $x++) {
  $rows++;
  $prod_list_contents .= '	  <tr>';
  for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
	switch ($column_list[$col]) {
	  case 'PRODUCT_LIST_MODEL':
		$prod_list_contents .= '		<td>' . $listing[$x]['products_model'] . '</td>';
		break;
	  case 'PRODUCT_LIST_NAME':
		if (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {
		  $prod_list_contents .= '		<td><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a></td>';
		} else {
		  $prod_list_contents .= '		<td><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a></td>';
		}
		break;
	  case 'PRODUCT_LIST_MANUFACTURER':
		$prod_list_contents .= '		<td><a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing[$x]['manufacturers_id']) . '">' . $listing[$x]['manufacturers_name'] . '</a></td>';
		break;
	  case 'PRODUCT_LIST_PRICE':
		if (tep_not_null($listing[$x]['specials_new_products_price'])) {
		  $prod_list_contents .= '		<td align="right"><del>' .  $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</del>  <span class="productSpecialPrice">' . $currencies->display_price($listing[$x]['specials_new_products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</span></td>';
		} else {
		  $prod_list_contents .= '		<td align="right">' . $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</td>';
		}
		break;
	  case 'PRODUCT_LIST_QUANTITY':
		$prod_list_contents .= '		<td align="right">' . $listing[$x]['products_quantity'] . '</td>';
		break;		  
	  case 'PRODUCT_LIST_MIN_ORDER_QTY':
		$prod_list_contents .= '		<td align="right">' . $lc_text = ' ' . $listing[$x]['products_min_order_qty'] . ' ';
		break;
	  case 'PRODUCT_LIST_WEIGHT':
		$prod_list_contents .= '		<td align="right">' . $listing[$x]['products_weight'] . '</td>';
		break;
	  case 'PRODUCT_LIST_IMAGE':
		if (isset($HTTP_GET_VARS['manufacturers_id'])  && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {
		  $prod_list_contents .= '		<td align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing[$x]['products_image'], $listing[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>';
		} else {
		  $prod_list_contents .= '		<td align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing[$x]['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>';
		}
		break;
	  case 'PRODUCT_LIST_BUY_NOW':
		$prod_list_contents .= '		<td align="center">' . $lc_text = '<input type=button value="  -1" onclick="javascript:changeValue(document.getElementById(\'add_id_'.$listing[$x]['products_id'].'\'),-1);return  false;"><input type="text" name="add_id['.$number_of_products.']"  id="add_id_'.$listing[$x]['products_id'].'" value="0" size="3"><input  type=button value="+1" onclick="javascript:changeValue(document.getElementById(\'add_id_'.$listing[$x]['products_id'].'\'),1);return  false;">';
	  $lc_text .= '<input type="hidden"  name="products_id['.$number_of_products.']"  value="'.$listing[$x]['products_id'].'">';
	 break;		  
	}
  }
  $prod_list_contents .= '	  </tr>';
}
$prod_list_contents .= '	</table>' .
					   '  </div>' .
					   '</div>';
echo $prod_list_contents;
 } else {
?>
<p><?php echo TEXT_NO_PRODUCTS; ?></p>
<?php
 }
 if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
?>
<br />
<div>
  <span style="float: right;"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></span>
  <span><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></span>
</div>
<br>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
 <tr>
<td align="right" class="main"><?php echo tep_draw_button(IMAGE_BUTTON_IN_CART, 'cart', null, 'primary'); ?></td>
 </tr>
</table>
</form>
<?php
 }
?>
 </div>

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