/** * カート内の商品の妥当性をチェックする. * * エラーが発生した場合は, 商品をカート内から削除又は数量を調整し, * エラーメッセージを返す. * * 1. 商品種別に関連づけられた配送業者の存在チェック * 2. 削除/非表示商品のチェック * 3. 販売制限数のチェック * 4. 在庫数チェック * * @param string $productTypeId 商品種別ID * @return string エラーが発生した場合はエラーメッセージ */ public function checkProducts($productTypeId) { $objProduct = new SC_Product_Ex(); $objDelivery = new SC_Helper_Delivery_Ex(); $arrDeliv = $objDelivery->getList($productTypeId); $tpl_message = ''; // カート内の情報を取得 $arrItems = $this->getCartList($productTypeId); foreach ($arrItems as &$arrItem) { $product =& $arrItem['productsClass']; /* * 表示/非表示商品のチェック */ if (SC_Utils_Ex::isBlank($product) || $product['status'] != 1) { $this->delProduct($arrItem['cart_no'], $productTypeId); $tpl_message .= "※ 現時点で販売していない商品が含まれておりました。該当商品をカートから削除しました。\n"; } else { /* * 配送業者のチェック */ if (SC_Utils_Ex::isBlank($arrDeliv)) { $tpl_message .= '※「' . $product['name'] . '」はまだ配送の準備ができておりません。'; $tpl_message .= '恐れ入りますがお問い合わせページよりお問い合わせください。' . "\n"; $this->delProduct($arrItem['cart_no'], $productTypeId); } /* * 販売制限数, 在庫数のチェック */ $limit = $objProduct->getBuyLimit($product); if (!is_null($limit) && $arrItem['quantity'] > $limit) { if ($limit > 0) { $this->setProductValue($arrItem['id'], 'quantity', $limit, $productTypeId); $total_inctax = $limit * SC_Helper_TaxRule_Ex::sfCalcIncTax($arrItem['price'], $product['product_id'], $arrItem['id'][0]); $this->setProductValue($arrItem['id'], 'total_inctax', $total_inctax, $productTypeId); $tpl_message .= '※「' . $product['name'] . '」は販売制限(または在庫が不足)しております。'; $tpl_message .= "一度に数量{$limit}を超える購入はできません。\n"; } else { $this->delProduct($arrItem['cart_no'], $productTypeId); $tpl_message .= '※「' . $product['name'] . "」は売り切れました。\n"; continue; } } } } return $tpl_message; }
/** * Page のアクション. * * @return void */ public function action() { $objDeliv = new SC_Helper_Delivery_Ex(); $mode = $this->getMode(); if (!empty($_POST)) { $objFormParam = new SC_FormParam_Ex(); $objFormParam->setParam($_POST); $this->arrErr = $this->lfCheckError($mode, $objFormParam); if (!empty($this->arrErr['deliv_id'])) { trigger_error('', E_USER_ERROR); return; } } switch ($mode) { case 'delete': // ランク付きレコードの削除 $objDeliv->delete($_POST['deliv_id']); $this->objDisplay->reload(); // PRG pattern break; case 'up': $objDeliv->rankUp($_POST['deliv_id']); $this->objDisplay->reload(); // PRG pattern break; case 'down': $objDeliv->rankDown($_POST['deliv_id']); $this->objDisplay->reload(); // PRG pattern break; default: break; } $this->arrDelivList = $objDeliv->getList(); }
/** * Page のアクション. * * @return void */ public function action() { //決済処理中ステータスのロールバック $objPurchase = new SC_Helper_Purchase_Ex(); $objPurchase->cancelPendingOrder(PENDING_ORDER_CANCEL_FLAG); $objSiteSess = new SC_SiteSession_Ex(); $objCartSess = new SC_CartSession_Ex(); $objCustomer = new SC_Customer_Ex(); $objFormParam = new SC_FormParam_Ex(); $objDelivery = new SC_Helper_Delivery_Ex(); $this->is_multiple = $objPurchase->isMultiple(); // カートの情報を取得 $this->arrShipping = $objPurchase->getShippingTemp($this->is_multiple); $this->tpl_uniqid = $objSiteSess->getUniqId(); $cart_key = $objCartSess->getKey(); $this->cartKey = $cart_key; $objPurchase->verifyChangeCart($this->tpl_uniqid, $objCartSess); // 配送業者を取得 $this->arrDeliv = $objDelivery->getList($cart_key); $this->is_single_deliv = $this->isSingleDeliv($this->arrDeliv); $this->is_download = $this->cartKey == PRODUCT_TYPE_DOWNLOAD; // 会員情報の取得 if ($objCustomer->isLoginSuccess(true)) { $this->tpl_login = '******'; $this->tpl_user_point = $objCustomer->getValue('point'); $this->name01 = $objCustomer->getValue('name01'); $this->name02 = $objCustomer->getValue('name02'); } // 戻り URL の設定 // @deprecated 2.12.0 テンプレート直書きに戻した $this->tpl_back_url = '?mode=return'; $arrOrderTemp = $objPurchase->getOrderTemp($this->tpl_uniqid); // 正常に受注情報が格納されていない場合はカート画面へ戻す if (SC_Utils_Ex::isBlank($arrOrderTemp)) { SC_Response_Ex::sendRedirect(CART_URL); SC_Response_Ex::actionExit(); } // カート内商品の妥当性チェック $this->tpl_message = $objCartSess->checkProducts($cart_key); if (strlen($this->tpl_message) >= 1) { SC_Response_Ex::sendRedirect(CART_URL); SC_Response_Ex::actionExit(); } /* * 購入金額の取得 * ここでは送料を加算しない */ $this->arrPrices = $objCartSess->calculate($cart_key, $objCustomer); // お届け日一覧の取得 $this->arrDelivDate = $objPurchase->getDelivDate($objCartSess, $cart_key); switch ($this->getMode()) { /* * 配送業者選択時のアクション * モバイル端末以外の場合は, JSON 形式のデータを出力し, ajax で取得する. */ case 'select_deliv': $this->setFormParams($objFormParam, $arrOrderTemp, true, $this->arrShipping); $objFormParam->setParam($_POST); $this->arrErr = $objFormParam->checkError(); if (SC_Utils_Ex::isBlank($this->arrErr)) { $deliv_id = $objFormParam->getValue('deliv_id'); $arrSelectedDeliv = $this->getSelectedDeliv($objCartSess, $deliv_id); $arrSelectedDeliv['error'] = false; } else { $arrSelectedDeliv = array('error' => true); $this->tpl_mainpage = 'shopping/select_deliv.tpl'; // モバイル用 } if (SC_Display_Ex::detectDevice() != DEVICE_TYPE_MOBILE) { echo SC_Utils_Ex::jsonEncode($arrSelectedDeliv); SC_Response_Ex::actionExit(); } else { $this->arrPayment = $arrSelectedDeliv['arrPayment']; $this->arrDelivTime = $arrSelectedDeliv['arrDelivTime']; } break; // 登録処理 // 登録処理 case 'confirm': // パラメーター情報の初期化 $this->setFormParams($objFormParam, $_POST, $this->is_download, $this->arrShipping); $this->arrErr = $this->lfCheckError($objFormParam, $this->arrPrices['subtotal'], $this->tpl_user_point); $deliv_id = $objFormParam->getValue('deliv_id'); if (strval($deliv_id) !== strval(intval($deliv_id))) { $deliv_id = $this->arrDeliv[0]['deliv_id']; $objFormParam->setValue('deliv_id', $deliv_id); } $arrSelectedDeliv = $this->getSelectedDeliv($objCartSess, $deliv_id); $this->arrPayment = $arrSelectedDeliv['arrPayment']; $this->arrDelivTime = $arrSelectedDeliv['arrDelivTime']; $this->img_show = $arrSelectedDeliv['img_show']; if (empty($this->arrErr)) { $this->saveShippings($objFormParam, $this->arrDelivTime); $this->lfRegistData($this->tpl_uniqid, $objFormParam->getDbArray(), $objPurchase, $this->arrPayment); // 正常に登録されたことを記録しておく $objSiteSess->setRegistFlag(); // 確認ページへ移動 SC_Response_Ex::sendRedirect(SHOPPING_CONFIRM_URLPATH); SC_Response_Ex::actionExit(); } break; // 前のページに戻る // 前のページに戻る case 'return': // 正常な推移であることを記録しておく $objSiteSess->setRegistFlag(); $url = null; if ($this->is_multiple) { $url = MULTIPLE_URLPATH . '?from=multiple'; } elseif ($objCustomer->isLoginSuccess(true)) { if ($this->cartKey == PRODUCT_TYPE_DOWNLOAD) { $url = CART_URL; } else { $url = DELIV_URLPATH; } } else { $url = SHOPPING_URL . '?from=nonmember'; } SC_Response_Ex::sendRedirect($url); SC_Response_Ex::actionExit(); break; default: // FIXME 前のページから戻ってきた場合は別パラメーター(mode)で処理分岐する必要があるのかもしれない $this->setFormParams($objFormParam, $arrOrderTemp, $this->is_download, $this->arrShipping); if (!$this->is_single_deliv) { $deliv_id = $objFormParam->getValue('deliv_id'); } else { $deliv_id = $this->arrDeliv[0]['deliv_id']; } if (!SC_Utils_Ex::isBlank($deliv_id)) { $objFormParam->setValue('deliv_id', $deliv_id); $arrSelectedDeliv = $this->getSelectedDeliv($objCartSess, $deliv_id); $this->arrPayment = $arrSelectedDeliv['arrPayment']; $this->arrDelivTime = $arrSelectedDeliv['arrDelivTime']; $this->img_show = $arrSelectedDeliv['img_show']; } break; } // モバイル用 ポストバック処理 if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE && SC_Utils_Ex::isBlank($this->arrErr)) { $this->tpl_mainpage = $this->getMobileMainpage($this->is_single_deliv, $this->getMode()); } $this->arrForm = $objFormParam->getFormParamList(); }