Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

Posted

Hi, I just installed this and now I am receiving an error on my product listing page the error reads as:

 

Warning: Division by zero in C:\wamp\www\bargaincart\includes\modules\product_listing.php on line 119

 

Warning: Division by zero in C:\wamp\www\bargaincart\includes\modules\product_listing.php on line 338

 

This only occurs when I click on the category but when I click on the product in whats new it displays fine. Any help would be appreciated.

I am currently just learning osCommerce and PHP, but am always willing to help out.

 

Have successfully installed the following: Discount Coupons, UPS shipping module, Ultimate SEO URL's, Easy Meta Tags for SEO 1.0, Google XML Sitemap SEO v1.3, HTML Editor for Email and Newsletters.

Posted (edited)
Hi, I just installed this and now I am receiving an error on my product listing page the error reads as:

 

Warning: Division by zero in C:\wamp\www\bargaincart\includes\modules\product_listing.php on line 119

 

Warning: Division by zero in C:\wamp\www\bargaincart\includes\modules\product_listing.php on line 338

 

This only occurs when I click on the category but when I click on the product in whats new it displays fine. Any help would be appreciated.

 

 

The solution to your problem is that you must also copy the installer.php file in your root folder and then visit it through http://yoursite/installer.php so the needed infos are inserted to your sql table!

 

-------------------------------------------------------------------------------------------------------------------------

 

A NEW QUESTION NOW

 

 

i also have a question/problem with the same excellent contribution (i installed 1.2 ver and manually added 1.2.3

 

when i do a category search in store thanks to this contribution it appears with the products a buy it now button BUT the actual link of this button confuses important link information - here is what i mean:

 

on top of it, it shows:

 

h t t p : // w w w .mysite.org/1_9/cPath/1_9/action/buy_now/products_id/26

 

 

 

instead of the link that it should have with it:

 

 

h t t p : // w w w .mysite.org/index.php?cPath=1_9&action=buy_now&products_id=26

 

 

 

so of cource i get the following error message when i click on it:

 

Not Found

 

The requested URL /1_4/cPath/1_4/action/buy_now/products_id/1 was not found on this server.

 

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

 

 

Anyone knows where should i look in order to fix it because i don't!

 

contribution is http://addons.oscommerce.com/info/6505 by FIMBLE

Edited by teochris
Posted

I doubt it will be the contribution as many have used and no-one has reported a problem as yet, does the buy now button work ok with the original file?

Sometimes you're the dog and sometimes the lamp post

[/url]

My Contributions

Posted (edited)
I doubt it will be the contribution as many have used and no-one has reported a problem as yet, does the buy now button work ok with the original file?

 

 

Fimble really thanks for your time!

 

I can not see this buy now button from the original file anymore because my site has a lot of mods and when i tried the original product_listing.php i got a lot of errors instead of the category list page

 

However a strange thing is that if after the category list seach i apply a seach filter (lets say manufacturers) the buy now button now creates the proper link as you can see below and everything works ok:

 

h t t p://w w w.mysite.org/index.php/cPath/1_9/filter_id/2/action/buy_now/products_id/26

 

i include for you my product_listing.php code - most of this code is from your attached file since i compared it with the previous your mod product_listing.php file (at the end of this page i also include the code from my previous product_listing.php

 

I believe the solution is if you point to me the code that creates the link for the buy now button AFTER the filter is applied in the category search i will also copy this code to the buy now button! :)

 

********************************************************************************

******************************* product_listing.php code after your mod *************

********************************************************************************

 

 

<?php

$list_box_contents = array();

$list_box_contents[] = array('params' => 'class="productListing-heading"');

$cur_row = sizeof($list_box_contents) - 1;

$add_multiple = false;

$use_of_attributes = false;

$get_short_description = true;

$column_list[] = PRODUCT_SHORT_DESCRIPTION;

for ($col=0, $n=sizeof($column_list); $col<$n; $col++)

{

switch ($column_list[$col])

{

case 'PRODUCT_LIST_MULTIPLE':

$add_multiple = true;

$use_of_attributes = true;

echo '<form name="buy_now_" method="post" action="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'sort', 'products_id')) . 'action=add_multiple', 'NONSSL') . '">';

break;

case 'PRODUCT_LIST_BUY_NOW_MULTIPLE':

$use_of_attributes = true;

break;

case 'PRODUCT_SHORT_DESCRIPTION':

$get_short_description = true;

break;

}

}

?>

<?php

$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="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', 'products_id'))); ?></td>

</tr>

</table>

<?php

}

