For that extra condition to work we need to search two extra tables in the database.
Try to replace
Code:
$prods = func_query("SELECT * FROM $sql_tbl[products], $sql_tbl[clean_urls] WHERE resource_type = 'P' AND productid = resource_id AND forsale = 'Y'");
with
Code:
$prods = func_query("SELECT * FROM $sql_tbl[xcart_clean_urls], $sql_tbl[xcart_products_categories], $sql_tbl[xcart_products], $sql_tbl[xcart_categories] WHERE xcart_clean_urls.resource_type = 'P' AND xcart_products.productid = xcart_clean_urls.resource_id AND main = 'Y' AND xcart_products.productid = xcart_products_categories.productid AND xcart_products.forsale = "Y" AND xcart_products_categories.categoryid = xcart_categories.categoryid AND xcart_categories.avail = 'Y'");
I hope this works for you. Please check carefully to see if the result is correct.
Andreas