/** * Get Rule Module Info * * Retrieves a list of discount rules enabled by the customer * * @access public * @param string $type - The type of the rules * @return array Returns an array of initialized rules */ function GetRuleModuleInfo($type = 'all') { static $cache = array(); if (isset($cache[$type])) { return $cache[$type]; } if ($type == 'all') { $query = "\n SELECT *\n FROM [|PREFIX|]discounts ORDER BY sortorder DESC"; } else { $query = "\n SELECT *\n FROM [|PREFIX|]discounts\n WHERE discountruletype='rule_" . $type . "'\n ORDER BY sortorder DESC"; } $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $DiscountInfo = array(); while ($var = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { if (($var['discountruletype'] == 'rule_percentoffitemsincat' || $var['discountruletype'] == 'rule_percentoffitemsinseries') && $var['discountenabled']) { GetModuleByIdNew('rule', $object, $var['discountruletype']); $DiscountInfo = initializeObj($var, $DiscountInfo); } } return $DiscountInfo; }
/** * Get Rule Module Info * * Retrieves a list of discount rules enabled by the customer * * @access public * @param string $type - The type of the rules * @return array Returns an array of initialized rules */ function GetDiscountRuleModuleInfo($type = 'all') { static $cache = array(); if (isset($cache[$type])) { return $cache[$type]; } //$date = ConvertDateToTimeWithHours(date("m/d/Y"),date("H:i")); $cdate = mktime(date("H") - 5, date("i"), 0, date("m"), date("d"), date("Y")); if ($type == 'all') { $query = "\n SELECT *\n FROM [|PREFIX|]discounts \n WHERE \n (discountexpiry=0 || {$cdate} < discountexpiry)\n AND (discountstart=0 || {$cdate} > discountstart) \n AND (discountmaxuses=0 || discountcurrentuses < discountmaxuses)\n ORDER BY sortorder DESC"; } else { $query = "\n SELECT *\n FROM [|PREFIX|]discounts\n WHERE discountruletype='rule_" . $type . "'\n AND (discountexpiry=0 || {$cdate} < discountexpiry)\n AND (discountstart=0 || {$cdate} > discountstart)\n AND (discountmaxuses=0 || discountcurrentuses < discountmaxuses)\n ORDER BY sortorder DESC"; } $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $DiscountInfo = array(); while ($var = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { if (($var['discountruletype'] == 'rule_percentoffitemsincat' || $var['discountruletype'] == 'rule_percentoffitemsinseries') && $var['discountenabled']) { GetModuleByIdNew('rule', $object, $var['discountruletype']); $DiscountInfo = initializeObj($var, $DiscountInfo); } } return $DiscountInfo; }