/** * カートの情報を取得する * * @param SC_CartSession $objCart カートセッション管理クラス * @return array カートデータ配列 */ public function lfGetCartData(&$objCart) { $arrCartKeys = $objCart->getKeys(); foreach ($arrCartKeys as $cart_key) { // 購入金額合計 $products_total += $objCart->getAllProductsTotal($cart_key); // 合計数量 $total_quantity += $objCart->getTotalQuantity($cart_key); // 送料無料チェック if (!$this->isMultiple && !$this->hasDownload) { $is_deliv_free = $objCart->isDelivFree($cart_key); } } $arrCartList = array(); $arrCartList['ProductsTotal'] = $products_total; $arrCartList['TotalQuantity'] = $total_quantity; // 店舗情報の取得 $arrInfo = SC_Helper_DB_Ex::sfGetBasisData(); $arrCartList['free_rule'] = $arrInfo['free_rule']; // 送料無料までの金額 if ($is_deliv_free) { $arrCartList['deliv_free'] = 0; } else { $deliv_free = $arrInfo['free_rule'] - $products_total; $arrCartList['deliv_free'] = $deliv_free; } return $arrCartList; }
/** * Page のプロセス. * * @return void */ function process() { $objSubView = new SC_SiteView(); $objCart = new SC_CartSession(); $objSiteInfo = new SC_SiteInfo(); if (count($_SESSION[$objCart->key]) > 0) { // カート情報を取得 $arrCartList = $objCart->getCartList(); // カート内の商品ID一覧を取得 $arrAllProductID = $objCart->getAllProductID(); // 商品が1つ以上入っている場合には商品名称を取得 if (count($arrAllProductID) > 0) { $objQuery = new SC_Query(); $arrVal = array(); $sql = ""; $sql = "SELECT name FROM dtb_products WHERE product_id IN ( ?"; $arrVal = array($arrAllProductID[0]); for ($i = 1; $i < count($arrAllProductID); $i++) { $sql .= " ,? "; array_push($arrVal, $arrAllProductID[$i]); } $sql .= " )"; $arrProduct_name = $objQuery->getAll($sql, $arrVal); foreach ($arrProduct_name as $key => $val) { $arrCartList[$key]['product_name'] = $val['name']; } } // 店舗情報の取得 $arrInfo = $objSiteInfo->data; // 購入金額合計 $ProductsTotal = $objCart->getAllProductsTotal($arrInfo); // 合計個数 $TotalQuantity = $objCart->getTotalQuantity(); // 送料無料までの金額 $arrCartList[0]['ProductsTotal'] = $ProductsTotal; $arrCartList[0]['TotalQuantity'] = $TotalQuantity; $deliv_free = $arrInfo['free_rule'] - $ProductsTotal; $arrCartList[0]['free_rule'] = $arrInfo['free_rule']; $arrCartList[0]['deliv_free'] = $deliv_free; $this->arrCartList = $arrCartList; } $objSubView->assignobj($this); $objSubView->display($this->tpl_mainpage); }
/** * Page のプロセス(モバイル). * * @return void */ function mobileProcess() { $objCustomer = new SC_Customer(); $objCartSess = new SC_CartSession(); //受注詳細データの取得 $arrDisp = $this->lfGetOrderDetail($_POST['order_id']); //ログインしていない、またはDBに情報が無い場合 if (!$objCustomer->isLoginSuccess(true) or count($arrDisp) == 0) { SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR, "", false, "", true); } for ($num = 0; $num < count($arrDisp); $num++) { $product_id = $arrDisp[$num]['product_id']; $cate_id1 = $arrDisp[$num]['classcategory_id1']; $cate_id2 = $arrDisp[$num]['classcategory_id2']; $quantity = $arrDisp[$num]['quantity']; $objCartSess->addProduct(array($product_id, $cate_id1, $cate_id2), $quantity); } $this->sendRedirect($this->getLocation(MOBILE_URL_CART_TOP), true); }
/** * カートの情報を取得する * * @param SC_CartSession $objCart カートセッション管理クラス * @param Array $arrInfo 基本情報配列 * @param Array $cartKeys 商品種類配列 * @return array $arrCartList カートデータ配列 */ public function lfGetCartData($objCart, $arrInfo, $cartKeys) { $cartList = array(); foreach ($cartKeys as $key) { // カート集計処理 $cartList[$key]['productTypeName'] = $this->arrProductType[$key]; //商品種類名 $cartList[$key]['totalInctax'] = $objCart->getAllProductsTotal($key); //合計金額 $cartList[$key]['delivFree'] = $arrInfo['free_rule'] - $cartList[$key]['totalInctax']; // 送料無料までの金額を計算 $cartList[$key]['totalTax'] = $objCart->getAllProductsTax($key); //消費税合計 $cartList[$key]['quantity'] = $objCart->getTotalQuantity($key); //商品数量合計 $cartList[$key]['productTypeId'] = $key; // 商品種別ID } return $cartList; }
public function testCleanupSession__カートとセッションの配送情報が削除される() { // 引数の準備 $helper = new SC_Helper_Purchase(); $cartSession = new SC_CartSession(); $customer = new SC_Customer(); // 削除前のデータを設定 $cartSession->addProduct('1001', 5); // product_type_id=1 $cartSession->addProduct('1002', 10); // product_type_id=2 $_SESSION['site']['uniqid'] = '100001'; $helper->cleanupSession('1001', $cartSession, $customer, '1'); $this->expected = array('cart_max_deleted' => 0, 'cart_max_notdeleted' => 1, 'uniqid' => '', 'shipping' => null, 'multiple_temp' => null); $this->actual['cart_max_deleted'] = $cartSession->getMax('1'); $this->actual['cart_max_notdeleted'] = $cartSession->getMax('2'); $this->actual['uniqid'] = $_SESSION['site']['uniqid']; $this->actual['shipping'] = $_SESSION['shipping']; $this->actual['multiple_temp'] = $_SESSION['multiple_temp']; $this->verify(); }
/** * カートの情報を取得する * * @param SC_CartSession $objCart カートセッション管理クラス * @return array $arrCartList カートデータ配列 */ function lfGetCartData(&$objCart) { $arrCartKeys = $objCart->getKeys(); foreach ($arrCartKeys as $cart_key) { // カート情報を取得 $arrCartList = $objCart->getCartList($cart_key); // カート内の商品ID一覧を取得 $arrAllProductID = $objCart->getAllProductID($cart_key); // 商品が1つ以上入っている場合には商品名称を取得 if (!SC_Utils_Ex::isBlank($arrCartList['productsClass'])) { foreach ($arrCartList['productsClass'] as $key => $val) { $arrCartList[$key]['product_name'] = $val['name']; } } // 購入金額合計 $products_total += $objCart->getAllProductsTotal($cart_key); // 合計数量 $total_quantity += $objCart->getTotalQuantity($cart_key); // 送料無料チェック if (!$this->isMultiple && !$this->hasDownload) { $is_deliv_free = $objCart->isDelivFree($cart_key); } } $arrCartList[0]['ProductsTotal'] = $products_total; $arrCartList[0]['TotalQuantity'] = $total_quantity; // 店舗情報の取得 $arrInfo = SC_Helper_DB_Ex::sfGetBasisData(); $arrCartList[0]['free_rule'] = $arrInfo['free_rule']; // 送料無料までの金額 if ($is_deliv_free) { $arrCartList[0]['deliv_free'] = 0; } else { $deliv_free = $arrInfo['free_rule'] - $products_total; $arrCartList[0]['deliv_free'] = $deliv_free; } return $arrCartList; }
/** * Page のプロセス(モバイル). * * FIXME 要リファクタリング * * @return void */ function mobileProcess() { $objView = new SC_MobileView(); $objCustomer = new SC_Customer(); $objQuery = new SC_Query(); $objDb = new SC_Helper_DB_Ex(); // パラメータ管理クラス $this->objFormParam = new SC_FormParam(); // パラメータ情報の初期化 $this->lfInitParam(); // POST値の取得 $this->objFormParam->setParam($_POST); // ファイル管理クラス $this->objUpFile = new SC_UploadFile(IMAGE_TEMP_DIR, IMAGE_SAVE_DIR); // ファイル情報の初期化 $this->lfInitFile(); if (!isset($_POST['mode'])) { $_POST['mode'] = ""; } if (!empty($_POST['mode'])) { $tmp_id = $_POST['product_id']; } else { $tmp_id = $_GET['product_id']; } // 値の正当性チェック if (!SC_Utils_Ex::sfIsInt($tmp_id) || !$objDb->sfIsRecord("dtb_products", "product_id", $tmp_id, 'del_flg = 0 AND status = 1')) { SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND); } // ログイン判定 if ($objCustomer->isLoginSuccess(true)) { //お気に入りボタン表示 $this->tpl_login = true; /* 閲覧ログ機能は現在未使用 $table = "dtb_customer_reading"; $where = "customer_id = ? "; $arrval[] = $objCustomer->getValue('customer_id'); //顧客の閲覧商品数 $rpcnt = $objQuery->count($table, $where, $arrval); //閲覧数が設定数以下 if ($rpcnt < CUSTOMER_READING_MAX){ //閲覧履歴に新規追加 lfRegistReadingData($tmp_id, $objCustomer->getValue('customer_id')); } else { //閲覧履歴の中で一番古いものを削除して新規追加 $oldsql = "SELECT MIN(update_date) FROM ".$table." WHERE customer_id = ?"; $old = $objQuery->getone($oldsql, array($objCustomer->getValue("customer_id"))); $where = "customer_id = ? AND update_date = ? "; $arrval = array($objCustomer->getValue("customer_id"), $old); //削除 $objQuery->delete($table, $where, $arrval); //追加 lfRegistReadingData($tmp_id, $objCustomer->getValue('customer_id')); } */ } // 規格選択セレクトボックスの作成 $this->lfMakeSelectMobile($this, $tmp_id); // 商品IDをFORM内に保持する。 $this->tpl_product_id = $tmp_id; switch ($_POST['mode']) { case 'select': // 規格1が設定されている場合 if ($this->tpl_classcat_find1) { // templateの変更 $this->tpl_mainpage = "products/select_find1.tpl"; break; } case 'select2': $this->arrErr = $this->lfCheckError(); // 規格1が設定されている場合 if ($this->tpl_classcat_find1 and $this->arrErr['classcategory_id1']) { // templateの変更 $this->tpl_mainpage = "products/select_find1.tpl"; break; } // 規格2が設定されている場合 if ($this->tpl_classcat_find2) { $this->arrErr = array(); $this->tpl_mainpage = "products/select_find2.tpl"; break; } case 'selectItem': $this->arrErr = $this->lfCheckError(); // 規格1が設定されている場合 if ($this->tpl_classcat_find2 and $this->arrErr['classcategory_id2']) { // templateの変更 $this->tpl_mainpage = "products/select_find2.tpl"; break; } // 商品数の選択を行う $this->tpl_mainpage = "products/select_item.tpl"; break; case 'cart': // 入力値の変換 $this->objFormParam->convParam(); $this->arrErr = $this->lfCheckError(); if (count($this->arrErr) == 0) { $objCartSess = new SC_CartSession(); $classcategory_id1 = $_POST['classcategory_id1']; $classcategory_id2 = $_POST['classcategory_id2']; // 規格1が設定されていない場合 if (!$this->tpl_classcat_find1) { $classcategory_id1 = '0'; } // 規格2が設定されていない場合 if (!$this->tpl_classcat_find2) { $classcategory_id2 = '0'; } $objCartSess->setPrevURL($_SERVER['REQUEST_URI']); $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $this->objFormParam->getValue('quantity')); $this->sendRedirect($this->getLocation(MOBILE_URL_CART_TOP), true); exit; } break; default: break; } $objQuery = new SC_Query(); // DBから商品情報を取得する。 $arrRet = $objQuery->select("*", "vw_products_allclass_detail AS alldtl", "product_id = ?", array($tmp_id)); $this->arrProduct = $arrRet[0]; // 商品コードの取得 $code_sql = "SELECT product_code FROM dtb_products_class AS prdcls WHERE prdcls.product_id = ? GROUP BY product_code ORDER BY product_code"; $arrProductCode = $objQuery->getall($code_sql, array($tmp_id)); $arrProductCode = SC_Utils_Ex::sfswaparray($arrProductCode); $this->arrProductCode = $arrProductCode["product_code"]; // 購入制限数を取得 if ($this->arrProduct['sale_unlimited'] == 1 || $this->arrProduct['sale_limit'] > SALE_LIMIT_MAX) { $this->tpl_sale_limit = SALE_LIMIT_MAX; } else { $this->tpl_sale_limit = $this->arrProduct['sale_limit']; } // サブタイトルを取得 $arrFirstCat = $objDb->sfGetFirstCat($arrRet[0]['category_id']); $tpl_subtitle = $arrFirstCat['name']; $this->tpl_subtitle = $tpl_subtitle; // DBからのデータを引き継ぐ $this->objUpFile->setDBFileList($this->arrProduct); // ファイル表示用配列を渡す $this->arrFile = $this->objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL, true); // 支払方法の取得 $this->arrPayment = $this->lfGetPayment(); // 入力情報を渡す $this->arrForm = $this->objFormParam->getFormParamList(); //レビュー情報の取得 $this->arrReview = $this->lfGetReviewData($tmp_id); // タイトルに商品名を入れる $this->tpl_title = "商品詳細 " . $this->arrProduct["name"]; //オススメ商品情報表示 $this->arrRecommend = $this->lfPreGetRecommendProducts($tmp_id); //この商品を買った人はこんな商品も買っています $this->arrRelateProducts = $this->lfGetRelateProducts($tmp_id); $objView->assignobj($this); $objView->display(SITE_FRAME); }
/** * 配送業者IDから, 支払い方法, お届け時間の配列を取得する. * * 結果の連想配列の添字の値は以下の通り * - 'arrDelivTime' - お届け時間の配列 * - 'arrPayment' - 支払い方法の配列 * - 'img_show' - 支払い方法の画像の有無 * * @param SC_CartSession $objCartSess SC_CartSession インスタンス * @param integer $deliv_id 配送業者ID * @return array 支払い方法, お届け時間を格納した配列 */ public function getSelectedDeliv(&$objCartSess, $deliv_id) { $arrResults = array(); if (strval($deliv_id) === strval(intval($deliv_id))) { $arrResults['arrDelivTime'] = SC_Helper_Delivery_Ex::getDelivTime($deliv_id); $total = $objCartSess->getAllProductsTotal($objCartSess->getKey()); $payments_deliv = SC_Helper_Delivery_Ex::getPayments($deliv_id); $objPayment = new SC_Helper_Payment_Ex(); $payments_total = $objPayment->getByPrice($total); $arrPayment = array(); foreach ($payments_total as $payment) { if (in_array($payment['payment_id'], $payments_deliv)) { $arrPayment[] = $payment; } } $arrResults['arrPayment'] = $arrPayment; $arrResults['img_show'] = $this->hasPaymentImage($arrResults['arrPayment']); } return $arrResults; }
/** * 単一配送指定用に配送商品を設定する * * @param SC_CartSession $objCartSession カート情報のインスタンス * @param integer $shipping_id 配送先ID * @return void */ public function setShipmentItemTempForSole(&$objCartSession, $shipping_id = 0) { $objCartSess = new SC_CartSession_Ex(); $this->clearShipmentItemTemp(); $arrCartList =& $objCartSession->getCartList($objCartSess->getKey()); foreach ($arrCartList as $arrCartRow) { if ($arrCartRow['quantity'] == 0) { continue; } $this->setShipmentItemTemp($shipping_id, $arrCartRow['id'], $arrCartRow['quantity']); } }
/** * Page のプロセス. * * @return void */ function process() { global $objCampaignSess; $objView = new SC_SiteView(false); $objQuery = new SC_Query(); $objCampaignSess = new SC_CampaignSession(); // ディレクトリ名を取得 $dir_name = dirname($_SERVER['PHP_SELF']); $arrDir = split('/', $dir_name); $dir_name = $arrDir[count($arrDir) - 1]; /* セッションにキャンペーンデータを書き込む */ // キャンペーンからの遷移という情報を保持 $objCampaignSess->setIsCampaign(); // キャンペーンIDを保持 $campaign_id = $objQuery->get("dtb_campaign", "campaign_id", "directory_name = ? AND del_flg = 0", array($dir_name)); $objCampaignSess->setCampaignId($campaign_id); // キャンペーンディレクトリ名を保持 $objCampaignSess->setCampaignDir($dir_name); // カートに入れないページの場合のページ(申込のみページ)へリダイレクト $cart_flg = $objQuery->get("dtb_campaign", "cart_flg", "campaign_id = ?", array($campaign_id)); if (!$cart_flg) { $this->sendRedirect($this->getLocation(CAMPAIGN_URL . "{$dir_name}/application.php")); exit; } // キャンペーンが開催中かをチェック if ($this->lfCheckActive($dir_name, $objQuery)) { $status = CAMPAIGN_TEMPLATE_ACTIVE; } else { $status = CAMPAIGN_TEMPLATE_END; } if ($_GET['init'] != "") { $this->tpl_init = 'false'; $this->lfDispProductsList($_GET['ids'], $objQuery); } else { $this->tpl_init = 'true'; } switch ($_POST['mode']) { case 'cart': $this->arrErr = $this->lfCheckError($_POST['product_id']); if (count($this->arrErr) == 0) { $objCartSess = new SC_CartSession(); $classcategory_id = "classcategory_id" . $_POST['product_id']; $classcategory_id1 = $_POST[$classcategory_id . '_1']; $classcategory_id2 = $_POST[$classcategory_id . '_2']; $quantity = "quantity" . $_POST['product_id']; // 規格1が設定されていない場合 if (!$this->tpl_classcat_find1[$_POST['product_id']]) { $classcategory_id1 = '0'; } // 規格2が設定されていない場合 if (!$this->tpl_classcat_find2[$_POST['product_id']]) { $classcategory_id2 = '0'; } $objCartSess->setPrevURL($_SERVER['REQUEST_URI']); $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $_POST[$quantity], $campaign_id); $this->sendRedirect($this->getLocation(URL_CART_TOP)); exit; } break; default: break; } // 入力情報を渡す $this->arrForm = $_POST; $this->tpl_dir_name = CAMPAIGN_TEMPLATE_PATH . $dir_name . "/" . $status; //---- ページ表示 $objView->assignobj($this); $objView->display($this->tpl_mainpage); }
/** * 配送業者IDから, 支払い方法, お届け時間の配列を取得する. * * 結果の連想配列の添字の値は以下の通り * - 'arrDelivTime' - お届け時間の配列 * - 'arrPayment' - 支払い方法の配列 * - 'img_show' - 支払い方法の画像の有無 * * @param SC_CartSession $objCartSess SC_CartSession インスタンス * @param integer $deliv_id 配送業者ID * @return array 支払い方法, お届け時間を格納した配列 */ public function getSelectablePayment(&$objCartSess, $deliv_id, $is_list = false) { $arrPayment = array(); if (strval($deliv_id) === strval(intval($deliv_id))) { $total = $objCartSess->getAllProductsTotal($objCartSess->getKey()); $payments_deliv = DeliveryHelper::getPayments($deliv_id); $objPayment = new PaymentHelper(); $payments_total = $objPayment->getByPrice($total); foreach ($payments_total as $payment) { if (in_array($payment['payment_id'], $payments_deliv)) { if ($is_list) { $arrPayment[$payment['payment_id']] = $payment['payment_method']; } else { $arrPayment[] = $payment; } } } } return $arrPayment; }
/** * セッションに保持している情報を破棄する. * * 通常、受注処理(completeOrder)完了後に呼び出され、 * セッション情報を破棄する. * * 決済モジュール画面から確認画面に「戻る」場合を考慮し、 * セッション情報を破棄しないカスタマイズを、モジュール側で * 加える機会を与える. * * @param integer $orderId 注文番号 * @param SC_CartSession $objCartSession カート情報のインスタンス * @param SC_Customer $objCustomer SC_Customer インスタンス * @param integer $cartKey 登録を行うカート情報のキー */ function cleanupSession($orderId, &$objCartSession, &$objCustomer, $cartKey) { // カートの内容を削除する. $objCartSession->delAllProducts($cartKey); SC_SiteSession_Ex::unsetUniqId(); // セッションの配送情報を破棄する. $this->unsetShippingTemp(); $objCustomer->updateSession(); }
* modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ require_once "../require.php"; $objSiteSess = new SC_SiteSession(); $objCartSess = new SC_CartSession(); $objQuery = new SC_Query(); // 前のページで正しく登録手続きが行われた記録があるか判定 SC_Utils::sfIsPrePage($objSiteSess); // SPSモジュール連携用 if (file_exists(MODULE_PATH . 'mdl_sps/inc/include.php') && !$objCartSess->getTotalQuantity()) { require_once MODULE_PATH . 'mdl_sps/inc/include.php'; header("Location: " . ERROR_URL); exit; } // アクセスの正当性の判定 $uniqid = SC_Utils::sfCheckNormalAccess($objSiteSess, $objCartSess); $payment_id = $_SESSION["payment_id"]; // 支払いIDが無い場合にはエラー if ($payment_id == "") { SC_Utils::sfDispSiteError(PAGE_ERROR, "", true);
function SC_SiteView($cart = true) { parent::SC_View(); $this->_smarty->template_dir = TEMPLATE_DIR; $this->_smarty->compile_dir = COMPILE_DIR; $this->initpath(); // PHP5ではsessionをスタートする前にヘッダー情報を送信していると警告が出るため、先にセッションをスタートするように変更 SC_Utils_Ex::sfDomainSessionStart(); if ($cart) { $include_dir = realpath(dirname(__FILE__)); require_once $include_dir . "/SC_CartSession.php"; $objCartSess = new SC_CartSession(); $objCartSess->setPrevURL($_SERVER['REQUEST_URI']); } }
function lfGetDelivDate() { $objCartSess = new SC_CartSession(); $objQuery = new SC_Query(); // 商品IDの取得 $max = $objCartSess->getMax(); for ($i = 1; $i <= $max; $i++) { if ($_SESSION[$objCartSess->key][$i]['id'][0] != "") { $arrID['product_id'][$i] = $_SESSION[$objCartSess->key][$i]['id'][0]; } } if (count($arrID['product_id']) > 0) { $id = implode(",", $arrID['product_id']); //商品から発送目安の取得 $deliv_date = $objQuery->get("dtb_products", "MAX(deliv_date_id)", "product_id IN (" . $id . ")"); //発送目安 switch ($deliv_date) { //即日発送 case '1': $start_day = 1; break; //1-2日後 //1-2日後 case '2': $start_day = 3; break; //3-4日後 //3-4日後 case '3': $start_day = 5; break; //1週間以内 //1週間以内 case '4': $start_day = 8; break; //2週間以内 //2週間以内 case '5': $start_day = 15; break; //3週間以内 //3週間以内 case '6': $start_day = 22; break; //1ヶ月以内 //1ヶ月以内 case '7': $start_day = 32; break; //2ヶ月以降 //2ヶ月以降 case '8': $start_day = 62; break; //お取り寄せ(商品入荷後) //お取り寄せ(商品入荷後) case '9': $start_day = ""; break; default: //お届け日が設定されていない場合 $start_day = ""; break; } //配達可能日のスタート値から、配達日の配列を取得する $arrDelivDate = $this->lfGetDateArray($start_day, DELIV_DATE_END_MAX); } return $arrDelivDate; }
/** * カートの商品を数量ごとに分割し, フォームに設定する. * * @param SC_FormParam $objFormParam SC_FormParam インスタンス * @param SC_CartSession $objCartSess SC_CartSession インスタンス * @return void */ public function setParamToSplitItems(&$objFormParam, &$objCartSess) { $cartLists =& $objCartSess->getCartList($objCartSess->getKey()); $arrItems = array(); $index = 0; foreach (array_keys($cartLists) as $key) { $arrProductsClass = $cartLists[$key]['productsClass']; $quantity = (int) $cartLists[$key]['quantity']; for ($i = 0; $i < $quantity; $i++) { foreach ($arrProductsClass as $key2 => $val) { $arrItems[$key2][$index] = $val; } $arrItems['quantity'][$index] = 1; $arrItems['price'][$index] = $cartLists[$key]['price']; $arrItems['price_inctax'][$index] = $cartLists[$key]['price_inctax']; $index++; } } $objFormParam->setParam($arrItems); $objFormParam->setValue('line_of_num', $index); }
/** * Page のプロセス(モバイル). * * @return void */ function mobileProcess() { // 買い物を続ける場合 if (!isset($_REQUEST['continue'])) { $_REQUEST['continue'] = ""; } if ($_REQUEST['continue']) { $this->sendRedirect($this->getLocation(MOBILE_URL_SITE_TOP), true); exit; } $objView = new SC_MobileView(false); $objCartSess = new SC_CartSession("", false); $objSiteSess = new SC_SiteSession(); $objSiteInfo = $objView->objSiteInfo; $objCustomer = new SC_Customer(); $objDb = new SC_Helper_DB_Ex(); // 基本情報の取得 $arrInfo = $objSiteInfo->data; // 商品購入中にカート内容が変更された。 if ($objCartSess->getCancelPurchase()) { $this->tpl_message = "商品購入中にカート内容が変更されましたので、お手数ですが購入手続きをやり直して下さい。"; } if (!isset($_POST['mode'])) { $_POST['mode'] = ""; } 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->sendRedirect(MOBILE_URL_SHOP_TOP, true); 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, $arrInfo); $this->arrData = $objDb->sfTotalConfirm($arrData, $this, $objCartSess, $arrInfo, $objCustomer); $this->arrInfo = $arrInfo; // ログイン判定 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_pretax; $this->tpl_deliv_free = $tpl_deliv_free; // 前頁のURLを取得 $this->tpl_prev_url = $objCartSess->getPrevURL(); $objView->assignobj($this); $objView->display(SITE_FRAME); }
/** * Page のプロセス(モバイル). * * @return void */ function mobileProcess() { $objView = new SC_MobileView(); // カートが空かどうかを確認する。 $objCartSess = new SC_CartSession("", false); $this->tpl_cart_empty = count($objCartSess->getCartList()) < 1; $objView->assignobj($this); $objView->display(SITE_FRAME); }
/** * 集計情報を元に最終計算を行う. * * @param array $arrData 各種情報 * @param LC_Page $objPage LC_Page インスタンス * @param SC_CartSession $objCartSess SC_CartSession インスタンス * @param array $arrInfo 店舗情報の配列 * @param SC_Customer $objCustomer SC_Customer インスタンス * @return array 最終計算後の配列 */ function sfTotalConfirm($arrData, &$objPage, &$objCartSess, $arrInfo, $objCustomer = "") { // 未定義変数を定義 if (!isset($arrData['deliv_pref'])) { $arrData['deliv_pref'] = ""; } if (!isset($arrData['payment_id'])) { $arrData['payment_id'] = ""; } if (!isset($arrData['charge'])) { $arrData['charge'] = ""; } if (!isset($arrData['use_point'])) { $arrData['use_point'] = ""; } // 商品の合計個数 $total_quantity = $objCartSess->getTotalQuantity(true); // 税金の取得 $arrData['tax'] = $objPage->tpl_total_tax; // 小計の取得 $arrData['subtotal'] = $objPage->tpl_total_pretax; // 合計送料の取得 $arrData['deliv_fee'] = 0; // 商品ごとの送料が有効の場合 if (OPTION_PRODUCT_DELIV_FEE == 1) { $arrData['deliv_fee'] += $objCartSess->getAllProductsDelivFee(); } // 配送業者の送料が有効の場合 if (OPTION_DELIV_FEE == 1) { // 送料の合計を計算する $arrData['deliv_fee'] += $this->sfGetDelivFee($arrData); } // 送料無料の購入数が設定されている場合 if (DELIV_FREE_AMOUNT > 0) { if ($total_quantity >= DELIV_FREE_AMOUNT) { $arrData['deliv_fee'] = 0; } } // 送料無料条件が設定されている場合 if ($arrInfo['free_rule'] > 0) { // 小計が無料条件を超えている場合 if ($arrData['subtotal'] >= $arrInfo['free_rule']) { $arrData['deliv_fee'] = 0; } } // 合計の計算 $arrData['total'] = $objPage->tpl_total_pretax; // 商品合計 $arrData['total'] += $arrData['deliv_fee']; // 送料 $arrData['total'] += $arrData['charge']; // 手数料 // お支払い合計 $arrData['payment_total'] = $arrData['total'] - $arrData['use_point'] * POINT_VALUE; // 加算ポイントの計算 if (USE_POINT === false) { $arrData['add_point'] = 0; } else { $arrData['add_point'] = SC_Utils::sfGetAddPoint($objPage->tpl_total_point, $arrData['use_point'], $arrInfo); if ($objCustomer != "") { // 誕生日月であった場合 if ($objCustomer->isBirthMonth()) { $arrData['birth_point'] = BIRTH_MONTH_POINT; $arrData['add_point'] += $arrData['birth_point']; } } } if ($arrData['add_point'] < 0) { $arrData['add_point'] = 0; } return $arrData; }
/** * 配送業者IDから, 支払い方法, お届け時間の配列を取得する. * * 結果の連想配列の添字の値は以下の通り * - 'arrDelivTime' - お届け時間の配列 * - 'arrPayment' - 支払い方法の配列 * - 'img_show' - 支払い方法の画像の有無 * * @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス * @param SC_CartSession $objCartSess SC_CartSession インスタンス * @param integer $deliv_id 配送業者ID * @return array 支払い方法, お届け時間を格納した配列 */ function getSelectedDeliv(&$objPurchase, &$objCartSess, $deliv_id) { $arrResults = array(); $arrResults['arrDelivTime'] = $objPurchase->getDelivTime($deliv_id); $total = $objCartSess->getAllProductsTotal($objCartSess->getKey(), $deliv_id); $arrResults['arrPayment'] = $objPurchase->getPaymentsByPrice($total, $deliv_id); $arrResults['img_show'] = $this->hasPaymentImage($arrResults['arrPayment']); return $arrResults; }
/** * Page のプロセス(モバイル). * * FIXME スパゲッティ... * * @return void */ function mobileProcess() { $objView = new SC_MobileView(); $conn = new SC_DBConn(); $objDb = new SC_Helper_DB_Ex(); //表示件数の選択 if (isset($_REQUEST['disp_number']) && SC_Utils_Ex::sfIsInt($_REQUEST['disp_number'])) { $this->disp_number = $_REQUEST['disp_number']; } else { //最小表示件数を選択 $this->disp_number = current(array_keys($this->arrPRODUCTLISTMAX)); } //表示順序の保存 $this->orderby = isset($_REQUEST['orderby']) ? $_REQUEST['orderby'] : ""; // GETのカテゴリIDを元に正しいカテゴリIDを取得する。 $arrCategory_id = $objDb->sfGetCategoryId("", $_GET['category_id']); // タイトル編集 $tpl_subtitle = ""; $tpl_search_mode = false; if (!isset($_GET['mode'])) { $_GET['mode'] = ""; } if (!isset($_POST['mode'])) { $_POST['mode'] = ""; } if (!isset($_GET['name'])) { $_GET['name'] = ""; } if (!isset($_REQUEST['orderby'])) { $_REQUEST['orderby'] = ""; } if (empty($arrCategory_id)) { $arrCategory_id = array("0"); } if ($_GET['mode'] == 'search') { $tpl_subtitle = "検索結果"; $tpl_search_mode = true; } elseif (empty($arrCategory_id)) { $tpl_subtitle = "全商品"; } else { $arrFirstCat = $objDb->sfGetFirstCat($arrCategory_id[0]); $tpl_subtitle = $arrFirstCat['name']; } $objQuery = new SC_Query(); $count = $objQuery->count("dtb_best_products", "category_id = ?", $arrCategory_id); // 以下の条件でBEST商品を表示する // ・BEST最大数の商品が登録されている。 // ・カテゴリIDがルートIDである。 // ・検索モードでない。 if ($count >= BEST_MIN && $this->lfIsRootCategory($arrCategory_id[0]) && $_GET['mode'] != 'search') { // 商品TOPの表示処理 $this->arrBestItems = SC_Utils_Ex::sfGetBestProducts($conn, $arrCategory_id[0]); $this->BEST_ROOP_MAX = ceil((BEST_MAX - 1) / 2); } else { if ($_GET['mode'] == 'search' && strlen($_GET['category_id']) == 0) { // 検索時にcategory_idがGETに存在しない場合は、仮に埋めたIDを空白に戻す $arrCategory_id = array(""); } // 商品一覧の表示処理 $this->lfDispProductsList($arrCategory_id[0], $_GET['name'], $this->disp_number, $_REQUEST['orderby']); // 検索条件を画面に表示 // カテゴリー検索条件 if (strlen($_GET['category_id']) == 0) { $arrSearch['category'] = "指定なし"; } else { $arrCat = $conn->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?", array($category_id)); $arrSearch['category'] = $arrCat; } // 商品名検索条件 if ($_GET['name'] === "") { $arrSearch['name'] = "指定なし"; } else { $arrSearch['name'] = $_GET['name']; } } if ($_POST['mode'] == "cart" && $_POST['product_id'] != "") { // 値の正当性チェック if (!SC_Utils_Ex::sfIsInt($_POST['product_id']) || !SC_Utils_Ex::sfIsRecord("dtb_products", "product_id", $_POST['product_id'], "del_flg = 0 AND status = 1")) { SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND, "", false, "", true); } else { // 入力値の変換 $this->arrErr = $this->lfCheckError($_POST['product_id']); if (count($this->arrErr) == 0) { $objCartSess = new SC_CartSession(); $classcategory_id = "classcategory_id" . $_POST['product_id']; $classcategory_id1 = $_POST[$classcategory_id . '_1']; $classcategory_id2 = $_POST[$classcategory_id . '_2']; $quantity = "quantity" . $_POST['product_id']; // 規格1が設定されていない場合 if (!$this->tpl_classcat_find1[$_POST['product_id']]) { $classcategory_id1 = '0'; } // 規格2が設定されていない場合 if (!$this->tpl_classcat_find2[$_POST['product_id']]) { $classcategory_id2 = '0'; } $objCartSess->setPrevURL($_SERVER['REQUEST_URI']); $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $_POST[$quantity]); $this->sendRedirect(MOBILE_URL_CART_TOP, array(session_name() => session_id())); exit; } } } // ページ送り機能用のURLを作成する。 $objURL = new Net_URL($_SERVER['PHP_SELF']); foreach ($_REQUEST as $key => $value) { if ($key == session_name() || $key == 'pageno') { continue; } $objURL->addQueryString($key, mb_convert_encoding($value, 'SJIS', CHAR_CODE)); } if ($this->objNavi->now_page > 1) { $objURL->addQueryString('pageno', $this->objNavi->now_page - 1); $this->tpl_previous_page = $objURL->path . '?' . $objURL->getQueryString(); } if ($this->objNavi->now_page < $this->objNavi->max_page) { $objURL->addQueryString('pageno', $this->objNavi->now_page + 1); $this->tpl_next_page = $objURL->path . '?' . $objURL->getQueryString(); } $this->tpl_subtitle = $tpl_subtitle; $this->tpl_search_mode = $tpl_search_mode; // 支払方法の取得 $this->arrPayment = $this->lfGetPayment(); // 入力情報を渡す $this->arrForm = $_POST; $this->category_id = $arrCategory_id[0]; $this->arrSearch = $arrSearch; $this->tpl_mainpage = MOBILE_TEMPLATE_DIR . "products/list.tpl"; $objView->assignobj($this); $objView->display(SITE_FRAME); }