/** * Page のアクション. * * @return void */ function action() { $objSiteSess = new SC_SiteSession_Ex(); $objCartSess = new SC_CartSession_Ex(); $objPurchase = new SC_Helper_Purchase_Ex(); $objCustomer = new SC_Customer_Ex(); $objFormParam = new SC_FormParam_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 = $objPurchase->getDeliv($cart_key); $this->is_single_deliv = $this->isSingleDeliv($this->arrDeliv); // 会員情報の取得 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_URLPATH); SC_Response_Ex::actionExit(); } // カート内商品の妥当性チェック $this->tpl_message = $objCartSess->checkProducts($cart_key); if (strlen($this->tpl_message) >= 1) { SC_Response_Ex::sendRedirect(CART_URLPATH); 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($objPurchase, $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, false, $this->arrShipping); $deliv_id = $objFormParam->getValue('deliv_id'); $arrSelectedDeliv = $this->getSelectedDeliv($objPurchase, $objCartSess, $deliv_id); $this->arrPayment = $arrSelectedDeliv['arrPayment']; $this->arrDelivTime = $arrSelectedDeliv['arrDelivTime']; $this->img_show = $arrSelectedDeliv['img_show']; $this->arrErr = $this->lfCheckError($objFormParam, $this->arrPrices['subtotal'], $this->tpl_user_point); 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 ($product_type_id == PRODUCT_TYPE_DOWNLOAD) { $url = CART_URLPATH; } 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, false, $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($objPurchase, $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(); }
/** * カート内の商品の妥当性をチェックする. * * エラーが発生した場合は, 商品をカート内から削除又は数量を調整し, * エラーメッセージを返す. * * 1. 商品種別に関連づけられた配送業者の存在チェック * 2. 削除/非表示商品のチェック * 3. 販売制限数のチェック * 4. 在庫数チェック * * @param string $productTypeId 商品種別ID * @return string エラーが発生した場合はエラーメッセージ */ function checkProducts($productTypeId) { $objProduct = new SC_Product_Ex(); $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 .= t('c_* A product in your cart is no longer being sold at this time. The item was deleted from your cart._01'); } else { /* * 配送業者のチェック */ $arrDeliv = SC_Helper_Purchase_Ex::getDeliv($productTypeId); if (SC_Utils_Ex::isBlank($arrDeliv)) { $tpl_message .= t('c_* Delivery preparations are not ready for T_ARG1. Please access the inquiry page for more details._01', array('T_ARG1' => $product['name'])); $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 = SC_Helper_DB_Ex::sfCalcIncTax($arrItem['price']) * $limit; $this->setProductValue($arrItem['id'], 'total_inctax', $total_inctax, $productTypeId); $tpl_message .= t('c_* There is a sale restriction (or inventory shortage) for T_ARG1. It is not possible to purchase a quantity that exceeds T_ARG2 in a single purchase._01', array('T_ARG1' => $product['name'], 'T_ARG2' => $limit)); } else { $this->delProduct($arrItem['cart_no'], $productTypeId); $tpl_message .= t('c_* T_ARG1 is sold out._01', array('T_ARG1' => $product['name'])); continue; } } } } return $tpl_message; }
/** * カート内の商品の妥当性をチェックする. * * エラーが発生した場合は, 商品をカート内から削除又は数量を調整し, * エラーメッセージを返す. * * 1. 商品種別に関連づけられた配送業者の存在チェック * 2. 削除/非表示商品のチェック * 3. 販売制限数のチェック * 4. 在庫数チェック * * @param string $productTypeId 商品種別ID * @return string エラーが発生した場合はエラーメッセージ */ function checkProducts($productTypeId) { $objProduct = new SC_Product_Ex(); $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 { /* * 配送業者のチェック */ $arrDeliv = SC_Helper_Purchase_Ex::getDeliv($productTypeId); 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 = SC_Helper_DB_Ex::sfCalcIncTax($arrItem['price']) * $limit; $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; }
/** * カート内の商品の妥当性をチェックする. * * エラーが発生した場合は, 商品をカート内から削除又は数量を調整し, * エラーメッセージを返す. * * 1. 商品種別に関連づけられた配送業者の存在チェック * 2. 削除/非表示商品のチェック * 3. 商品購入制限数のチェック * 4. 在庫数チェック * * @param string $key 商品種別ID * @return string エラーが発生した場合はエラーメッセージ */ function checkProducts($productTypeId) { $objProduct = new SC_Product_Ex(); $tpl_message = ""; // カート内の情報を取得 $items = $this->getCartList($productTypeId); foreach (array_keys($items) as $key) { $item =& $items[$key]; $product =& $item['productsClass']; /* * 表示/非表示商品のチェック */ if (SC_Utils_Ex::isBlank($product)) { $this->delProduct($item['cart_no'], $productTypeId); $tpl_message .= "※ 現時点で販売していない商品が含まれておりました。該当商品をカートから削除しました。\n"; } else { /* * 配送業者のチェック */ $arrDeliv = SC_Helper_Purchase_Ex::getDeliv($productTypeId); if (SC_Utils_Ex::isBlank($arrDeliv)) { $tpl_message .= "※「" . $product['name'] . "」はまだ配送の準備ができておりません。恐れ入りますがお問い合わせページよりお問い合わせください。\n"; $this->delProduct($item['cart_no'], $productTypeId); } /* * 商品購入制限数, 在庫数のチェック */ $limit = $objProduct->getBuyLimit($product); if (!is_null($limit) && $item['quantity'] > $limit) { if ($limit > 0) { $this->setProductValue($item['id'], 'quantity', $limit, $productTypeId); $this->setProductValue($item['id'], 'total_inctax', SC_Helper_DB_Ex::sfCalcIncTax($item['price']) * $limit, $productTypeId); $tpl_message .= "※「" . $product['name'] . "」は販売制限(または在庫が不足)しております。一度に数量{$limit}以上の購入はできません。\n"; } else { $this->delProduct($item['cart_no'], $productTypeId); $tpl_message .= "※「" . $product['name'] . "」は売り切れました。\n"; continue; } } } } return $tpl_message; }