$list_box_contents = array();

global $cart;

 

if ($listing_split->number_of_rows > 0)

{

if (PRODUCT_LIST_NUMCOL <= 0)

{

$colnum = 3;

$tdsize = floor(100/3);

} else {

$colnum = PRODUCT_LIST_NUMCOL;

$tdsize = floor(100/PRODUCT_LIST_NUMCOL);

}

$row = 0;

$column = 0;

$listing_query = tep_db_query($listing_split->sql_query);

$no_of_listings = tep_db_num_rows($listing_query);

while ($_listing = tep_db_fetch_array($listing_query))

{

$_listing['total'] = '';

$listing[] = $_listing;

$list_of_prdct_ids[] = $_listing['products_id'];

}

if ($use_of_attributes == true) {

$products_attributes_count_query = tep_db_query("select count(*) as total, patrib.products_id from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id in (" . implode(',', $list_of_prdct_ids) . ") and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "' group by products_id");

while ($_products_attributes_count = tep_db_fetch_array($products_attributes_count_query)) {

$products_attributes_count[] = array('products_id' => $_products_attributes_count['products_id'], 'total' => $_products_attributes_count['total']);

}

$no_of_products_with_attributes = count($products_attributes_count);

for ($x = 0; $x < $no_of_listings; $x++) {

if (!empty($products_attributes_count)) {

for ($i = 0; $i < $no_of_products_with_attributes; $i++) {

if ($listing[$x]['products_id'] == $products_attributes_count[$i]['products_id'] ) {

$listing[$x]['total'] = $products_attributes_count[$i]['total'];

}

}

}

}

}

 

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

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

}

 

 

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'];

}

}

}

}

 

 

