tpl_title = "現在のカゴの中"; } /** * Page のプロセス. * * @return void */ function process() { parent::process(); $this->action(); $this->sendResponse(); } /** * Page のアクション. * * @return void */ function action() { $objView = new SC_SiteView(false); $objCartSess = new SC_CartSession(); $objSiteSess = new SC_SiteSession(); $objSiteInfo = $objView->objSiteInfo; $objCustomer = new SC_Customer(); $objDb = new SC_Helper_DB_Ex(); $objProduct = new SC_Product(); $i = 0; $this->cartKeys = $objCartSess->getKeys(); foreach ($this->cartKeys as $key) { // 商品購入中にカート内容が変更された。 if($objCartSess->getCancelPurchase($key)) { $this->tpl_message = "商品購入中にカート内容が変更されましたので、お手数ですが購入手続きをやり直して下さい。"; } } $this->cartItems =& $objCartSess->getAllCartList(); if (!isset($_POST['mode'])) $_POST['mode'] = ""; switch($_POST['mode']) { case 'up': $objCartSess->upQuantity($_POST['cart_no'], $_POST['cartKey']); $this->objDisplay->reload(); // PRG pattern break; case 'down': $objCartSess->downQuantity($_POST['cart_no'], $_POST['cartKey']); $this->objDisplay->reload(); // PRG pattern break; case 'delete': $objCartSess->delProduct($_POST['cart_no'], $_POST['cartKey']); $this->objDisplay->reload(); // PRG pattern break; case 'confirm': // カート内情報の取得 $cartKey = $_POST['cartKey']; $cartList = $objCartSess->getCartList($cartKey); // カート商品が1件以上存在する場合 if(count($cartList) > 0) { // 正常に登録されたことを記録しておく $objSiteSess->setRegistFlag(); $pre_uniqid = $objSiteSess->getUniqId(); // 注文一時IDの発行 $objSiteSess->setUniqId(); $uniqid = $objSiteSess->getUniqId(); // エラーリトライなどで既にuniqidが存在する場合は、設定を引き継ぐ if($pre_uniqid != "") { $sqlval['order_temp_id'] = $uniqid; $where = "order_temp_id = ?"; $objQuery = new SC_Query(); $objQuery->update("dtb_order_temp", $sqlval, $where, array($pre_uniqid)); } // カートを購入モードに設定 $objCartSess->saveCurrentCart($uniqid, $cartKey); // 購入ページへ $this->objDisplay->redirect(URL_SHOP_TOP); exit; } break; default: break; } // 基本情報の取得 $this->arrInfo = $objSiteInfo->data; foreach ($this->cartKeys as $key) { // カート集計処理 $this->tpl_message = $objCartSess->checkProducts($key); $this->tpl_total_inctax[$key] = $objCartSess->getAllProductsTotal($key); $this->tpl_total_tax[$key] = $objCartSess->getAllProductsTax($key); // ポイント合計 $this->tpl_total_point[$key] = $objCartSess->getAllProductsPoint($key); $this->arrData = $objCartSess->calculate($key, $objCustomer); // 送料無料までの金額を計算 $this->tpl_deliv_free[$key] = $this->arrInfo['free_rule'] - $this->tpl_total_inctax[$key]; } // ログイン判定 if($objCustomer->isLoginSuccess()) { $this->tpl_login = true; $this->tpl_user_point = $objCustomer->getValue('point'); $this->tpl_name = $objCustomer->getValue('name01'); } // 前頁のURLを取得 $this->tpl_prev_url = $objCartSess->getPrevURL(); } /** * モバイルページを初期化する. * * @return void */ function mobileInit() { $this->init(); } /** * Page のプロセス(モバイル). * * @return void */ function mobileProcess() { parent::mobileProcess(); $this->mobileAction(); $this->sendResponse(); } /** * Page のアクション(モバイル). * * @return void */ function mobileAction() { // 買い物を続ける場合 if ($_REQUEST['mode'] == 'continue') { $this->objDisplay->redirect($this->getLocation(MOBILE_URL_SITE_TOP)); exit; } $objView = new SC_MobileView(false); $objCartSess = new SC_CartSession(); $objSiteSess = new SC_SiteSession(); $objSiteInfo = $objView->objSiteInfo; $objCustomer = new SC_Customer(); $objDb = new SC_Helper_DB_Ex(); // 商品購入中にカート内容が変更された。 if($objCartSess->getCancelPurchase()) { $this->tpl_message = "商品購入中にカート内容が変更されましたので、お手数ですが購入手続きをやり直して下さい。"; } switch($_POST['mode']) { case 'confirm': // カート内情報の取得 $arrRet = $objCartSess->getCartList(); $max = count($arrRet); $cnt = 0; for ($i = 0; $i < $max; $i++) { // 商品規格情報の取得 $arrData = $objDb->sfGetProductsClass($arrRet[$i]['id']); // DBに存在する商品 if($arrData != "") { $cnt++; } } // カート商品が1件以上存在する場合 if($cnt > 0) { // 正常に登録されたことを記録しておく $objSiteSess->setRegistFlag(); $pre_uniqid = $objSiteSess->getUniqId(); // 注文一時IDの発行 $objSiteSess->setUniqId(); $uniqid = $objSiteSess->getUniqId(); // エラーリトライなどで既にuniqidが存在する場合は、設定を引き継ぐ if($pre_uniqid != "") { $sqlval['order_temp_id'] = $uniqid; $where = "order_temp_id = ?"; $objQuery = new SC_Query(); $objQuery->update("dtb_order_temp", $sqlval, $where, array($pre_uniqid)); } // カートを購入モードに設定 $objCartSess->saveCurrentCart($uniqid); // 購入ページへ $this->objDisplay->redirect(MOBILE_URL_SHOP_TOP); exit; } break; default: break; } if (!isset($_GET['mode'])) $_GET['mode'] = ""; /* * FIXME sendRedirect() を使った方が良いが無限ループしてしまう... */ switch($_GET['mode']) { case 'up': $objCartSess->upQuantity($_GET['cart_no']); SC_Utils_Ex::sfReload(session_name() . "=" . session_id()); break; case 'down': $objCartSess->downQuantity($_GET['cart_no']); SC_Utils_Ex::sfReload(session_name() . "=" . session_id()); break; case 'delete': $objCartSess->delProduct($_GET['cart_no']); SC_Utils_Ex::sfReload(session_name() . "=" . session_id()); break; } // カート集計処理 if (empty($arrData)) { $arrData = array(); } $objDb->sfTotalCart($this, $objCartSess); $this->arrData = $objDb->sfTotalConfirm($arrData, $this, $objCartSess, null, $objCustomer); // 基本情報の取得 $this->arrInfo = $objSiteInfo->data; // ログイン判定 if($objCustomer->isLoginSuccess(true)) { $this->tpl_login = true; $this->tpl_user_point = $objCustomer->getValue('point'); $this->tpl_name = $objCustomer->getValue('name01'); } // 送料無料までの金額を計算 $tpl_deliv_free = $this->arrInfo['free_rule'] - $this->tpl_total_inctax; $this->tpl_deliv_free = $tpl_deliv_free; // 前頁のURLを取得 $this->tpl_prev_url = $objCartSess->getPrevURL(); } /** * デストラクタ. * * @return void */ function destroy() { parent::destroy(); } } ?>