/**
  * Page のアクション.
  *
  * @return void
  */
 function action()
 {
     // カートが空かどうかを確認する。
     $objCartSess = new SC_CartSession_Ex();
     $arrCartKeys = $objCartSess->getKeys();
     $this->tpl_cart_empty = true;
     foreach ($arrCartKeys as $cart_key) {
         if (count($objCartSess->getCartList($cart_key)) > 0) {
             $this->tpl_cart_empty = false;
             break;
         }
     }
     // メインテンプレートを設定
     if (CUSTOMER_CONFIRM_MAIL == true) {
         // 仮会員登録完了
         $this->tpl_mainpage = 'entry/complete.tpl';
     } else {
         // 本会員登録完了
         SC_Response_Ex::sendRedirectFromUrlPath('regist/complete.php');
     }
 }
Ejemplo n.º 2
0
 /**
  * Page のアクション.
  *
  * @return void
  */
 function action()
 {
     $objCartSess = new SC_CartSession_Ex();
     $objSiteSess = new SC_SiteSession_Ex();
     $objCustomer = new SC_Customer_Ex();
     $objFormParam = $this->lfInitParam($_POST);
     $this->mode = $this->getMode();
     // モバイル対応
     if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) {
         if (isset($_GET['cart_no'])) {
             $objFormParam->setValue('cart_no', $_GET['cart_no']);
         }
         if (isset($_GET['cartKey'])) {
             $objFormParam->setValue('cartKey', $_GET['cartKey']);
         }
     }
     $this->cartKeys = $objCartSess->getKeys();
     foreach ($this->cartKeys as $key) {
         // 商品購入中にカート内容が変更された。
         if ($objCartSess->getCancelPurchase($key)) {
             $this->tpl_message .= "商品購入中にカート内容が変更されましたので、お手数ですが購入手続きをやり直して下さい。\n";
         }
     }
     $cart_no = $objFormParam->getValue('cart_no');
     $cartKey = $objFormParam->getValue('cartKey');
     // エラーチェック
     $arrError = $objFormParam->checkError();
     if (isset($arrError) && !empty($arrError)) {
         SC_Utils_Ex::sfDispSiteError(CART_NOT_FOUND);
         SC_Response_Ex::actionExit();
     }
     switch ($this->mode) {
         case 'confirm':
             // カート内情報の取得
             $cartList = $objCartSess->getCartList($cartKey);
             // カート商品が1件以上存在する場合
             if (count($cartList) > 0) {
                 // カートを購入モードに設定
                 $this->lfSetCurrentCart($objSiteSess, $objCartSess, $cartKey);
                 // 購入ページへ
                 SC_Response_Ex::sendRedirect(SHOPPING_URL);
                 SC_Response_Ex::actionExit();
             }
             break;
         case 'up':
             //1個追加
             $objCartSess->upQuantity($cart_no, $cartKey);
             SC_Response_Ex::reload(array('category_id' => $objFormParam->getValue('category_id')), true);
             SC_Response_Ex::actionExit();
             break;
         case 'down':
             //1個減らす
             $objCartSess->downQuantity($cart_no, $cartKey);
             SC_Response_Ex::reload(array('category_id' => $objFormParam->getValue('category_id')), true);
             SC_Response_Ex::actionExit();
             break;
         case 'setQuantity':
             //数量変更
             $objCartSess->setQuantity($objFormParam->getValue('quantity'), $cart_no, $cartKey);
             SC_Response_Ex::reload(array('category_id' => $objFormParam->getValue('category_id')), true);
             SC_Response_Ex::actionExit();
             break;
         case 'delete':
             //カートから削除
             $objCartSess->delProduct($cart_no, $cartKey);
             SC_Response_Ex::reload(array('category_id' => $objFormParam->getValue('category_id')), true);
             SC_Response_Ex::actionExit();
             break;
         default:
             break;
     }
     $this->arrInfo = SC_Helper_DB_Ex::sfGetBasisData();
     $totalIncTax = 0;
     foreach ($this->cartKeys as $key) {
         // カート集計処理
         $this->tpl_message .= $objCartSess->checkProducts($key);
         $this->tpl_total_inctax[$key] = $objCartSess->getAllProductsTotal($key);
         $totalIncTax += $this->tpl_total_inctax[$key];
         $this->tpl_total_tax[$key] = $objCartSess->getAllProductsTax($key);
         // ポイント合計
         $this->tpl_total_point[$key] = $objCartSess->getAllProductsPoint($key);
         $this->arrData[$key] = $objCartSess->calculate($key, $objCustomer);
         // 送料無料チェック
         $this->arrData[$key]['is_deliv_free'] = $objCartSess->isDelivFree($key);
         // 送料無料までの金額を計算
         $this->tpl_deliv_free[$key] = $this->arrInfo['free_rule'] - $this->tpl_total_inctax[$key];
     }
     //商品の合計金額をセット
     $this->tpl_all_total_inctax = $totalIncTax;
     $this->tpl_category_id = $objFormParam->getValue('category_id');
     // ログイン判定
     if ($objCustomer->isLoginSuccess(true)) {
         $this->tpl_login = true;
         $this->tpl_user_point = $objCustomer->getValue('point');
         $this->tpl_name = $objCustomer->getValue('name01');
     }
     // 前頁のURLを取得
     // TODO: SC_CartSession::setPrevURL()利用不可。
     $this->lfGetCartPrevUrl($_SESSION, $_SERVER['HTTP_REFERER']);
     $this->tpl_prev_url = isset($_SESSION['cart_prev_url']) ? $_SESSION['cart_prev_url'] : '';
     // すべてのカートの内容を取得する
     $this->cartItems = $objCartSess->getAllCartList();
 }
 /**
  * 入力チェックを行う.
  *
  * @param  SC_FormParam $objFormParam SC_FormParam インスタンス
  * @return array        エラー情報の配列
  */
 public function lfCheckError(&$objFormParam)
 {
     $objCartSess = new SC_CartSession_Ex();
     $objFormParam->convParam();
     // 数量未入力は0に置換
     $objFormParam->setValue('quantity', $objFormParam->getValue('quantity', 0));
     $arrErr = $objFormParam->checkError();
     $arrParams = $objFormParam->getSwapArray();
     if (empty($arrErr)) {
         foreach ($arrParams as $index => $arrParam) {
             // 数量0で、お届け先を選択している場合
             if ($arrParam['quantity'] == 0 && !SC_Utils_Ex::isBlank($arrParam['shipping'])) {
                 $arrErr['shipping'][$index] = '※ 数量が0の場合、お届け先を入力できません。<br />';
             }
             // 数量の入力があり、お届け先を選択していない場合
             if ($arrParam['quantity'] > 0 && SC_Utils_Ex::isBlank($arrParam['shipping'])) {
                 $arrErr['shipping'][$index] = '※ お届け先が入力されていません。<br />';
             }
         }
     }
     // 入力エラーが無い場合、カゴの中身との数量の整合を確認
     if (empty($arrErr)) {
         $arrQuantity = array();
         // 入力内容を集計
         foreach ($arrParams as $arrParam) {
             $product_class_id = $arrParam['product_class_id'];
             $arrQuantity[$product_class_id] += $arrParam['quantity'];
         }
         // カゴの中身と突き合わせ
         $cartLists =& $objCartSess->getCartList($objCartSess->getKey());
         foreach ($cartLists as $arrCartRow) {
             $product_class_id = $arrCartRow['id'];
             // 差異がある場合、エラーを記録
             if ($arrCartRow['quantity'] != $arrQuantity[$product_class_id]) {
                 foreach ($arrParams as $index => $arrParam) {
                     if ($arrParam['product_class_id'] == $product_class_id) {
                         $arrErr['quantity'][$index] = '※ 数量合計を「' . $arrCartRow['quantity'] . '」にしてください。<br />';
                     }
                 }
             }
         }
     }
     return $arrErr;
 }
 /**
  * 入力チェックを行う.
  *
  * @param SC_FormParam $objFormParam SC_FormParam インスタンス
  * @return array エラー情報の配列
  */
 function lfCheckError(&$objFormParam)
 {
     $objCartSess = new SC_CartSession_Ex();
     $objFormParam->convParam();
     // 数量未入力は0に置換
     $objFormParam->setValue('quantity', $objFormParam->getValue('quantity', 0));
     $arrErr = $objFormParam->checkError();
     $arrParams = $objFormParam->getSwapArray();
     if (empty($arrErr)) {
         foreach ($arrParams as $index => $arrParam) {
             // 数量0で、お届け先を選択している場合
             if ($arrParam['quantity'] == 0 && !SC_Utils_Ex::isBlank($arrParam['shipping'])) {
                 $arrErr['shipping'][$index] = t('c_* When the quantity is 0, it is not possible to enter a shipping destination.<br />_01');
             }
             // 数量の入力があり、お届け先を選択していない場合
             if ($arrParam['quantity'] > 0 && SC_Utils_Ex::isBlank($arrParam['shipping'])) {
                 $arrErr['shipping'][$index] = t('c_* The shipping destination has not been entered.<br />_01');
             }
         }
     }
     // 入力エラーが無い場合、カゴの中身との数量の整合を確認
     if (empty($arrErr)) {
         $arrQuantity = array();
         // 入力内容を集計
         foreach ($arrParams as $arrParam) {
             $product_class_id = $arrParam['product_class_id'];
             $arrQuantity[$product_class_id] += $arrParam['quantity'];
         }
         // カゴの中身と突き合わせ
         $cartLists =& $objCartSess->getCartList($objCartSess->getKey());
         foreach ($cartLists as $arrCartRow) {
             $product_class_id = $arrCartRow['id'];
             // 差異がある場合、エラーを記録
             if ($arrCartRow['quantity'] != $arrQuantity[$product_class_id]) {
                 foreach ($arrParams as $index => $arrParam) {
                     if ($arrParam['product_class_id'] == $product_class_id) {
                         $arrErr['quantity'][$index] = t('c_* Use T_ARG1 for the total quantity.<br />_01', array('T_ARG1' => $arrCartRow['quantity']));
                     }
                 }
             }
         }
     }
     return $arrErr;
 }