developer_x Posted April 5, 2005 Share Posted April 5, 2005 I need checkboxes in the product listing table instead of the buy now buttons so that clients can select and buy multiple items. The orignal product listing(if you click on a category , and then any of its subcategory, products of that subcategory are listed) comes with buy now buttons. I needed checkboxes instead of these buy now buttons so that a visitor can add multiple products by checking the checkboxes. I tried using this contribution: Add Multi Products Checkbox But the 'Add to Cart' button is not working. This contribution is based on 2 older contributions which are: 1- Add Multi Products by C Wilsonhttp://www.oscommerce.com/community/contributions,1129 2- Add Multi Products Revived by Steve Oliveirahttp://www.oscommerce.com/community/contributions,3022 As the Add Multi Products Checkbox 1.0 contribution was not working properly. I tried to change Ian C wilson's contribution to suit my requirements. In the catalog/includes/modules/product_listing_multi.php I replaced $lc_text = '<input type="text" name="add_id['.$number_of_products.']" value="0" size="4">'; (line # 154 approximately) with this line: $lc_text = '<input type="checkbox" name="add_id['.sizeof($list_box_contents).']" value="1">'; I do get the checkboxes. All the items get added to the cart except the first one. I also tried using the standard osc checkbox function: $lc_text = tep_draw_checkbox_field(' add_id['.sizeof($list_box_contents).'] ', '1'); But results still has that bug. In the 'Add Multi Products Revived by Steve Oliveira ' contribution this bug has been discussed. I have took the steps told in that contribution for removing that bugh. But I am still getting that bug. Its almost done. Need a lil bit of help. Irfan, Link to comment Share on other sites More sharing options...
starflyer Posted April 15, 2005 Share Posted April 15, 2005 developer x, did you get the problem fixed? i'm trying to do the same thing for my site Link to comment Share on other sites More sharing options...
osclover Posted April 15, 2005 Share Posted April 15, 2005 No mate. Its a pity. i have put given up for the time being. been busy with greater things. y don't u opt for the input boxes. they r better than checkboxes as they allow the clients/visitors to purchase multiple numbers of the same product too beside allowing multiple number of different products. If a client dosen't want a product he/she will not alter the default number pre-placed in the input box. This default number is zero meaning that client' doesn't need this product. Hope this helps. Link to comment Share on other sites More sharing options...
starflyer Posted April 15, 2005 Share Posted April 15, 2005 thanks for the response! maybe; i'd prefer the checkboxes since all my items are just "1" in quantity. i'll mess with the code some more...but, might have to stick with what works Link to comment Share on other sites More sharing options...
osclover Posted April 15, 2005 Share Posted April 15, 2005 yes. try to get it working. i must be missing something too basic. may be u can get it right. n plz do post it here if y remove the bug. thanks. Link to comment Share on other sites More sharing options...
boxtel Posted April 15, 2005 Share Posted April 15, 2005 yes. try to get it working. i must be missing something too basic. may be u can get it right. n plz do post it here if y remove the bug. thanks. <{POST_SNAPBACK}> the way I have it currently (I am using columns though) : after : $info_box_contents = array(); I use : $p_index = 0; then after : while ($listing = tep_db_fetch_array($listing_query)) { I use : $p_index++; ?> <input type="hidden" name="products_id[<?php echo $p_index; ?>]" value="<?php echo $listing['products_id']; ?>"> <?php then for the checkboxes : <td align="center" valign="middle"><input type="checkbox" class="checkbox" name="add_id['.$p_index.']" value="1"></td> and in application top : case 'add_multi': for ($i=0; $i<=sizeof($_POST['products_id']);$i++) { $cart->add_cart($_POST['products_id'][$i+1], $cart->get_quantity(tep_get_uprid($_POST['products_id'][$i+1], $_POST['id'][$i+1]))+($_POST['add_id'][$i+1]), $_POST['id'][$i+1]); } tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); break; Treasurer MFC Link to comment Share on other sites More sharing options...
starflyer Posted April 19, 2005 Share Posted April 19, 2005 hi boxtel. could you send me sample files with your fix? i'm having trouble implementing it Link to comment Share on other sites More sharing options...
boxtel Posted April 19, 2005 Share Posted April 19, 2005 hi boxtel. could you send me sample files with your fix? i'm having trouble implementing it <{POST_SNAPBACK}> don't know what you mean with sample files. here is my product_listing.php if that helps you better, mind you, it is rather modified and there are things in there that will not run as is on your system so don't ask me to explain everything. <?php if ((stristr(basename($PHP_SELF),'advanced')) and ($_GET['keywords']) and ($_GET['hl'])){ $display_search_results = true; } else { $display_search_results = false; } if (isset($_SESSION['res'])) { if ($_SESSION['res'] == '800'){ $max_colums = 3; $max_search = 6; } else { $max_colums = 4; $max_search = 8; } } else { $max_colums = 3; $max_search = 6; } $table_width = ceil(100 / $max_colums); // union crash prevention if ($cPath == 64) { $cPath = ''; } if (isset($pw_mispell)){ ?> <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr><td><?php echo $pw_string; ?></td></tr> </table> <?php } $listing_split = new splitPageResults($listing_sql, $max_search, 'p.products_id'); $rows = ($listing_split->number_of_rows); $current_page = 1; if (isset($HTTP_GET_VARS['page'])) {$current_page = $HTTP_GET_VARS['page'];} if ( ($rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (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" valign="middle" align="right"><?php echo $listing_split->display_fancy_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y', 'lng', 'language', 'currency', 'zx', 'azx', 'top', 'action')), $rows, $current_page, TEXT_DISPLAY_NUMBER_OF_PRODUCTS, $max_search); ?></td> </tr> </table> <?php } ?> <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 $info_box_contents = array(); $p_index = 0; $buyable = false; if ($listing_split->number_of_rows > 0) { $row = 0; $col = 0; $listing_query = tep_db_query($listing_split->sql_query); while ($listing = tep_db_fetch_array($listing_query)) { $p_index++; ?> <input type="hidden" name="products_id[<?php echo $p_index; ?>]" value="<?php echo $listing['products_id']; ?>"> <?php $lc_text = '<table class="borderGray" width="100%" height="100%" cellpadding="0" cellspacing="0">'; if (PRODUCT_LIST_IMAGE > 0) { $lc_text .= '<tr>'; $lc_text .= '<td align="center" height="145px" valign="middle" class="smalltext"> <a onmouseover="window.status=\'' . $listing['products_name'] . '\' ; return true" href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_PRODUCT_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>'; $lc_text .= '</tr>'; } if (PRODUCT_LIST_MODEL > 0) { $lc_text .= '<tr>'; $lc_text .= '<td align="center" height="20px" valign="middle" class="vsmalltext">[' . $listing['products_model'] . ']</td>'; $lc_text .= '</tr>'; } if (PRODUCT_LIST_NAME > 0) { $lc_text .= '<tr>'; if ($display_search_results) { $lc_text .= '<td align="center" height="40px" valign="top" class="smalltext"> <a onmouseover="window.status=\'' . $listing['products_name'] . '\' ; return true" href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . highlight_viewable_text($listing['products_name'], $_GET['keywords'], 'searchTag') . '</a></td>'; } else { $lc_text .= '<td align="center" height="40px" valign="top" class="smalltext"> <a onmouseover="window.status=\'' . $listing['products_name'] . '\' ; return true" href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a></td>'; } $lc_text .= '</tr>'; } if (PRODUCT_LIST_MANUFACTURER > 0) { $lc_text .= '<tr>'; $lc_text .= '<td align="center" height="15px"valign="middle" class="smalltext">' . $listing['manufacturers_name'] . '</td>'; $lc_text .= '</tr>'; } if (PRODUCT_LIST_WEIGHT > 0) { $lc_text .= '<tr>'; $lc_text .= '<td align="center" height="15px" valign="middle" class="smalltext">' . $listing['products_weight'] . ' ' . WEIGHT_UNIT . '</td>'; $lc_text .= '</tr>'; } if (PRODUCT_LIST_PRICE > 0) { $lc_text .= '<tr>'; if (tep_not_null($listing['specials_new_products_price'])) { $lc_text .= '<td height="40px"align="center" valign="top" class="smalltext"> <s>' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s><br><span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span></td>'; } else { if ($listing['products_price'] > 0) { $lc_text .= '<td height="40px" align="center" valign="top" class="smalltext"> ' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</td>'; } else { $lc_text .= '<td height="40px" align="center" valign="top" class="smalltext"> ' . TEXT_CALL_FOR_PRICE . '</td>'; } } $lc_text .= '</tr>'; } if (PRODUCT_LIST_BUY_NOW > 0) { $lc_text .= '<tr>'; if (($listing['products_quantity'] > 0) and ($listing['products_price'] > 0) and ($session_started)) { $lc_text .= '<td height="33px" align="center" valign="middle" class="smalltext"> <a href="' . tep_href_link(basename($PHP_SELF), 'action=buy_now&products_id=' . $listing['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY) . '</a></td></tr><tr><td align="center" valign="middle"><input type="checkbox" class="checkbox" name="add_id['.$p_index.']" value="1"></td></tr><td>' .tep_draw_separator('pixel_trans.gif', '100%', '5') . '</td>'; $buyable = true; } else { if ($listing['products_quantity'] < 0) { $lc_text .= '<td height="33px" align="center" valign="middle" class="smalltext"> ' . tep_image_button('button_buy_sold.gif', 'Sold') . '</td></tr><tr><td>' . tep_draw_separator('pixel_trans.gif', '100%', '25') . '</td>'; } else { $lc_text .= '<td height="33px" align="center" valign="middle" class="smalltext"> ' . tep_image_button('button_buy_off.gif') . '</td></tr><tr><td>' . tep_draw_separator('pixel_trans.gif', '100%', '24') . '</td>'; } } $lc_text .= '</tr>'; } $lc_text .= '</table>'; $info_box_contents[$row][$col] = array('align' => 'center', 'params' => ' width="' . $table_width . '%" class="smallText" valign="top" ', 'text' => $lc_text); $col ++; if ($col >= $max_colums) { $col = 0; $row ++; } } $colx = $col; if (($row > 0) && ($colx > 0)) { while ($colx < $max_colums ) { $lc_text = '<table><tr><td></td></tr></table>'; $info_box_contents[$row][$colx] = array('align' => 'center', 'params' => '', 'text' => $lc_text); $colx++; } } new contentBox($info_box_contents, '#ffffff'); } else { ?> <tr><td> <?php $info_box_contents = array(); $info_box_contents[0] = array('params' => 'class="productListing-odd"'); $info_box_contents[0][] = array('params' => 'class="productListing-data"', 'text' => TEXT_NO_PRODUCTS); new contentBox($info_box_contents); ?> </td></tr><tr><td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td></tr> <?php } if ($buyable) { ?> <table align="center" width="100%" cellspacing="0" cellpadding="4" class="borderWhite"> <tr> <td align="left" width="30%" class="main"><input name="allbox" type="checkbox" value="Check All" onclick="InboxCheckAll();" /> Select All</td> <td align="right" width="40%" nowrap class="main"><?php echo ADD_MULTIPLE_PRODUCTS; ?></td> <td align="center" class="main" valign="middle"> <img src="images/arrow_south_east.gif" alt="<?php echo ADD_MULTIPLE_PRODUCTS; ?>" title="<?php echo ADD_MULTIPLE_PRODUCTS; ?>"></td> <td align="left" width="140px"class="main"><?php echo tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td> </tr> </table> <?php } echo '</form>'; if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) { $rows = ($listing_split->number_of_rows); ?> <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 $listing_split->display_fancy_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y', 'lng', 'language', 'currency', 'zx', 'azx', 'top', 'action')), $rows, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_PRODUCTS, $max_search); ?> </td> </tr> </table> <?php } ?> Treasurer MFC Link to comment Share on other sites More sharing options...
Guest Posted April 21, 2005 Share Posted April 21, 2005 I am having the same problem, the "add to cart" box does not work. Could anyone shed some light on the problem? I did email John Andriessen the day after this contribution was release but have had no response as yet. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.