if ($get_short_description == true) {

$short_description_query = tep_db_query("select pd.products_id, pd.products_description from " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.language_id = '" . (int)$languages_id . "' and products_id in (" . implode(',', $list_of_prdct_ids) . ")");

while ($short_description_array = tep_db_fetch_array($short_description_query)) {

$short_description[] = array ('products_id' => $short_description_array['products_id'], 'short_description' => substr(strip_tags($short_description_array['products_description']), 0, 120) . '...');

}

 

 

$number_of_descriptions = count($short_description);

for ($x = 0; $x < $no_of_listings; $x++) {

if ($number_of_descriptions > 0) {

for ($i = 0; $i < $number_of_descriptions; $i++) {

if ($listing[$x]['products_id'] == $short_description[$i]['products_id'] ) {

$listing[$x]['short_description'] = $short_description[$i]['short_description'];

}

}

}

}

}

 

$counter = 0;

for ($x = 0; $x < $no_of_listings; $x++) {

 

if ($x % PRODUCT_LIST_NUMCOL == 0) {

if (($counter+1)/2 == floor(($counter+1)/2)) {

 

$list_box_contents[$row] = array('params' => 'class="productListing-even"');

$class_for_buy_now_row = 'class="productListing-even"';

} else {

$list_box_contents[$row] = array('params' => 'class="productListing-even"');

$class_for_buy_now_row = 'class="productListing-odd"';

}

}

 

$product_contents = array();

 

for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {

$lc_align = '';

$lc_text = array();

 

switch ($column_list[$col]) {

case 'PRODUCT_LIST_MODEL':

$lc_align = '';

$lc_text['products_model'] = ' ' . $listing[$x]['products_model'] . ' ';

break;

case 'PRODUCT_LIST_NAME':

$lc_align = '';

if (isset($_GET['manufacturers_id'])) {

$lc_text['products_name'] = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . (int)$_GET['manufacturers_id'] . '&products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a>';

} else {

$lc_text['products_name'] = '<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_SHORT_DESCRIPTION';

$lc_text['products_short_description'] = $listing[$x]['short_description'];

break;

case 'PRODUCT_LIST_MANUFACTURER':

$lc_align = '';

$lc_text['manufacturers_name'] = '<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['products_price'] = '<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['products_price'] = ' ' . $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['products_quantity'] = ' ' . $listing[$x]['products_quantity'] . ' ';

break;

case 'PRODUCT_LIST_WEIGHT':

$lc_align = 'right';

$lc_text['products_weight'] = ' ' . $listing[$x]['products_weight'] . ' ';

break;

case 'PRODUCT_LIST_IMAGE':

$lc_align = 'center';

if (isset($_GET['manufacturers_id'])) {

$lc_text['products_image'] = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . (int)$_GET['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['products_image'] = '<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_text['button_buy_now'] = '<a href="' . tep_href_link(basename($_SERVER['PHP_SELF']), tep_get_all_get_params(array('action','sort','products_id')) . 'action=buy_now&products_id=' . $listing[$x]['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW, 'style="padding-bottom: 5px;"') . '</a>';

 

$lc_text['button_continue'] = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE, 'style="padding-bottom: 5px;"') . '</a>';

break;

 

case 'PRODUCT_LIST_MULTIPLE':

$lc_align = 'right';

$lc_valign = 'top';

$product_list_multiple_text = (TABLE_HEADING_MULTIPLE . tep_draw_input_field('Qty_ProdId_' . $listing[$x]['products_id'], '0', 'size="4"'));

if ((int)$listing[$x]['total'] > 0) {

$product_list_multiple_text .= '<table border="0" cellpadding="0" cellspacing"0">';

$products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . $listing[$x]['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'");

while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {

$selected_attribute = false;

$products_options_array = array();

$product_list_multiple_text .= '<tr><td class="main">' . $products_options_name['products_options_name'] . ':</td><td>' . "\n";

$products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix, pa.products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . $listing[$x]['products_id'] . "' and pa.options_id = '" . $products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "'");

$list_of_prdcts_attributes_id = '';

$products_options = array();

while ($_products_options = tep_db_fetch_array($products_options_query)) {

$products_options[] = $_products_options;

}

 

for ($v = 0 ; $v < count($products_options); $v++) {

$options_text = '';

$options_text = $products_options[$v]['products_options_values_name'];

if (defined('PRODUCT_LIST_ACTUAL_PRICE_IN_DROPDOWN') && PRODUCT_LIST_ACTUAL_PRICE_IN_DROPDOWN == 'Yes') {

 

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

$original_price = $listing[$x]['specials_new_products_price'];

} else {

$original_price = $listing[$x]['products_price'];

}

if ($products_options[$v]['price_prefix'] == "-")

{

$show_price = 0.0 + $original_price - $products_options[$v]['options_values_price'];

} else {

$show_price = 0.0 + $original_price + $products_options[$v]['options_values_price'];

}

$options_text .= ' (' . $currencies->display_price($show_price, tep_get_tax_rate($listing[$x]['products_tax_class_id'])) .') ';

 

} else {

if ($products_options[$v]['options_values_price'] != '0') {

$options_text .= ' (' . $products_options[$v]['price_prefix'] . $currencies->display_price($products_options[$v]['options_values_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) .') ';

}

}

$products_options_array[] = array('id' => $products_options[$v]['products_options_values_id'], 'text' => $options_text);

}

 

$product_list_multiple_text .= tep_draw_pull_down_menu('id_'.$listing[$x]['products_id'].'[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute);

$product_list_multiple_text .= '</td></tr>';

}

$product_list_multiple_text .= '</table>';

$lc_text['product_list_multiple'] = $product_list_multiple_text;

}

break;

case 'PRODUCT_LIST_BUY_NOW_MULTIPLE':

$lc_align = 'right';

$lc_valign = 'top';

$lc_text_plbnm = '<form name="buy_now_' . $listing[$x]['products_id'] . '" method="post" action="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action','sort','products_id')) . 'action=buy_now_form', 'NONSSL') . '">';

$lc_text_plbnm .= (TABLE_HEADING_MULTIPLE) . '<input type="text" name="cart_quantity" value="1" maxlength="6" size="4">';

if ((int)$listing[$x]['total'] > 0) {

$lc_text_plbnm .= '<table border="0" cellpadding="0" cellspacing"0">';

$products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . $listing[$x]['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'");

while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {

$selected_attribute = false;

$products_options_array = array();

$lc_text_plbnm .= '<tr><td class="main">' . $products_options_name['products_options_name'] . ':</td><td>' . "\n";

$products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix, pa.products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . $listing[$x]['products_id'] . "' and pa.options_id = '" . $products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "'");

$list_of_prdcts_attributes_id = '';

$products_options = array();

while ($_products_options = tep_db_fetch_array($products_options_query)) {

$products_options[] = $_products_options;

}

 

for ($v = 0 ; $v < count($products_options); $v++) {

$options_text = '';

$options_text = $products_options[$v]['products_options_values_name'];

if (defined('PRODUCT_LIST_ACTUAL_PRICE_IN_DROPDOWN') && PRODUCT_LIST_ACTUAL_PRICE_IN_DROPDOWN == 'Yes') {

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

$original_price = $listing[$x]['specials_new_products_price'];

} else {

$original_price = $listing[$x]['products_price'];

}

if ($products_options[$v]['price_prefix'] == "-")

{

$show_price = 0.0 + $original_price - $products_options[$v]['options_values_price'];

} else {

$show_price = 0.0 + $original_price + $products_options[$v]['options_values_price'];

}

$options_text .= ' (' . $currencies->display_price($show_price, tep_get_tax_rate($listing[$x]['products_tax_class_id'])) .') ';

} else {

if ($products_options[$v]['options_values_price'] != '0') {

$options_text .= ' (' . $products_options[$v]['price_prefix'] . $currencies->display_price($products_options[$v]['options_values_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) .') ';

}

}

$products_options_array[] = array('id' => $products_options[$v]['products_options_values_id'], 'text' => $options_text);

}

 

$lc_text_plbnm .= tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute);

$lc_text_plbnm .= '</td></tr>';

}

$lc_text_plbnm .= '</table>';

$lc_text_plbnm .= tep_draw_hidden_field('products_id', $listing[$x]['products_id']) . tep_image_submit('button_buy_now.gif', TEXT_BUY . $listing[$x]['products_name'] . TEXT_NOW);

 

}

if ((int)$listing[$x]['total'] == 0) {

$lc_text_plbnm .= '<br> ';

$lc_text_plbnm .= tep_draw_hidden_field('products_id', $listing[$x]['products_id']) . tep_image_submit('button_buy_now.gif', TEXT_BUY . $listing[$x]['products_name'] . TEXT_NOW);

$lc_text_plbnm .= '<br> ';

$lc_text_plbnm .= '<table border="0" cellpadding="0" cellspacing"0"><tr><td class="main"></td><td></td></tr></table>';

}

$lc_text_plbnm .= '</form>';

$lc_text['product_list_buy_now_multiple'] = $lc_text_plbnm;

break;

 

default: $lc_text = array();

}

if (is_array($lc_text)) {

foreach($lc_text as $name => $contents) {

$product_contents[$name] = $contents;

}

}

}

 

 

$class_for_right_side = '';

if (($x % $colnum) < ($colnum - 1)) {

$class_for_right_side = ' class="infobox"';

}

$class_for_bottom = '';

$last_row = ceil($no_of_listings / $colnum) - 1;

if ($row < $last_row) {

$class_for_bottom = ' class="infobox"';

}

$product_text = "\n";

$product_text .= '<table Width="100%" cellpadding="0" cellspacing="0" border="0">';

$product_text .= ' <tr><td width="30%" rowspan="7" height="122" align="center">' . $product_contents['products_image'] . '</td>';

$product_text .= ' <td width="80%" class="pagelisting">' . $product_contents['products_name'] . '</td></tr>';

$product_text .= ' <tr><td width="80%" cellpadding="0" cellspacing="0" class="description"><br>' . $product_contents['products_short_description'] . '<br></td></tr>';

$product_text .= ' <tr><td width="80%" class="price">Price:' . $product_contents['products_price'] . '</td></tr>';

if (!PRODUCT_LIST_MANUFACTURER == 1) { } else {

$product_text .= ' <tr><td width="80%" class="main">Manufactuer:' . $product_contents['manufacturers_name'] . '</td></tr>';

}

if (!PRODUCT_LIST_QUANTITY == 1) { } else {

$product_text .= ' <tr><td width="80%" class="main">Qty:' . $product_contents['products_quantity'] . '</td></tr>';

}

$product_text .= ' <tr><td width="80%" height="25" class="main" align="left">' . $product_contents['button_buy_now'] . '</td></tr>';

$product_text .= ' <tr><td width="80%" class="main" align="left">'. $product_contents['button_continue'] . '</td>';

$product_text .= '</tr></table><hr>';

$list_box_contents[$row][$column] = array('align' => 'center',

'valign' => $lc_valign,

'params' => 'class="productListing-data" width="'.$tdsize.'%"',

'text' => $product_text);

$column ++;

if ($x == ($no_of_listings -1)) {

$last_column = ($x % PRODUCT_LIST_NUMCOL);

$fill_up_empty_cell = tep_draw_separator('pixel_trans.gif', '250px' , '1');

for ($column = ($last_column + 1) ; $column < $colnum; $column++) {

$list_box_contents[$row][$column] = array('align' => 'center',

'valign' => $lc_valign,

'params' => 'class="productListing-data" width="'.$tdsize.'%"',

'text' => $fill_up_empty_cell);

}

}

if ($column >= $colnum && $x < ($no_of_listings -1)) {

$row ++;

$column = 0;

$counter++;

}

}

 

new productListingOSCBox($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','products_id','sort'))); // sort was added in this file, no point here ?></td>

</tr>

<?php if ($add_multiple == true){

?>

<tr>

<td align="left" class="main"> </td>

<td align="right" class="main"><?php echo tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART);

?></form></td>

</tr>

<?php } ?>

</table>

<?php

}

?>

 

********************************************************************************

******************************************

******************************* product_listing.php code before your mod ******************************************************

********************************************************************************

******************************************

 

<?php

/*

$Id: product_listing.php 1739 2007-12-20 00:52:16Z hpdl $

 

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="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;

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;

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

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>

<?php

}

?>

Edited by teochris
Posted

Hi again!

 

By checking your product_listing.php file

 

What i just discovered is that by replacing from line 182 the following code tep_href_link(basename($_SERVER['PHP_SELF'])

 

with this one tep_href_link(basename($PHP_SELF)

 

now the buy_now button does not do what it is supposed (now it takes you to the product) instead of opening the shopping cart but at least it does not link to a non existing page!

 

So it is either a problem with the original code maybe with the '[ or maybe i have not defined $_SERVER somewhere else in another file?

 

Still though if i click the buy_now button on a product after i have applied the manufacturer filter everything works as it is supposed!

 

Can you tell me your opinion?

Posted (edited)
Hi again!

 

By checking your product_listing.php file

 

What i just discovered is that by replacing from line 182 the following code tep_href_link(basename($_SERVER['PHP_SELF'])

 

with this one tep_href_link(basename($PHP_SELF)

 

now the buy_now button does not do what it is supposed (now it takes you to the product) instead of opening the shopping cart but at least it does not link to a non existing page!

 

So it is either a problem with the original code maybe with the '[ or maybe i have not defined $_SERVER somewhere else in another file?

 

Still though if i click the buy_now button on a product after i have applied the manufacturer filter everything works as it is supposed!

 

Can you tell me your opinion?

 

$PHP_SELF is set in application top with:

 

$PHP_SELF = (isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']);

 

which implies that on your server $_SERVER['PHP_SELF'] is not getting set?

 

I have seen other cases where the code like

 

 tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action','sort','products_id')) . 'action=buy_now&products_id=' . $listing[$x]['products_id'])

 

results in a redirect to product_info instead of the add to cart action, this would appear to be due to modifictions to appliction top be some package(s), is your appliction top modified, if so what is the add to cart code within that?

Edited by spooks

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Posted (edited)

A point I forgot, if your product has atributes app_top will redirect to product info as it know not what attribute to apply

Edited by spooks

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Posted

I am glad to announce that by performing a test action yesterday the problem was finally solved!

 

 

By checking your product_listing.php file

 

What i just discovered is that by replacing from line 182 the following code tep_href_link(basename($_SERVER['PHP_SELF'])

 

with this one tep_href_link(basename($PHP_SELF)

 

 

Thank you all for your time

Posted

Great, I take it that where u were getting re-directed to product info there were atributes?

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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