1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved. |
---|
6 | * |
---|
7 | * http://www.lockon.co.jp/ |
---|
8 | * |
---|
9 | * This program is free software; you can redistribute it and/or |
---|
10 | * modify it under the terms of the GNU General Public License |
---|
11 | * as published by the Free Software Foundation; either version 2 |
---|
12 | * of the License, or (at your option) any later version. |
---|
13 | * |
---|
14 | * This program is distributed in the hope that it will be useful, |
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | * GNU General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with this program; if not, write to the Free Software |
---|
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
22 | */ |
---|
23 | |
---|
24 | // {{{ requires |
---|
25 | require_once(CLASS_EX_REALDIR . "page_extends/LC_Page_Ex.php"); |
---|
26 | |
---|
27 | /** |
---|
28 | * 商品一覧 のページクラス. |
---|
29 | * |
---|
30 | * @package Page |
---|
31 | * @author LOCKON CO.,LTD. |
---|
32 | * @version $Id$ |
---|
33 | */ |
---|
34 | class LC_Page_Products_List extends LC_Page_Ex { |
---|
35 | |
---|
36 | // {{{ properties |
---|
37 | |
---|
38 | /** テンプレートクラス名1 */ |
---|
39 | var $tpl_class_name1 = array(); |
---|
40 | |
---|
41 | /** テンプレートクラス名2 */ |
---|
42 | var $tpl_class_name2 = array(); |
---|
43 | |
---|
44 | /** JavaScript テンプレート */ |
---|
45 | var $tpl_javascript; |
---|
46 | |
---|
47 | var $orderby; |
---|
48 | |
---|
49 | var $mode; |
---|
50 | |
---|
51 | /** 検索条件(内部データ) */ |
---|
52 | var $arrSearchData = array(); |
---|
53 | |
---|
54 | /** 検索条件(表示用) */ |
---|
55 | var $arrSearch = array(); |
---|
56 | |
---|
57 | var $tpl_subtitle = ''; |
---|
58 | |
---|
59 | /** ランダム文字列 **/ |
---|
60 | var $tpl_rnd = ''; |
---|
61 | |
---|
62 | // }}} |
---|
63 | // {{{ functions |
---|
64 | |
---|
65 | /** |
---|
66 | * Page を初期化する. |
---|
67 | * |
---|
68 | * @return void |
---|
69 | */ |
---|
70 | function init() { |
---|
71 | parent::init(); |
---|
72 | |
---|
73 | $masterData = new SC_DB_MasterData_Ex(); |
---|
74 | $this->arrSTATUS = $masterData->getMasterData("mtb_status"); |
---|
75 | $this->arrSTATUS_IMAGE = $masterData->getMasterData("mtb_status_image"); |
---|
76 | $this->arrDELIVERYDATE = $masterData->getMasterData("mtb_delivery_date"); |
---|
77 | $this->arrPRODUCTLISTMAX = $masterData->getMasterData("mtb_product_list_max"); |
---|
78 | } |
---|
79 | |
---|
80 | /** |
---|
81 | * Page のプロセス. |
---|
82 | * |
---|
83 | * @return void |
---|
84 | */ |
---|
85 | function process() { |
---|
86 | parent::process(); |
---|
87 | $this->action(); |
---|
88 | $this->sendResponse(); |
---|
89 | } |
---|
90 | |
---|
91 | /** |
---|
92 | * Page のAction. |
---|
93 | * |
---|
94 | * @return void |
---|
95 | */ |
---|
96 | function action() { |
---|
97 | $objQuery =& SC_Query::getSingletonInstance(); |
---|
98 | $objProduct = new SC_Product(); |
---|
99 | |
---|
100 | $this->arrForm = $_REQUEST;//時間が無いのでコレで勘弁してください。 tao_s |
---|
101 | //modeの取得 |
---|
102 | $this->mode = $this->getMode(); |
---|
103 | |
---|
104 | //表示条件の取得 |
---|
105 | $this->arrSearchData = array( |
---|
106 | 'category_id' => $this->lfGetCategoryId(intval($this->arrForm['category_id'])), |
---|
107 | 'maker_id'=>intval($this->arrForm['maker_id']), |
---|
108 | 'name'=>$this->arrForm['name'] |
---|
109 | ); |
---|
110 | $this->orderby = $this->arrForm['orderby']; |
---|
111 | |
---|
112 | //ページング設定 |
---|
113 | $this->tpl_pageno = $this->arrForm['pageno']; |
---|
114 | $this->disp_number = $this->lfGetDisplayNum($this->arrForm['disp_number']); |
---|
115 | |
---|
116 | // 画面に表示するサブタイトルの設定 |
---|
117 | $this->tpl_subtitle = $this->lfGetPageTitle($this->mode,$this->arrSearchData['category_id']); |
---|
118 | |
---|
119 | // 画面に表示する検索条件を設定 |
---|
120 | $this->arrSearch = $this->lfGetSearchConditionDisp($this->arrSearchData); |
---|
121 | |
---|
122 | // 商品一覧データの取得 |
---|
123 | $arrSearchCondition = $this->lfGetSearchCondition($this->arrSearchData); |
---|
124 | $this->tpl_linemax = $this->lfGetProductAllNum($arrSearchCondition); |
---|
125 | $urlParam = "category_id={$this->arrSearchData['category_id']}&pageno=#page#"; |
---|
126 | $this->objNavi = new SC_PageNavi($this->tpl_pageno, $this->tpl_linemax, $this->disp_number, "fnNaviPage", NAVI_PMAX, $urlParam,SC_Display::detectDevice() !== DEVICE_TYPE_MOBILE); |
---|
127 | $this->arrProducts = $this->lfGetProductsList($arrSearchCondition,$this->disp_number,$this->objNavi->start_row,$this->tpl_linemax,$objProduct); |
---|
128 | //商品一覧の表示処理 |
---|
129 | $strnavi = $this->objNavi->strnavi; |
---|
130 | // 表示文字列 |
---|
131 | $this->tpl_strnavi = empty($strnavi) ? " " : $strnavi; |
---|
132 | |
---|
133 | // 規格1クラス名 |
---|
134 | $this->tpl_class_name1 = $objProduct->className1; |
---|
135 | |
---|
136 | // 規格2クラス名 |
---|
137 | $this->tpl_class_name2 = $objProduct->className2; |
---|
138 | |
---|
139 | // 規格1 |
---|
140 | $this->arrClassCat1 = $objProduct->classCats1; |
---|
141 | |
---|
142 | // 規格1が設定されている |
---|
143 | $this->tpl_classcat_find1 = $objProduct->classCat1_find; |
---|
144 | // 規格2が設定されている |
---|
145 | $this->tpl_classcat_find2 = $objProduct->classCat2_find; |
---|
146 | |
---|
147 | $this->tpl_stock_find = $objProduct->stock_find; |
---|
148 | $this->tpl_product_class_id = $objProduct->product_class_id; |
---|
149 | $this->tpl_product_type = $objProduct->product_type; |
---|
150 | |
---|
151 | // 商品ステータスを取得 |
---|
152 | $this->productStatus = $this->arrProducts["productStatus"]; |
---|
153 | unset($this->arrProducts["productStatus"]); |
---|
154 | $this->tpl_javascript .= 'var productsClassCategories = ' . SC_Utils_Ex::jsonEncode($objProduct->classCategories) . ';'; |
---|
155 | //onloadスクリプトを設定 |
---|
156 | foreach ($this->arrProducts as $arrProduct) { |
---|
157 | $js_fnOnLoad .= "fnSetClassCategories(document.product_form{$arrProduct['product_id']});"; |
---|
158 | } |
---|
159 | |
---|
160 | //カート処理 |
---|
161 | $target_product_id = intval($this->arrForm['product_id']); |
---|
162 | if ( $target_product_id > 0) { |
---|
163 | // 商品IDの正当性チェック |
---|
164 | if (!SC_Utils_Ex::sfIsInt($this->arrForm['product_id']) || !SC_Helper_DB_Ex::sfIsRecord("dtb_products", "product_id", $this->arrForm['product_id'], "del_flg = 0 AND status = 1")) { |
---|
165 | SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND); |
---|
166 | } |
---|
167 | |
---|
168 | // 入力内容のチェック |
---|
169 | $arrErr = $this->lfCheckError($target_product_id,$this->arrForm,$this->tpl_classcat_find1,$this->tpl_classcat_find2); |
---|
170 | if (count($arrErr) == 0) { |
---|
171 | $this->lfAddCart($this->arrForm,$this->tpl_classcat_find1,$this->tpl_classcat_find2,$target_product_id,$_SERVER['HTTP_REFERER']); |
---|
172 | SC_Response_Ex::sendRedirect(CART_URLPATH); |
---|
173 | exit; |
---|
174 | } |
---|
175 | $js_fnOnLoad .= $this->lfSetSelectedData($this->arrProducts,$this->arrForm,$arrErr,$target_product_id); |
---|
176 | } |
---|
177 | |
---|
178 | // ページャ用データ設定(モバイル) |
---|
179 | if (SC_Display::detectDevice() == DEVICE_TYPE_MOBILE) { |
---|
180 | $this->tpl_previous_page = $this->objNavi->arrPagenavi['before']; |
---|
181 | $this->tpl_next_page = $this->objNavi->arrPagenavi['next']; |
---|
182 | } |
---|
183 | |
---|
184 | $this->tpl_javascript .= 'function fnOnLoad(){' . $js_fnOnLoad . '}'; |
---|
185 | $this->tpl_onload .= 'fnOnLoad(); '; |
---|
186 | |
---|
187 | $this->tpl_rnd = SC_Utils_Ex::sfGetRandomString(3); |
---|
188 | } |
---|
189 | |
---|
190 | /** |
---|
191 | * デストラクタ. |
---|
192 | * |
---|
193 | * @return void |
---|
194 | */ |
---|
195 | function destroy() { |
---|
196 | parent::destroy(); |
---|
197 | } |
---|
198 | |
---|
199 | /** |
---|
200 | * カテゴリIDの取得 |
---|
201 | * |
---|
202 | * @return integer カテゴリID |
---|
203 | */ |
---|
204 | function lfGetCategoryId($category_id) { |
---|
205 | // 指定なしの場合、0 を返す |
---|
206 | if ( |
---|
207 | strlen($category_id) == 0 |
---|
208 | || (String) $category_id == '0' |
---|
209 | ) { |
---|
210 | return 0; |
---|
211 | } |
---|
212 | |
---|
213 | // 正当性チェック |
---|
214 | if ( |
---|
215 | !SC_Utils_Ex::sfIsInt($category_id) |
---|
216 | || SC_Utils_Ex::sfIsZeroFilling($category_id) |
---|
217 | || !SC_Helper_DB_Ex::sfIsRecord('dtb_category', 'category_id', (array)$category_id, 'del_flg = 0') |
---|
218 | ) { |
---|
219 | SC_Utils_Ex::sfDispSiteError(CATEGORY_NOT_FOUND); |
---|
220 | } |
---|
221 | |
---|
222 | // 指定されたカテゴリIDを元に正しいカテゴリIDを取得する。 |
---|
223 | $arrCategory_id = SC_Helper_DB_Ex::sfGetCategoryId('', $category_id); |
---|
224 | |
---|
225 | if (empty($arrCategory_id)) { |
---|
226 | SC_Utils_Ex::sfDispSiteError(CATEGORY_NOT_FOUND); |
---|
227 | } |
---|
228 | |
---|
229 | return $arrCategory_id[0]; |
---|
230 | } |
---|
231 | |
---|
232 | /* 商品一覧の表示 */ |
---|
233 | function lfGetProductsList($searchCondition,$disp_number,$startno,$linemax,&$objProduct) { |
---|
234 | |
---|
235 | $arrval_order = array(); |
---|
236 | |
---|
237 | $objQuery =& SC_Query::getSingletonInstance(); |
---|
238 | // 表示順序 |
---|
239 | switch ($this->orderby) { |
---|
240 | // 販売価格が安い順 |
---|
241 | case 'price': |
---|
242 | $objProduct->setProductsOrder('price02', 'dtb_products_class', 'ASC'); |
---|
243 | break; |
---|
244 | |
---|
245 | // 新着順 |
---|
246 | case 'date': |
---|
247 | $objProduct->setProductsOrder('create_date', 'dtb_products', 'DESC'); |
---|
248 | break; |
---|
249 | |
---|
250 | default: |
---|
251 | if (strlen($searchCondition["where_category"]) >= 1) { |
---|
252 | $dtb_product_categories = "(SELECT * FROM dtb_product_categories WHERE ".$searchCondition["where_category"].")"; |
---|
253 | $arrval_order = array_merge($searchCondition["arrvalCategory"], $searchCondition["arrvalCategory"]); |
---|
254 | } else { |
---|
255 | $dtb_product_categories = 'dtb_product_categories'; |
---|
256 | } |
---|
257 | $order = <<< __EOS__ |
---|
258 | ( |
---|
259 | SELECT |
---|
260 | T3.rank |
---|
261 | FROM |
---|
262 | $dtb_product_categories T2 |
---|
263 | JOIN dtb_category T3 |
---|
264 | USING (category_id) |
---|
265 | WHERE T2.product_id = alldtl.product_id |
---|
266 | ORDER BY T3.rank DESC, T2.rank DESC |
---|
267 | LIMIT 1 |
---|
268 | ) DESC |
---|
269 | ,( |
---|
270 | SELECT |
---|
271 | T2.rank |
---|
272 | FROM |
---|
273 | $dtb_product_categories T2 |
---|
274 | JOIN dtb_category T3 |
---|
275 | USING (category_id) |
---|
276 | WHERE T2.product_id = alldtl.product_id |
---|
277 | ORDER BY T3.rank DESC, T2.rank DESC |
---|
278 | LIMIT 1 |
---|
279 | ) DESC |
---|
280 | ,product_id |
---|
281 | __EOS__; |
---|
282 | $objQuery->setOrder($order); |
---|
283 | break; |
---|
284 | } |
---|
285 | // 取得範囲の指定(開始行番号、行数のセット) |
---|
286 | $objQuery->setLimitOffset($disp_number, $startno); |
---|
287 | $objQuery->setWhere($searchCondition["where"]); |
---|
288 | |
---|
289 | // 表示すべきIDとそのIDの並び順を一気に取得 |
---|
290 | $arrProduct_id = $objProduct->findProductIdsOrder($objQuery, array_merge($searchCondition["arrval"], $arrval_order)); |
---|
291 | |
---|
292 | // 取得した表示すべきIDだけを指定して情報を取得。 |
---|
293 | $where = ""; |
---|
294 | if (is_array($arrProduct_id) && !empty($arrProduct_id)) { |
---|
295 | $where = 'product_id IN (' . implode(',', $arrProduct_id) . ')'; |
---|
296 | } else { |
---|
297 | // 一致させない |
---|
298 | $where = '0<>0'; |
---|
299 | } |
---|
300 | $objQuery =& SC_Query::getSingletonInstance(); |
---|
301 | $objQuery->setWhere($where); |
---|
302 | $arrProducts = $objProduct->lists($objQuery, $arrProduct_id); |
---|
303 | |
---|
304 | //取得している並び順で並び替え |
---|
305 | $arrProducts2 = array(); |
---|
306 | foreach($arrProducts as $item) { |
---|
307 | $arrProducts2[ $item['product_id'] ] = $item; |
---|
308 | } |
---|
309 | $arrProducts = array(); |
---|
310 | foreach($arrProduct_id as $product_id) { |
---|
311 | $arrProducts[] = $arrProducts2[$product_id]; |
---|
312 | } |
---|
313 | |
---|
314 | // 規格を設定 |
---|
315 | $objProduct->setProductsClassByProductIds($arrProduct_id); |
---|
316 | $arrProducts += array("productStatus"=>$objProduct->getProductStatus($arrProduct_id)); |
---|
317 | return $arrProducts; |
---|
318 | } |
---|
319 | |
---|
320 | /* 入力内容のチェック */ |
---|
321 | function lfCheckError($product_id,&$arrForm,$tpl_classcat_find1,$tpl_classcat_find2) { |
---|
322 | |
---|
323 | // 入力データを渡す。 |
---|
324 | $objErr = new SC_CheckError($arrForm); |
---|
325 | |
---|
326 | // 複数項目チェック |
---|
327 | if ($tpl_classcat_find1[$product_id]) { |
---|
328 | $objErr->doFunc(array("規格1", 'classcategory_id1', INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
329 | } |
---|
330 | if ($tpl_classcat_find2[$product_id]) { |
---|
331 | $objErr->doFunc(array("規格2", 'classcategory_id2', INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
332 | } |
---|
333 | $objErr->doFunc(array("数量", 'quantity', INT_LEN), array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
334 | |
---|
335 | return $objErr->arrErr; |
---|
336 | } |
---|
337 | |
---|
338 | /** |
---|
339 | * パラメータの読み込み |
---|
340 | * |
---|
341 | * @return void |
---|
342 | */ |
---|
343 | function lfGetDisplayNum($display_number) { |
---|
344 | // 表示件数 |
---|
345 | if (!isset($display_number) |
---|
346 | OR !SC_Utils_Ex::sfIsInt($display_number) |
---|
347 | ) { |
---|
348 | //最小表示件数を選択 |
---|
349 | return current(array_keys($this->arrPRODUCTLISTMAX)); |
---|
350 | } |
---|
351 | return $display_number; |
---|
352 | } |
---|
353 | |
---|
354 | /** |
---|
355 | * ページタイトルの設定 |
---|
356 | * |
---|
357 | * @return str |
---|
358 | */ |
---|
359 | function lfGetPageTitle($mode,$category_id = 0){ |
---|
360 | if ($mode == 'search') { |
---|
361 | return "検索結果"; |
---|
362 | } elseif ($category_id == 0) { |
---|
363 | return "全商品"; |
---|
364 | } else { |
---|
365 | $arrCat = SC_Helper_DB_Ex::sfGetCat($category_id); |
---|
366 | return $arrCat['name']; |
---|
367 | } |
---|
368 | return ""; |
---|
369 | } |
---|
370 | |
---|
371 | /** |
---|
372 | * 表示用検索条件の設定 |
---|
373 | * |
---|
374 | * @return array |
---|
375 | */ |
---|
376 | function lfGetSearchConditionDisp($arrSearchData){ |
---|
377 | $objQuery =& SC_Query::getSingletonInstance(); |
---|
378 | $arrSearch = array('category'=>"指定なし",'maker'=>"指定なし",'name'=>"指定なし"); |
---|
379 | // カテゴリー検索条件 |
---|
380 | if ($arrSearchData['category_id'] > 0) { |
---|
381 | $arrSearch['category'] = $objQuery->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?", array($arrSearchData['category_id'])); |
---|
382 | } |
---|
383 | |
---|
384 | // メーカー検索条件 |
---|
385 | if (strlen($arrSearchData['maker_id']) > 0) { |
---|
386 | $arrSearch['maker'] = $objQuery->getOne("SELECT name FROM dtb_maker WHERE maker_id = ?", array($arrSearchData['maker_id'])); |
---|
387 | } |
---|
388 | |
---|
389 | // 商品名検索条件 |
---|
390 | if (strlen($arrSearchData['name']) > 0) { |
---|
391 | $arrSearch['name'] = $arrSearchData['name']; |
---|
392 | } |
---|
393 | return $arrSearch; |
---|
394 | } |
---|
395 | |
---|
396 | /** |
---|
397 | * 該当件数の取得 |
---|
398 | * |
---|
399 | * @return int |
---|
400 | */ |
---|
401 | function lfGetProductAllNum($searchCondition){ |
---|
402 | // 検索結果対象となる商品の数を取得 |
---|
403 | $objQuery =& SC_Query::getSingletonInstance(); |
---|
404 | $objQuery->setWhere($searchCondition["where"]); |
---|
405 | $objProduct = new SC_Product(); |
---|
406 | return $objProduct->findProductCount($objQuery, $searchCondition["arrval"]); |
---|
407 | } |
---|
408 | |
---|
409 | /** |
---|
410 | * 検索条件のwhere文とかを取得 |
---|
411 | * |
---|
412 | * @return array |
---|
413 | */ |
---|
414 | function lfGetSearchCondition($arrSearchData){ |
---|
415 | $searchCondition = array( |
---|
416 | "where"=>"", |
---|
417 | "arrval"=>array(), |
---|
418 | "where_category"=>"", |
---|
419 | "arrvalCategory"=>array() |
---|
420 | ); |
---|
421 | |
---|
422 | // カテゴリからのWHERE文字列取得 |
---|
423 | if ($arrSearchData["category_id"] != 0) { |
---|
424 | list($searchCondition["where_category"], $searchCondition["arrvalCategory"]) = SC_Helper_DB_Ex::sfGetCatWhere($arrSearchData["category_id"]); |
---|
425 | } |
---|
426 | // ▼対象商品IDの抽出 |
---|
427 | // 商品検索条件の作成(未削除、表示) |
---|
428 | $searchCondition["where"] = "alldtl.del_flg = 0 AND alldtl.status = 1 "; |
---|
429 | |
---|
430 | // 在庫無し商品の非表示 |
---|
431 | if (NOSTOCK_HIDDEN === true) { |
---|
432 | $searchCondition["where"] .= ' AND (stock >= 1 OR stock_unlimited = 1)'; |
---|
433 | } |
---|
434 | |
---|
435 | if (strlen($searchCondition["where_category"]) >= 1) { |
---|
436 | $searchCondition["where"] .= " AND T2.".$searchCondition["where_category"]; |
---|
437 | $searchCondition["arrval"] = array_merge($searchCondition["arrval"], $searchCondition["arrvalCategory"]); |
---|
438 | } |
---|
439 | |
---|
440 | // 商品名をwhere文に |
---|
441 | $name = $arrSearchData['name']; |
---|
442 | $name = str_replace(",", "", $name); |
---|
443 | // 全角スペースを半角スペースに変換 |
---|
444 | $name = str_replace(' ', ' ', $name); |
---|
445 | // スペースでキーワードを分割 |
---|
446 | $names = preg_split("/ +/", $name); |
---|
447 | // 分割したキーワードを一つずつwhere文に追加 |
---|
448 | foreach ($names as $val) { |
---|
449 | if ( strlen($val) > 0 ) { |
---|
450 | $searchCondition["where"] .= " AND ( alldtl.name ILIKE ? OR alldtl.comment3 ILIKE ?) "; |
---|
451 | $searchCondition["arrval"][] = "%$val%"; |
---|
452 | $searchCondition["arrval"][] = "%$val%"; |
---|
453 | } |
---|
454 | } |
---|
455 | |
---|
456 | // メーカーらのWHERE文字列取得 |
---|
457 | if ($arrSearchData['maker_id']) { |
---|
458 | $searchCondition["where"] .= " AND alldtl.maker_id = ? "; |
---|
459 | $searchCondition["arrval"][] = $arrSearchData['maker_id']; |
---|
460 | } |
---|
461 | return $searchCondition; |
---|
462 | } |
---|
463 | |
---|
464 | /** |
---|
465 | * カートに入れる商品情報にエラーがあったら戻す |
---|
466 | * |
---|
467 | * @return str |
---|
468 | */ |
---|
469 | function lfSetSelectedData(&$arrProducts,$arrForm,$arrErr,$product_id){ |
---|
470 | $js_fnOnLoad = ""; |
---|
471 | foreach (array_keys($arrProducts) as $key) { |
---|
472 | if ($arrProducts[$key]['product_id'] == $product_id) { |
---|
473 | $arrProducts[$key]['product_class_id'] = $arrForm['product_class_id']; |
---|
474 | $arrProducts[$key]['classcategory_id1'] = $arrForm['classcategory_id1']; |
---|
475 | $arrProducts[$key]['classcategory_id2'] = $arrForm['classcategory_id2']; |
---|
476 | $arrProducts[$key]['quantity'] = $arrForm['quantity']; |
---|
477 | $arrProducts[$key]['arrErr'] = $arrErr; |
---|
478 | $js_fnOnLoad .= "fnSetClassCategories(document.product_form{$arrProducts[$key]['product_id']}, '{$arrForm['classcategory_id2']}');"; |
---|
479 | } |
---|
480 | } |
---|
481 | return $js_fnOnLoad; |
---|
482 | } |
---|
483 | |
---|
484 | /** |
---|
485 | * カートに商品を追加 |
---|
486 | * |
---|
487 | * @return void |
---|
488 | */ |
---|
489 | function lfAddCart($arrForm,$tpl_classcat_find1,$tpl_classcat_find2,$target_product_id,$referer){ |
---|
490 | $classcategory_id1 = $arrForm['classcategory_id1']; |
---|
491 | $classcategory_id2 = $arrForm['classcategory_id2']; |
---|
492 | // 規格1が設定されていない場合 |
---|
493 | if (!$tpl_classcat_find1[$target_product_id]) { |
---|
494 | $classcategory_id1 = '0'; |
---|
495 | } |
---|
496 | // 規格2が設定されていない場合 |
---|
497 | if (!$tpl_classcat_find2[$target_product_id]) { |
---|
498 | $classcategory_id2 = '0'; |
---|
499 | } |
---|
500 | |
---|
501 | // 規格IDを取得 |
---|
502 | $product_class_id = $arrForm['product_class_id']; |
---|
503 | $product_type = $arrForm['product_type']; |
---|
504 | $objCartSess = new SC_CartSession_Ex(); |
---|
505 | $objCartSess->addProduct($product_class_id, $arrForm['quantity']); |
---|
506 | |
---|
507 | // カート「戻るボタン」用に保持 |
---|
508 | if (SC_Utils_Ex::sfIsInternalDomain($referer)) { |
---|
509 | //該当メソッドが無いため、$_SESSIONに直接セット |
---|
510 | $_SESSION['cart_referer_url'] = $referer; |
---|
511 | } |
---|
512 | } |
---|
513 | } |
---|
514 | ?> |
---|