Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Starting At Price Contribution (Shows Prices from X.XX next to sub-categories)


stubbsy

Recommended Posts

Hi there,

 

I have found this contribution which was written a number of years ago (and the author is no longer a member).

 

It adds a nice feature to OScommerce where by it shows the lowest price of a product in a sucategory under the subcategory image.

 

pricesfrom.jpg

 

It does the job in that it shows the lowest priced item in a category, but the problem is that it takes about 30 seconds to display the page on my site as I have a few thousand products.

 

I wondered if anyone would care to take a look through this small piece of code to see why it is taking so long to display the pages and maybe fix it :) ?

 

Any help much appreciated

 

Thanks

 

Dave

 

"Starting At Price" Mod for osCommerce 2.2 MS2 only
---------------------------------------------------
This mod adds a line beneath each of your categories with the price (Starting at price) of the cheapest product in the subcategories. A lot of online shops (such as sonystyle.com) have this feature and I wanted to have the same one on my site. I also decided to share this contribution with the community. This is my first contribution. Feel free to build up on it, but dont forget to keep the original copyright in place. Thanks.
----------------------

October 31, 2004 - Version 1.0 Released by Stas Baydakov (original author)


Released under the GNU General Public License

---------------------------------------------------
--------------INSTALLATION-------------------------
Follow the steps below to successfully install this mod.

------STEP 1-------
OPEN (../includes/languages/english/index.php)

-----

FIND:
 define('HEADING_TITLE', 'Categories');


ADD AFTER:
 define('STARTING_AT_PRICE', 'Starting at');
-------------------

------STEP 2-------
----------
-OPTION A: Use this option if you do not have BTS template system installed-
OPEN (../index.php)

-OPTION B: Use this option if you have BTS template system installed-
OPEN (../templates/your_template_folder/content/index_nested.tpl.php)
----------

FIND:

while ($categories = tep_db_fetch_array($categories_query)) {
  $rows++;


ADD AFTER:

$startprice = '';
$cats = '';
$cats[] = $categories['categories_id']; // current catID as starting value
// put cat-IDs of all cats nested in current branch into $cats array, go through all subbranches
for($i=0;$i<count($cats);$i++) {
	$categorie_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$cats[$i] . "'"); 
	while ($categorie = tep_db_fetch_array($categorie_query)) {
		$cats[] = $categorie['categories_id'];
	}
	$cats=array_unique($cats); // sort out doubles
}

$num = (int) 1.0;
$starting_price_query = tep_db_query("select p.products_id, 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.categories_id in (".implode(', ', $cats).") and p.products_status = '1' order by products_price asc limit " . $num);

while ($starting_price = tep_db_fetch_array($starting_price_query)) {
	$startprice = '<b>' . STARTING_AT_PRICE . ' ' . $currencies->display_price($starting_price['products_price'], tep_get_tax_rate($starting_price['products_tax_class_id'])) . '</b>';
}

-----

FIND:

  echo '				<td align="center" class="smallText" width="' . $width . '" valign="top"><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name']) . '<br>' . $categories['categories_name'] . '</a></td>' . "\n";


REPLACE WITH:

  echo '				<td align="center" class="smallText" width="' . $width . '" valign="top"><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name']) . '<br>' . $categories['categories_name'] . '</a><br>' . $startprice . '</td>' . "\n";
-----

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