Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

cieto Featured Products v2 JUST RELEASE!


emiliano

Recommended Posts

Cieto Featured Products v2 by Emiliano Casta?o <[email protected]>

for osCommerce V2.2 CVS (http://www.oscommerce.com)

CHANGELOG

 

03/02/2002 V2.0

Cleaner files.

Posibility to set up as many columns as you want.

Shows only products from the category you are in (i hope).

 

---

 

Download at:

http://www.oscommerce.com/community/contributions,505

 

---

 

Thanks to everyone

 

Emiliano Casta?o

[email protected]

patagonia, argentina

Link to comment
Share on other sites

Shows only products from the category you are in (i hope).

 

hey emiliano.

 

good to see you back... I don't see in this new version where it pulls products from the category you are in...

 

also in modules/featured_products.php for the if statement to work, in featured.php, you need to pull the products description.

The only thing necessary for evil to flourish is for good men to do nothing

- Edmund Burke

Link to comment
Share on other sites

Emiliano,

 

I am pretty sure this new version won't pull from categories. I just tried it and it does not.

 

I still run v1.5 b/c I have modified it to pull from categories...

 

here is my includes/modules/featured.php file:

<?php

/*

 osCommerce, Open Source E-Commerce Solutions

 http://www.oscommerce.com



 Copyright (c) 2002 osCommerce



 Released under the GNU General Public License

 

 Featured Products Listing

*/



 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_FEATURED);



if(FEATURED_PRODUCTS_DISPLAY == true) 

   {

?>



<!-- body //-->

<table border="0" cellspacing="0" cellpadding="0">

      <tr>

   <td class="pageHeading">Featured Products</td>

   </tr>

   <tr>

       <td>

<?php



 $featured_products_category_id = $new_products_category_id;

 

  if ( (!isset($featured_products_category_id)) || ($featured_products_category_id == '0') ) { // We are not in category depth; we are on the main page

   $featured_products_query_raw = "select p.products_id, pd.products_name, pd.products_description, pd.products_shortdescription, p.products_image, p.products_tax_class_id, s.status as specstat, s.specials_new_products_price, p.products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' left join " . TABLE_FEATURED . " f on p.products_id = f.products_id where p.products_status = '1' and f.status = '1' order by rand() DESC limit " . MAX_DISPLAY_FEATURED_PRODUCTS; //and f.status = '1'

 } else { // We are in category depth; pull the featured from the category by random

   $featured_products_query_raw = "select distinct p.products_id, pd.products_name, p.products_image, p.products_tax_class_id, pd.products_description, pd.products_shortdescription, s.status as specstat, s.specials_new_products_price, p.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 left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' left join " . TABLE_FEATURED . " f on p.products_id = f.products_id where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . $featured_products_category_id . "' and p.products_status = '1' order by rand() DESC limit " . MAX_DISPLAY_FEATURED_PRODUCTS; //and f.status = '1' 

 }



 $featured_products_query = tep_db_query($featured_products_query_raw);

 while ($featured_products = tep_db_fetch_array($featured_products_query)) {

//    $featured_products['products_name'] = tep_get_products_name($featured_products['products_id']);

//    $featured_products['products_description'] = tep_get_products_description($featured_products['products_id']);

   $featured_products_array[] = array('id' => $featured_products['products_id'],

                                 'name' => $featured_products['products_name'],

         'description' => $featured_products['products_description'],

           'shortdescription' => $featured_products['products_shortdescription'],

         'image' => $featured_products['products_image'],

                                 'price' => $featured_products['products_price'],

                                 'specials_price' => $featured_products['specials_new_products_price'],

                                 'tax_class_id' => $featured_products['products_tax_class_id'],

                                 'manufacturer' => $featured_products['manufacturers_name']);

 }



 require(DIR_WS_MODULES  . FILENAME_FEATURED_PRODUCTS);

?>

       </td>

     </tr>

   </table>

<?php

} else // If it's disabled, then include the original New Products box 

   { 

     include (DIR_WS_MODULES . FILENAME_NEW_PRODUCTS); 

   }

?>

 

if you are in category depth, it pulls a random product from that category, whether it is selected as featured or not (that can be changed to pull featured from that category by placing "and f.status = '1'" back into the statement for category depth)... if you are on the main page, it pulls random products from those selected as featured in admin from any category.

The only thing necessary for evil to flourish is for good men to do nothing

- Edmund Burke

Link to comment
Share on other sites

