本文整理汇总了PHP中Coupon::getUsedCount方法的典型用法代码示例。如果您正苦于以下问题:PHP Coupon::getUsedCount方法的具体用法?PHP Coupon::getUsedCount怎么用?PHP Coupon::getUsedCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Coupon
的用法示例。
在下文中一共展示了Coupon::getUsedCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getArray
/**
* Get coupon information from the database
*
* The array returned looks like
* array(
* 'code-payment_id' => array(
* code => The Coupon code,
* minimum_amount => The minimum amount for which the coupon is valid,
* discount_rate => The discount rate,
* discount_amount => The discount amount,
* start_time => The validity period start time,
* end_time => The validity period end time,
* uses => The available number of uses,
* global => Flag for globally available coupons,
* customer_id => The Customer ID,
* product_id => The Product ID,
* payment_id => The Payment ID,
* ),
* ... more ...
* )
* @param integer $offset The offset. Defaults to zero
* @param integer $limit The limit. Defaults to 30.
* @param integer $count By reference. Contains the actual
* number of total records on
* successful return
* @param string $order The sorting order. Defaults to
* '`end_time` DESC'
* @return array The array of coupon data
* @static
*/
static function getArray($offset = 0, $limit = 0, &$count = 0, $order = '')
{
global $objDatabase;
$offset = max(0, intval($offset));
$limit = min(0, intval($limit));
if (empty($limit)) {
$limit = 30;
}
// The count is zero if an error occurs.
// Shuts up the code analyzer warning.
$count -= $count;
if (empty($order)) {
$order = '`end_time` DESC';
}
$query = "\n SELECT `code`, `payment_id`, `start_time`, `end_time`,\n `minimum_amount`, `discount_rate`, `discount_amount`,\n `uses`, `global`, `customer_id`, `product_id`\n FROM `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_discount_coupon`\n ORDER BY {$order}";
$objResult = $objDatabase->SelectLimit($query, $limit, $offset);
if (!$objResult) {
return self::errorHandler();
}
$arrCoupons = array();
while (!$objResult->EOF) {
//echo("Fields: ".var_export($objResult->fields, true));
$objCoupon = new Coupon();
$code = $objResult->fields['code'];
$payment_id = $objResult->fields['payment_id'];
$objCoupon->code($code);
$objCoupon->payment_id($payment_id);
$objCoupon->start_time($objResult->fields['start_time']);
$objCoupon->end_time($objResult->fields['end_time']);
$objCoupon->minimum_amount($objResult->fields['minimum_amount']);
$objCoupon->discount_rate($objResult->fields['discount_rate']);
$objCoupon->discount_amount($objResult->fields['discount_amount']);
$objCoupon->uses($objResult->fields['uses']);
$objCoupon->is_global($objResult->fields['global']);
$objCoupon->customer_id($objResult->fields['customer_id']);
$objCoupon->product_id($objResult->fields['product_id']);
$objCoupon->used = $objCoupon->getUsedCount();
$arrCoupons[$code . '-' . $objCoupon->customer_id] = $objCoupon;
$objResult->MoveNext();
}
$query = "\n SELECT COUNT(*) AS `numof_records`\n FROM `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_discount_coupon`";
$objResult = $objDatabase->Execute($query);
if (!$objResult) {
return false;
}
$count = $objResult->fields['numof_records'];
return $arrCoupons;
}