static function _createAutoPointCoupon($controller, $member, $autoCouponConf) { $coupon = new Coupon(); $coupon->setTitle('Bonus Coupon'); $coupon->setDiscountPercentage(Helper_Structure::getArrayValue($autoCouponConf, 'discount_percentage')); $coupon->setDiscountAmount(Helper_Structure::getArrayValue($autoCouponConf, 'discount_amount')); $str = $member->getEmail() . $controller->now . 'AutoPointCoupon'; $suffix = substr(md5($str), 0, 7); $coupon->setCouponCode('BONUS-' . $member->getEmail() . '-' . $suffix); $couponType = 'product'; if (Helper_Structure::getArrayValue($autoCouponConf, 'coupon_type')) { $couponType = Helper_Structure::getArrayValue($autoCouponConf, 'coupon_type'); } $coupon->setCouponType($couponType); $coupon->setIsAllProducts(TRUE); $coupon->setNumOfUsage(1); if ($expirySeconds = Helper_Structure::getArrayValue($autoCouponConf, 'expiry_seconds')) { $coupon->setExpiryDate(Helper_Date::formatSqlDatetime($controller->now + $expirySeconds)); } return $coupon; }