emiliano...

 

in default.php, the 1st instance of FILENAME_FEATURED should look like:

 

<?php $new_products_category_id = $current_category_id; include(DIR_WS_MODULES . FILENAME_FEATURED); ?>

 

I dunno... I didn't change anything other than modules/featured.php form the 1.3 version.

 

that is the only thing I can thing of that would keep it from working.

The only thing necessary for evil to flourish is for good men to do nothing

- Edmund Burke

Link to comment
Share on other sites

I do believe I got this puppy to work in the category depth as well as the main page. Take a look at http://www.cleopas.org/catalog. Here is the includes/modules/featured.php file as it stands now. If there is an easier way to code this please let me know.

<?php

/*

 osCommerce, Open Source E-Commerce Solutions

 [url=http://www.oscommerce.com]http://www.oscommerce.com[/url]



 Copyright (c) 2002 osCommerce



 Released under the GNU General Public License

 

 Featured Products Listing

*/



 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_FEATURED);



?>

<!-- body //-->

<?php

   

   if(FEATURED_PRODUCTS_DISPLAY == true) {

     $featured_products_category_id = $current_category_id;

  if ((!isset($featured_products_category_id)) || ($featured_products_category_id == '0')) // We are not in category depth; we are on main page

  {

 $featured_products_query_raw = "select p.products_id, pd.products_name, pd.products_shortdescription, p.products_image, p.products_price, p.products_tax_class_id, IF(s.status = 1, s.specials_new_products_price, NULL) as specials_new_products_price, products_date_added, manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "'  left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id left join " . TABLE_FEATURED . " f on p.products_id = f.products_id where p.products_status = '1' and f.status = '1' order by rand() limit " . MAX_DISPLAY_FEATURED_PRODUCTS;  

 } else { // We are in category depth; pull the featured from the category by random

 $featured_products_query_raw = "select p.products_id, pd.products_name, pd.products_shortdescription, p.products_image, p.products_price, p.products_tax_class_id, IF(s.status = 1, s.specials_new_products_price, NULL) as specials_new_products_price, products_date_added, manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "'  left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id left join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c on p.products_id = p2c.products_id left join " . TABLE_CATEGORIES . " c on p2c.categories_id = c.categories_id left join " . TABLE_FEATURED . " f on p.products_id = f.products_id where c.parent_id = '" . $current_category_id . "' and p.products_status = '1' and f.status = '1' order by rand() limit " . MAX_DISPLAY_FEATURED_PRODUCTS;

  }

  $g = 0;

 $featured_products_query = tep_db_query($featured_products_query_raw);

 while ($featured_products = tep_db_fetch_array($featured_products_query)) {

   $featured_products_array[] = array('id' => $featured_products['products_id'],

                                 'name' => $featured_products['products_name'],

         'shortdescription' => $featured_products['products_shortdescription'],

         'image' => $featured_products['products_image'],

                                 'price' => $featured_products['products_price'],

                                 'specials_price' => $featured_products['specials_new_products_price'],

                                 'tax_class_id' => $featured_products['products_tax_class_id'],

                                 'manufacturer' => $featured_products['manufacturers_name']);

 $g ++;

 }

if ($g >= 1) {

  

//BOF Added for new InfoBox Look

 $info_box_contents = array();

 $info_box_contents[] = array('align' => 'left', 'text' => TABLE_HEADING_FEATURED_PRODUCTS);

 new infoBoxHeading($info_box_contents, true, true);

//EOF Added for new InfoBox Look



echo "<table class='infoBox' width='100%' border='0' cellspacing='0' cellpadding='1'>";

  echo "<tr><td>";

 echo "<table class='infoBoxContents' width='100%' border='0' cellspacing='0' cellpadding='0'>";

    echo "<tr><td>";

 

   require(DIR_WS_MODULES  . FILENAME_FEATURED_PRODUCTS);



      echo "</td></tr></table>";

      echo "</td></tr></table>";  

 }	

 else // If it's disabled, then include the original New Products box

{

     include (DIR_WS_MODULES . FILENAME_NEW_PRODUCTS);

}     

 }

  else // If it's disabled, then include the original New Products box

{

     include (DIR_WS_MODULES . FILENAME_NEW_PRODUCTS);

}  

?>

Link to comment
Share on other sites

I made a slight change to the includes/modules/featured.php file... this seems to be faster.

 

http://www.cleopas.org/catalog/

 

<?php

