Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Request help with "Add Multiple Products" mod


drmike

Recommended Posts

Hello. I hope this is appropriate - first time poster - begging your forgiveness if inapproparite...

 

I am trying to integrate the mod: http://www.oscommerce.com/community/contributions,1129 "Add Multiple Products" (which allows you to add multiple products in any quantity to the cart at once) into my site. After I followed the instructions, everything looks right, but the "Add to cart" button does not work - nothing happens when clicked.

 

I replaced the orignal product_listing.php with the included prodduct_listing_multiple.php and renamed it to product_listing.php because in the instructions it says:

In it's basic form I have presented this mod as a replacement for the standard module/product listing. To activate this

you will need to change the following define in application_top.php

 

define('FILENAME_PRODUCT_LISTING', 'product_listing.php');

 

change to

 

define('FILENAME_PRODUCT_LISTING', 'product_listing_multi.php')

however, I could not find these lines in application_top.php. So, instead of redefining it, I just replaced the file with the ..._multiple.php file so that I would not need to redefine it - but I'm not sure if this was a good move. I've posted the code for my new product_listing.php below, as well as the instrucitons for the mod.

 

If anyone has any suggestions on how I might fix this, or another mod that does the same thing, I would be very grateful. Thanks.

 

mike

 

<?php

/*

$Id: product_listing.php,v 1.44 2003/06/09 22:49:59 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 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') ) ) {

?>

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

<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);

while ($listing = tep_db_fetch_array($listing_query)) {

 

$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['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['products_id']) . '">' . $listing['products_name'] . '</a>';

} else {

$lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a> ';

}

break;

case 'PRODUCT_LIST_MANUFACTURER':

$lc_align = '';

$lc_text = ' <a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing['manufacturers_id']) . '">' . $listing['manufacturers_name'] . '</a> ';

break;

case 'PRODUCT_LIST_PRICE':

$lc_align = 'right';

if (tep_not_null($listing['specials_new_products_price'])) {

$lc_text = ' <s>' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s>  <span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span> ';

} else {

$lc_text = ' ' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . ' ';

}

break;

case 'PRODUCT_LIST_QUANTITY':

$lc_align = 'right';

$lc_text = ' ' . $listing['products_quantity'] . ' ';

break;

// START: display min. order. qty. mod

case 'PRODUCT_LIST_MIN_ORDER_QTY':

$lc_align = '';

$lc_text = ' ' . $listing['products_min_order_qty'] . ' ';

break;

// END: display min. order. qty. mod

case 'PRODUCT_LIST_WEIGHT':

$lc_align = 'right';

$lc_text = ' ' . $listing['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['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';

 

} else {

 

$lc_text = '

 

<script language="javascript"><!--

 

document.write(\'<a href="java script:popupWindow(\\\'' . tep_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $listing['products_id']) . '\\\')">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], addslashes($listing['products_name']), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>Click to enlarge</a>\');

 

//--></script>

 

<noscript>

 

<a href="' . tep_href_link(DIR_WS_IMAGES . $listing['products_image']) . '" target="_blank">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>

 

</noscript>';

 

}

 

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['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';

$lc_text = '<input type="text" name="add_id['.$number_of_products.']" value="0" size="4">';

$lc_text .= '<input type="hidden" name="products_id['.$number_of_products.']" value="'.$listing['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

}

?>

 

Mod Instructions

The zip file contains 2 files.

The file catalog/includes/modules/products_multi.php can be simply copied to the same directory in your install.

 

There are also changes that need to be made to catalog/includes/application_top.php

 

First in application_top.php find the lines

 

if (isset($HTTP_GET_VARS['action'])) {

if (DISPLAY_CART == 'true') {

$goto = FILENAME_SHOPPING_CART;

$parameters = array('action', 'cPath', 'products_id', 'pid');

} else {

$goto = basename($PHP_SELF);

if ($HTTP_GET_VARS['action'] == 'buy_now') {

$parameters = array('action', 'pid', 'products_id');

} else {

$parameters = array('action', 'pid');

}

}

and add immediately after add these lines

 

///////////////////////////////////////// Products Multi //////////////////////

if ($HTTP_GET_VARS['action'] == 'add_multi') {

$parameters = array('action', 'pid', 'products_id');

}#

///////////////////////////////////////// Products Multi //////////////////////

 

then just below this find the line

 

switch ($HTTP_GET_VARS['action']) {

 

and add the lines

 

///////////////////////////////////////// Products Multi //////////////////////

// multi_product_add

case 'add_multi':

for ($i=0; $i<=sizeof($HTTP_POST_VARS['products_id']);$i++) {

if($_POST['add_id'][$i] > 1)

$cart->add_cart($HTTP_POST_VARS['products_id'][$i], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'][$i], $HTTP_POST_VARS['id'][$i]))+($HTTP_POST_VARS['add_id'][$i]), $HTTP_POST_VARS['id'][$i]);

}

tep_redirect(tep_href_link(FILENAME_DEFAULT, tep_get_all_get_params($parameters), 'NONSSL'));

break;

///////////////////////////////////////// Products Multi //////////////////////

 

In it's basic form I have presented this mod as a replacement for the standard module/product listing. To activate this

you will need to change the following define in application_top.php

 

define('FILENAME_PRODUCT_LISTING', 'product_listing.php');

 

change to

 

define('FILENAME_PRODUCT_LISTING', 'product_listing_multi.php')

Link to comment
Share on other sites

Hello. I hope this is appropriate - first time poster - begging your forgiveness if inapproparite...

 

I am trying to integrate the mod: http://www.oscommerce.com/community/contributions,1129 "Add Multiple Products" (which allows you to add multiple products in any quantity to the cart at once) into my site. After I followed the instructions, everything looks right, but the "Add to cart" button does not work - nothing happens when clicked.

 

I replaced the orignal product_listing.php with the included prodduct_listing_multiple.php and renamed it to product_listing.php because in the instructions it says:

In it's basic form I have presented this mod as a replacement for the standard module/product listing. To activate this

you will need to change the following define in application_top.php

 

define('FILENAME_PRODUCT_LISTING', 'product_listing.php');

 

change to

 

define('FILENAME_PRODUCT_LISTING', 'product_listing_multi.php')

however, I could not find these lines in application_top.php. So, instead of redefining it, I just replaced the file with the ..._multiple.php file so that I would not need to redefine it - but I'm not sure if this was a good move. I've posted the code for my new product_listing.php below, as well as the instrucitons for the mod.

 

If anyone has any suggestions on how I might fix this, or another mod that does the same thing, I would be very grateful. Thanks.

 

mike

 

this :

 

define('FILENAME_PRODUCT_LISTING', 'product_listing_multi.php')

 

goes in filenames.php

Treasurer MFC

Link to comment
Share on other sites

Thank you for your help - very appreciated. I made the change to filenames.php and reinstated the original product_listing.phph and renamed the one I had back to product_listing_multi.php. However, the "add to cart" still doesn't work.

 

Can someone outline where the code is that controls this button/function? I am trying to determine if it is in application_top.php or product_listing_multi.php to try to see if there something I can fix. I am VERY new at this, but hey - I'm trying!

 

mike

Link to comment
Share on other sites

Thank you for your help - very appreciated.  I made the change to filenames.php and reinstated the original product_listing.phph and renamed the one I had back to product_listing_multi.php.  However, the "add to cart" still doesn't work.

 

Can someone outline where the code is that controls this button/function?  I am trying to determine if it is in application_top.php or product_listing_multi.php to try to see if there something I can fix.  I am VERY new at this, but hey - I'm trying!

 

mike

 

well, the button should submit the product id's along with the action and in application top the actual addition is performed.

Treasurer MFC

Link to comment
Share on other sites

  • 4 weeks later...

Sorry if I'm hijacking the post but I'm having a problem with this contribution too. I can only add quantities greater than 1 to the shopping cart.

 

So I can go down and add 3 x Product A or 5 x Product B etc but if I put a 1 in the box it doesn't add anything to the shopping cart.

 

If I put a number like 1.1 into the box it will also work and I can add 1 of a product with the Add Cart button on the indivdual product listing.

 

Any ideas.

Link to comment
Share on other sites

  • 1 month later...

I'm having trouble with this as well, and I'm not sure what it is. Any help would be appreciated. I also experienced a problem adding products in, but when I changed the locations of where the "add to cart" buttons are added, I did not have that particular issue, just the add 1 issue.

Link to comment
Share on other sites

Did anyone ever solve the 'add to cart' button problem where it does not do anything?

 

I've actually learned that changing the options in product listing about where to place the add to cart button problem seems to work, but then you have the other bugs, so it's not much help. :-)

Link to comment
Share on other sites

Ok. I solved the bug where it only adds items when a QTY of 2 is specified.

 

The contrib asks you to add code into application top. One line of this code looks like this: if($_POST['add_id'][$i] > 1)

 

This is basically saying if the QTY is over 1 add it.

 

It needs to say if($_POST['add_id'][$i] >= 1)

 

i.e if the qty is 1 or greater.

 

Works a charm now. Just need to sort out why it only works when the 'Location of Prev/Next Navigation Bar' config option in the admin panel > Product listing is set to 1 (top of page).

 

Hope this helps someone. If I get all this sorted I will update the contribution.

Link to comment
Share on other sites

Oh yes! You are a lifesaver. :-) I think I can finally rest in peace now. :-D How great is this, thanks a bunch. Too bad I didn't know PHP. :-/

Link to comment
Share on other sites

  • 4 weeks later...

I'm new to this, so likely I've overlooked something obvious. After applying this contribution (the latest, V1.2), I am unable to get the quantity input field to show in the product listing page as seen here. I've also applied a short descriptions contribution. I've looked for a conflict, but don't see one. I've spent over a day trying to resolve this problem. I'd appreciate any help. Thanks in advance!

 

My product_listing.php file follows

 

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

<?php

/*

$Id: product_listing.php,v 1.44 2003/06/09 22:49:59 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 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);

while ($listing = tep_db_fetch_array($listing_query)) {

 

$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['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['products_id']) . '"><b>' . $listing['products_name'] . '</a></b><br>' . $listing['short_desc'] . '</b>';

} else {

$lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '"><b>' . $listing['products_name'] . '</a></b><br>' . $listing['short_desc'] . '</b>';}

break;

case 'PRODUCT_LIST_MANUFACTURER':

$lc_align = '';

$lc_text = ' <a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing['manufacturers_id']) . '">' . $listing['manufacturers_name'] . '</a> ';

break;

case 'PRODUCT_LIST_PRICE':

$lc_align = 'right';

if (tep_not_null($listing['specials_new_products_price'])) {

$lc_text = ' <s>' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s>  <span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span> ';

} else {

$lc_text = ' ' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . ' ';

}

break;

case 'PRODUCT_LIST_QUANTITY':

$lc_align = 'right';

$lc_text = ' ' . $listing['products_quantity'] . ' ';

break;

// START: display min. order. qty. mod

case 'PRODUCT_LIST_MIN_ORDER_QTY':

$lc_align = '';

$lc_text = ' ' . $listing['products_min_order_qty'] . ' ';

break;

// END: display min. order. qty. mod

case 'PRODUCT_LIST_WEIGHT':

$lc_align = 'right';

$lc_text = ' ' . $listing['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['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['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['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['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['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';

$lc_text = '<input type="text" name="add_id['.$number_of_products.']" value="0" size="4">';

$lc_text .= '<input type="hidden" name="products_id['.$number_of_products.']" value="'.$listing['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

Have you made sure that in the Admin panel > Configuration > Product Listing the "Display Buy Now column" is set to something other than '0'.

 

Jim

 

I'm new to this, so likely I've overlooked something obvious. After applying this contribution (the latest, V1.2), I am unable to get the quantity input field to show in the product listing page as seen here. I've also applied a short descriptions contribution. I've looked for a conflict, but don't see one. I've spent over a day trying to resolve this problem. I'd appreciate any help. Thanks in advance!

 

My product_listing.php file follows

 

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

<?php

/*

  $Id: product_listing.php,v 1.44 2003/06/09 22:49:59 hpdl Exp $

 

  osCommerce, Open Source E-Commerce Solutions

  http://www.oscommerce.com

 

  Copyright ? 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);

    while ($listing = tep_db_fetch_array($listing_query)) {

 

      $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['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['products_id']) . '"><b>' . $listing['products_name'] . '</a></b><br>' . $listing['short_desc'] . '</b>';

                } else {

              $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '"><b>' . $listing['products_name'] . '</a></b><br>' . $listing['short_desc'] . '</b>';}

          break;

          case 'PRODUCT_LIST_MANUFACTURER':

            $lc_align = '';

            $lc_text = ' <a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing['manufacturers_id']) . '">' . $listing['manufacturers_name'] . '</a> ';

            break;

          case 'PRODUCT_LIST_PRICE':

            $lc_align = 'right';

            if (tep_not_null($listing['specials_new_products_price'])) {

              $lc_text = ' <s>' .  $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s>  <span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span> ';

            } else {

              $lc_text = ' ' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . ' ';

            }

            break;

          case 'PRODUCT_LIST_QUANTITY':

            $lc_align = 'right';

            $lc_text = ' ' . $listing['products_quantity'] . ' ';

            break;

          // START: display min. order. qty. mod

          case 'PRODUCT_LIST_MIN_ORDER_QTY':

            $lc_align = '';

            $lc_text = ' ' . $listing['products_min_order_qty'] . ' ';

            break;

          // END: display min. order. qty. mod

          case 'PRODUCT_LIST_WEIGHT':

            $lc_align = 'right';

            $lc_text = ' ' . $listing['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['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['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['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['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['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';

            $lc_text  = '<input type="text" name="add_id['.$number_of_products.']" value="0" size="4">';

            $lc_text .= '<input type="hidden" name="products_id['.$number_of_products.']" value="'.$listing['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

Archived

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

×
×
  • Create New...