I have been trying to combine these 2 mods
http://forum.x-cart.com/showpost.php?p=158429&postcount=1 and
http://forum.x-cart.com/showthread.php?t=34157 I believe I am using Telafirma's of the Random Products mod.
I am stuck on how to get it to limit the number by using the Random Product Option setting in the admin panel. I can hard code the Qty but would prefer to select it in the admin section.
Here is the code:
Code:
<?php
#
# randoms.php based on recommends.php
#
if ( !defined('XCART_START') ) { header("Location: home.php"); die("Access denied"); }
$config["Random_Products"]["number_of_randoms"] = max(intval($config["Random_Products"]["number_of_randoms"]), 0);
#
# Defining the conditions for selecting products for the list
#
$avail_condition = "";
if ($config["General"]["unlimited_products"] == "N" && $config["General"]["disable_outofstock_products"] == "Y") {
$avail_condition = " AND $sql_tbl[products].avail>0 ";
}
//Set Dates
$today = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
$lastmonth = mktime(0, 0, 0, date("m")-1, date("d"), date("Y"));
$query_ids = array();
$rnd = rand();
$query_ids = func_query_column("SELECT xcart_order_details.productid, COUNT(*) AS count
FROM xcart_order_details
LEFT JOIN xcart_orders ON (xcart_order_details.orderid = xcart_orders.orderid)
WHERE xcart_order_details.productid NOT LIKE '0'
AND xcart_orders.status NOT LIKE 'F'
AND xcart_orders.status NOT LIKE 'I'
AND xcart_orders.status NOT LIKE 'D'
AND xcart_orders.status NOT LIKE 'X'
AND xcart_orders.date BETWEEN '$lastmonth' AND '$today'
GROUP BY xcart_order_details.productid
ORDER BY count DESC
LIMIT 20 ");
x_load("product");
$randoms = func_search_random_products(
" AND $sql_tbl[products].productid IN ('".implode("','", $query_ids)."')",
(isset($user_account) && isset($user_account["membershipid"])) ? max(intval($user_account["membershipid"]), 0) : 0,
false,
$config["Random_Products"]["number_of_randoms"]
);
#echo"<pre>";print_r($randoms);echo"</pre>";
if (!empty($randoms))
$smarty->assign("randoms", $randoms);
?>
Thanks, Mike