/*

 osCommerce, Open Source E-Commerce Solutions

 http://www.oscommerce.com



 Copyright (c) 2002 osCommerce



 Released under the GNU General Public License

 

 Featured Products Listing

*/



 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_FEATURED);



?>

<!-- body //-->

<?php

   

   if(FEATURED_PRODUCTS_DISPLAY == true) {

     $featured_products_category_id = $current_category_id;

  if ((!isset($featured_products_category_id)) || ($featured_products_category_id == '0')) // We are not in category depth; we are on main page

  {

 $featured_products_query_raw = "select distinct p.products_id, pd.products_name, pd.products_shortdescription, p.products_image, p.products_price, p.products_tax_class_id, IF(s.status = 1, s.specials_new_products_price, NULL) as specials_new_products_price, products_date_added, manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "'  left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id left join " . TABLE_FEATURED . " f on p.products_id = f.products_id where p.products_status = '1' and f.status = '1' order by rand() limit " . MAX_DISPLAY_FEATURED_PRODUCTS;  

 } else { // We are in category depth; pull the featured from the category by random

 $featured_products_query_raw = "select distinct p.products_id, pd.products_name, pd.products_shortdescription, p.products_image, p.products_price, p.products_tax_class_id, IF(s.status = 1, s.specials_new_products_price, NULL) as specials_new_products_price, products_date_added, manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "'  left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id left join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c on p.products_id = p2c.products_id left join " . TABLE_CATEGORIES . " c on p2c.categories_id = c.categories_id left join " . TABLE_FEATURED . " f on p.products_id = f.products_id where c.parent_id = '" . $current_category_id . "' and p.products_status = '1' and f.status = '1' order by rand() limit " . MAX_DISPLAY_FEATURED_PRODUCTS;

  }

  $featured_products_query = tep_db_query($featured_products_query_raw);

    while ($featured_products = tep_db_fetch_array($featured_products_query)) {

     $featured_products_array[] = array('id' => $featured_products['products_id'],

                                 'name' => $featured_products['products_name'],

         'shortdescription' => $featured_products['products_shortdescription'],

         'image' => $featured_products['products_image'],

                                 'price' => $featured_products['products_price'],

                                 'specials_price' => $featured_products['specials_new_products_price'],

                                 'tax_class_id' => $featured_products['products_tax_class_id'],

                                 'manufacturer' => $featured_products['manufacturers_name']);

  }

 $fsize = sizeof($featured_products_array);

 if ($fsize >= '1') {

   

 $info_box_contents = array();

 $info_box_contents[] = array('align' => 'left', 'text' => TABLE_HEADING_FEATURED_PRODUCTS);

 new infoBoxHeading($info_box_contents, true, true);



echo "<table class='infoBox' width='100%' border='0' cellspacing='0' cellpadding='1'>";

  echo "<tr><td>";

 echo "<table class='infoBoxContents' width='100%' border='0' cellspacing='0' cellpadding='0'>";

    echo "<tr><td>";

 

   require(DIR_WS_MODULES  . FILENAME_FEATURED_PRODUCTS);



      echo "</td></tr></table>";

      echo "</td></tr></table>";  

 }	

 else // If it's disabled, then include the original New Products box

{

     include (DIR_WS_MODULES . FILENAME_NEW_PRODUCTS);

}     

 }

  else // If it's disabled, then include the original New Products box

{

     include (DIR_WS_MODULES . FILENAME_NEW_PRODUCTS);

}  

?>

Link to comment
Share on other sites

  • 3 weeks later...

Ummmmmmmmm, OK. It's working. Holy crap do I feel like a dunce...

 

I was under the impression that the FEATURED PRODUCTS was actually going to replace the small infobox on column_left.php and NOT the New Products box on default.php below the welcome message....... Is this right?!?!

Link to comment
Share on other sites

This is right... however when there are no featured products the new products box will show.

 

I don't have the time for it now but there should be no reason why you could not change the new products box to a featured products box or at least copy it... in theory.

 

If havn't done it yourself... I'll look into it tonight.

Link to comment
Share on other sites

Bloody hell, I'm like a mean, lean posting machine.

 

Ignore the above. I thought that this would be a problem until I decided to have BOTH a featured products box AND a <Month> Arrivals box.

 

This way I can have new products AND special, older products displayed.

Link to comment
Share on other sites

Just make sure you realize that, with the way that you may have it set up now ( can always be changed ), if you don't have any featured products you would get 2 new products boxes.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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