plugin_name = 'bingo'; // $X回に1回が当たり // ここの値を変更して下さい。 $this->X = 1; } function isEnable($class_name) { // parent::isEnable($class_name); $arrEnableClass = array( 'LC_Page_Shopping_Confirm_Ex', 'LC_Page_Shopping_Complete_Ex', ); return in_array($class_name, $arrEnableClass); } function preProcess(&$objPage) { // parent::preProcess($objPage); $class_name = get_class($objPage); switch ($class_name) { case 'LC_Page_Shopping_Confirm_Ex': if ($_POST['mode'] == 'confirm') { $this->lfDrawing(); } break; } } function process(&$objPage) { // parent::process($objPage); $class_name = get_class($objPage); switch ($class_name) { case 'LC_Page_Shopping_Confirm_Ex': break; case 'LC_Page_Shopping_Complete_Ex': $is_bingo = $_SESSION['plugin_bingo']['is_bingo']; if ($is_bingo) { if (SC_Utils_Ex::sfIsMobileSite()) { $objPage->tpl_mainpage = DATA_REALDIR . 'plugin/' . $this->plugin_name . '/templates/mobile/shopping/complete.tpl'; } else { $objPage->tpl_mainpage = DATA_REALDIR . 'plugin/' . $this->plugin_name . '/templates/shopping/complete.tpl'; } } break; } } function lfDrawing() { // is_bingoを初期化 $_SESSION['plugin_bingo'] = array('is_bingo'=>false); $rand = mt_rand(1, $this->X); // 当たり! if ($rand === 1) { $objDb = new SC_Helper_DB_Ex(); $objCartSess = new SC_CartSession(); $objCustomer = new SC_Customer(); $objSiteSess = new SC_SiteSession(); $tmpData = $objDb->sfGetOrderTemp($uniqid); // 当たりなので、使用ポイントを未使用にする。 $tmpData['use_point'] = 0; $cartKey = $_SESSION['cartKey']; $results = $objCartSess->calculate($cartKey, $objCustomer, $tmpData['use_point'], $tmpData['deliv_pref'], $tmpData['payment_id'], $tmpData['charge']); // 合計を0にするために合計額を値引にセット $tmpData['discount'] = $results['total']; // メモに「当たり」と記載する $tmpData['note'] = '当たり'; $uniqid = $objSiteSess->getUniqId(); $objDb->sfRegistTempOrder($uniqid, $tmpData); // is_bingoセット $_SESSION['plugin_bingo'] = array('is_bingo'=>true); } } } ?>