About Club osCommerce

Showcasing osCommerce - the good, the bad and the ugly!

StumbleUpon It! DIGG It!

Make a NEW featured product box

Written By Gary on Apr 08 2008 ·

Mark asks;

how would i go about re-coding [your featured product contribution] to keep the "new products for..." feature [and have the featured products in their own box]?

Step 1: Rename the module (new_products.php) in the zip to "featured_products.php"

Step 1a: Change the line of code in module "featured_products.php" from this;

PHP:
  1. $new_products_query = tep_db_query("select p.products_featured, 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_featured DESC, p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);

to this:

PHP:
  1. $new_products_query = tep_db_query("select p.products_featured, 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_featured = '1' AND p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_featured DESC, p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);

Step 1b: Change code in the same file from this:

PHP:
  1. TABLE_HEADING_NEW_PRODUCTS, strftime('%B')

to this:

PHP:
  1. TABLE_HEADING_FEATURED_PRODUCTS

Step 1c: Add this code into /includes/languages/english/index.php

PHP:
  1. define('TABLE_HEADING_FEATURED_PRODUCTS', 'Featured Products');

Step 2: Install the contribution which you have amended in Step 1, 1a, 1b and 1c!

Step 3: In index.php, add this code;

PHP:
  1. <?php if (tep_count_featured_products()> 0)  { ?>
  2.   <tr>
  3.     <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  4.   </tr>
  5.   <tr>
  6.     <td><?php include(DIR_WS_MODULES . 'featured_products.php'); ?></td>
  7.   </tr>
  8. <?php } ?>

Step 4: In /includes/functions/general.php add this extra code;

PHP:
  1. function tep_count_featured_products() {
  2.   $featured_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " where products_featured = '1'");
  3.   $featured = tep_db_fetch_array($featured_query);
  4. return $featured['total'];
  5. }

Step 5: If you get it working following the instructions above, Buy Me A Beer, I like beer ;) !

If you cannot get it working, I offer an install service - please email me on oscshops@gmail.com

Gary


Buy Gary A Beer?
Buying me a "beer" helps me to keep my contributions updated and keep this blog alive. Cheers!


No Comments

No comments yet.

Leave a comment

RSS feed for comments on this post · TrackBack URL

Hot 100 osCommerce Shops

View the osCommerce HOT 100These are the best looking, most exceptional osCommerce Stores as voted for by you.

New to osCommerce - get inspiration from these beautiful shops. Reckon your site has what it takes to become a member of the HOT 100? Submit it!