Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Index page new_products module - HELP PLEASE


Guest

Recommended Posts

Hi,

 

The new_products module that appears on the front page I have edited to include a more details button and a buy now button but for the life of me I can't seem to get the manufacturers name on there too.

 

The code I'm using to get the buttons is:

 

  $row = 0;
 $col = 0;
 $info_box_contents2 = array();
 while ($new_products = tep_db_fetch_array($new_products_query)) { 
$new_products['products_name'] = tep_get_products_name($new_products['products_id']);
$info_box_contents2[$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, 'class=shadow1') . '</a><br>
<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . $new_products['products_name'] . '</a><br>
<a title="more info" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . 'more-info-sml.gif','',47,13) . '</a>	' .
'<a title="buy now" href="' . tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $new_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . 'buy-now-sml.gif','',67,13) . '</a><br>' .
(($new_products['products_price'] > 0) ? $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])) : '')); 


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

 

 

Now the code I added to try and get the manufacturers name in is:

 

  $row = 0;
 $col = 0;
 $info_box_contents2 = array();
 while ($new_products = tep_db_fetch_array($new_products_query)) { 
$new_products['products_name'] = tep_get_products_name($new_products['products_id']);
$info_box_contents2[$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, 'class=shadow1') . '</a><br>
<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . $new_products['products_name'] . '</a><br>
<a title="more info" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . '<br>' . TEXT_MANUFACTURER . ' ' . $products_new['manufacturers_name'] . '<br><br>' . tep_image(DIR_WS_IMAGES . 'more-info-sml.gif','',47,13) . '</a>	' .
'<a title="buy now" href="' . tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $new_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . 'buy-now-sml.gif','',67,13) . '</a><br>' .
(($new_products['products_price'] > 0) ? $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])) : '')); 


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

 

This bit I added: . TEXT_MANUFACTURER . ' ' . $products_new['manufacturers_name'] .

 

PS: the file I am editing to do this is the new_products.php in incl/modules/

 

Anyone know my mistake? and can anyone provide a bit of code to get it working I'd need the man_name just above the buttons in bold text.

 

Many thanks for any help.

Link to comment
Share on other sites

You need to modify the SQL query to include the manufacturers' names.

 

From this:

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, 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 where products_status = '1' 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, 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_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' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);

}

 

to this:

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, m.manufacturers_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 left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id where products_status = '1' 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, m.manufacturers_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 left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " . 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' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);

}

 

That is untested, but it's the right idea.

Please use the forums for support! I am happy to help you here, but I am unable to offer free technical support over instant messenger or e-mail.

Link to comment
Share on other sites

Thanks for your help, I'm on the right track so using your bit of code and my bit of code. I comes up now with the words TEXT_MANUFACTURER any ideas why?

 

Also it seems now to be only displaying the last added products to the catalog, rather than alternating between them all as before.

 

Cheers for any help.

Link to comment
Share on other sites

Could really do with some help regarding the displaying the last added products to the store, rather than alternating between them all as before on the main index page.

 

Cheers

Link to comment
Share on other sites

Just a rundown of the stage i'm at and some info to hopefully help someone help me.

 

 

Below is my php code in the new_products.php file in the incl/modules/

 

My dilemma is that I can now get the two images 'details' 'buy now' buttons added, I can also get the manufacturers name added under the title of each product as I wanted thanks to dynamoeffects. My last problem which is a bit annoying as I've been messing with the code below is that the products are not refreshing. By that I mean the 100 odd products added to my store over the last few days are noit alternating but just showing the last 9 added products.

 

Please note I am reffering to the new_products module on the front index page of the store.

 

If I could go down on one knee and beg for help I would, ok I am...... :)

 

 

Thanks for reading, hopefully you can help.

 

 

<?php
/*
 $Id: new_products.php,v 1.34 2003/06/09 22:49:58 hpdl Exp $


This contribution enhances the New Products module so that it displays "more info" 
and "buy now" links underneath the displayed products.

See the README file for easy installation instructions.

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/
?>
<!-- new_products //-->
<?php
 $info_box_contents2 = array();
 $info_box_contents2[] = array('text' => sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')));

 new contentBoxHeading($info_box_contents2);

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, m.manufacturers_name, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' 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, m.manufacturers_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_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " . 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' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
}

$row = 0;
$col = 0;
$info_box_contents2 = array();
while ($new_products = tep_db_fetch_array($new_products_query)) {
$new_products['products_name'] = tep_get_products_name($new_products['products_id']);
$info_box_contents2[$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, 'class=shadow1') . '</a><br>
<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . $new_products['products_name'] . '</a><br>
<a title="more info" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . ' ' . $new_products['manufacturers_name'] . '<br><br>' . tep_image(DIR_WS_IMAGES . 'more-info-sml.gif','',47,13) . '</a> ' .
'<a title="buy now" href="' . tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $new_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . 'buy-now-sml.gif','',67,13) . '</a><br>' .
(($new_products['products_price'] > 0) ? $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_contents2);
?>
<!-- new_products_eof //-->

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...