Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

What's New and 'Out ofStock'


Jos Medinger

Recommended Posts

Posted

Hi there

 

Does anyone know where I can switch off the display of a newly added product to the catalog which is marked as 'OUT OF STOCK' from being shown in the What's New section?

 

Jos

===============

Simple yet Creative

Get Online Web Design : getonlinedesign.com

===============

Posted

depending on which new-products display you are talkin about (big one on index or small box in column left) you need to modify the query that each of these uses.

 

the query for the big one is found in includes/modules/new_products.php

i think the box one is in includes/boxes/new_products.php

 

it looks like this (big one)

 

-----------CODE STARTS

 

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);

}

 

-----------CODE ENDS

 

 

 

 

you need to add an extra where clause into both of the above queries. This should read

 

AND stock > 0

 

but you need to find which table the stock level is in and make sure the query looks in the right tables...ill have a look and post when i find out.

 

good luck

always here to offer some useless advice....

Posted

Thanks for this gazzzzza

 

I'll look too and see if I can figure out what goes where

 

I'd still appreciate your re-post though!

 

Jos

===============

Simple yet Creative

Get Online Web Design : getonlinedesign.com

===============

Posted

right

stock is in products table

 

so

im guessing

 

modify this bit

 

select p.products_id, p.products_image, p.products_tax_class_id

 

to

 

select p.products_id, p.products_image, p.products_tax_class_id, p.stock

 

then this bit

 

where products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);

 

to

 

where products_status = '1' AND stock > '0' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);

 

 

you will need this in both queries cos it runs one or t'other depending on whether you are in a category or not.

 

 

(one thing- u may not need the ''s around '0' - cant remember)

let me know how it goes :)

once that one is working then we can do the box one

always here to offer some useless advice....

Posted

Gareth - that generates the following error

 

1054 - Unknown column 'p.stock' in 'field list'

select p.products_id, p.products_image, p.products_tax_class_id,p.stock, if(s.status, s.specials_new_products_price, p.products_price) as products_price from products p left join specials s on p.products_id = s.products_id where products_status = '1' AND stock > '0' order by p.products_date_added desc limit 3

[TEP STOP]

 

Jos

===============

Simple yet Creative

Get Online Web Design : getonlinedesign.com

===============

Archived

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

×
×
  • Create New...