Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Another "What's New This Month" issue


jhande

Recommended Posts

Posted

The only edit I remember doing to the new products infobox was to give it a 1 month interval for displaying products.

 

On the index / home page it shows products from all categories just fine.

 

On a top level category the infobox disappears, but...

 

On a sub-category of the above, it displays as it should.

 

How can I get the box to display the sub-categories when on a top-level category?

- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Posted

Can you post your catalog/includes/modules/new_products.php code?

 

Below is the default code for RC 2.2a if you want to compare.

 

 

 

 

 

 

 

 

<!-- new_products //-->
<?php
$info_box_contents = array();
$info_box_contents[] = array('text' => sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')));

new contentBoxHeading($info_box_contents);

if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {
$new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
} else {
$new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
}

$row = 0;
$col = 0;
$info_box_contents = array();
while ($new_products = tep_db_fetch_array($new_products_query)) {
$info_box_contents[$row][$col] = array('align' => 'center',
	'params' => 'class="smallText" width="33%" valign="top"',
	'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . $new_products['products_name'] . '</a><br>' . $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])));

$col ++;
if ($col > 2) {
	$col = 0;
	$row ++;
}
}

new contentBox($info_box_contents);
?>
<!-- new_products_eof //-->

Posted

Thanks for the reply Don wink.gif

 

Here's my version:

 

<!-- new_products //-->
<?php
 if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {
//$new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
$new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' AND p.products_date_added > date_sub(NOW(), INTERVAL 1 MONTH) order by rand() limit " . MAX_DISPLAY_NEW_PRODUCTS);
 } else {
$new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' AND p.products_date_added > date_sub(NOW(), INTERVAL 1 MONTH) order by rand() limit " . MAX_DISPLAY_NEW_PRODUCTS);
 }

 if (tep_db_num_rows($new_products_query) > 0) {

 $info_box_contents = array();
 $info_box_contents[] = array('text' => sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')));

new contentBoxHeading($info_box_contents, tep_href_link(FILENAME_PRODUCTS_NEW));

 $row = 0;
 $col = 0;
 $info_box_contents = array();
 while ($new_products = tep_db_fetch_array($new_products_query)) {
$info_box_contents[$row][$col] = array('align' => 'center',
                                  		'params' => 'class="smallText" width="33%"',
                                  		'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . $new_products['products_name'] . '</a><br>' . $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])));

$col ++;
if ($col > 2) {
 	$col = 0;
 	$row ++;
}
 }
 new contentBox($info_box_contents);
}
?>
<!-- new_products_eof //-->

 

I still can't figure out what would cause the parent category to not display although there are new products in a sub-category. Sorry... sad.gif

- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Posted

I don't see anything really wacked out. I only see your file is a little out of order from the stock version.

 

You can TRY this (I just added your Month interval to the stock version).

 

Make sure you back up first.

 

<!-- new_products //-->
<?php
$info_box_contents = array();
$info_box_contents[] = array('text' => sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')));

new contentBoxHeading($info_box_contents);

if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {
	$new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' AND p.products_date_added > date_sub(NOW(), INTERVAL 1 MONTH) order by rand() limit " . MAX_DISPLAY_NEW_PRODUCTS);
} else {
	$new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'"' AND p.products_date_added > date_sub(NOW(), INTERVAL 1 MONTH) order by rand() limit " . MAX_DISPLAY_NEW_PRODUCTS);
}

$row = 0;
$col = 0;
$info_box_contents = array();
while ($new_products = tep_db_fetch_array($new_products_query)) {
	$info_box_contents[$row][$col] = array('align' => 'center',
	'params' => 'class="smallText" width="33%" valign="top"',
	'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . $new_products['products_name'] . '</a><br>' . $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])));

	$col ++;
	if ($col > 2) {
	$col = 0;
	$row ++;
	}
}

new contentBox($info_box_contents);
?>
<!-- new_products_eof //-->

 

I hope it works for you, but if not maybe somebody else can spot something I didn't.

Posted

That code will only display products from the current category (when you are in a category.) It will not display products in any subcategory.

 

Regards

Jim

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

Posted

Thanks Don, I gave that a try and received this error message:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home3/handesho/public_html/includes/modules/new_products.php on line 27

Here's line 27:

 

$info_box_contents[$row][$col] = array('align' => 'center',

 

I'll keep playing with the file and see what happens. whistling.gif

- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Archived

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

×
×
  • Create New...