/** * 表示用フォームパラメーター取得 * - 入力画面 * * @param UploadFile $objUpFile UploadFileインスタンス * @param UploadFile $objDownFile UploadFileインスタンス * @param array $arrForm フォーム入力パラメーター配列 * @return array 表示用フォームパラメーター配列 */ public function lfSetViewParam_InputPage(&$objUpFile, &$objDownFile, &$arrForm) { // カテゴリマスターデータ取得 /* @var $objDb DbHelper */ $objDb = Application::alias('eccube.helper.db'); list($this->arrCatVal, $this->arrCatOut) = $objDb->getLevelCatList(false); if (isset($arrForm['category_id']) && !is_array($arrForm['category_id'])) { $arrForm['category_id'] = Utils::jsonDecode($arrForm['category_id']); } $this->tpl_json_category_id = !empty($arrForm['category_id']) ? Utils::jsonEncode($arrForm['category_id']) : Utils::jsonEncode(array()); if ($arrForm['status'] == '') { $arrForm['status'] = DEFAULT_PRODUCT_DISP; } if ($arrForm['product_type_id'] == '') { $arrForm['product_type_id'] = DEFAULT_PRODUCT_DOWN; } if (OPTION_PRODUCT_TAX_RULE) { // 編集の場合は設定された税率、新規の場合はデフォルトの税率を取得 if ($arrForm['product_id'] == '') { $arrRet = TaxRuleHelper::getTaxRule(); } else { $arrRet = TaxRuleHelper::getTaxRule($arrForm['product_id'], $arrForm['product_class_id']); } $arrForm['tax_rate'] = $arrRet['tax_rate']; } // アップロードファイル情報取得(Hidden用) $arrHidden = $objUpFile->getHiddenFileList(); $arrForm['arrHidden'] = array_merge((array) $arrHidden, (array) $objDownFile->getHiddenFileList()); // 画像ファイル表示用データ取得 $arrForm['arrFile'] = $objUpFile->getFormFileList(IMAGE_TEMP_URLPATH, IMAGE_SAVE_URLPATH); // ダウンロード商品実ファイル名取得 $arrForm['down_realfilename'] = $objDownFile->getFormDownFile(); // 基本情報(デフォルトポイントレート用) $arrForm['arrInfo'] = Application::alias('eccube.helper.db')->getBasisData(); // サブ情報ありなしフラグ $arrForm['sub_find'] = $this->hasSubProductData($arrForm); return $arrForm; }
/** * 受注商品一覧側に商品を追加 * * @param FormParam $objFormParam FormParam インスタンス * @param array $arrProductClassIds 対象配列の商品規格ID * @param int $insert_product_class_id 追加商品規格ID * @param array $arrAddProductInfo 追加データ * @return array|null $arrAddProducts 更新データ */ public function checkInsertOrderProducts(&$objFormParam, $arrProductClassIds, $insert_product_class_id, $arrAddProductInfo) { if (!$arrProductClassIds || !in_array($insert_product_class_id, $arrProductClassIds)) { $arrAddProducts = array(); $arrTax = TaxRuleHelper::getTaxRule(0, $insert_product_class_id); $arrAddProductInfo['product_name'] = $arrAddProductInfo['product_name'] ? $arrAddProductInfo['product_name'] : $arrAddProductInfo['name']; $arrAddProductInfo['price'] = $arrAddProductInfo['price'] ? $arrAddProductInfo['price'] : $arrAddProductInfo['price02']; $arrAddProductInfo['quantity'] = 1; $arrAddProductInfo['tax_rate'] = $objFormParam->getValue('order_tax_rate') == '' ? $arrTax['tax_rate'] : $objFormParam->getValue('order_tax_rate'); $arrAddProductInfo['tax_rule'] = $objFormParam->getValue('order_tax_rule') == '' ? $arrTax['tax_rule'] : $objFormParam->getValue('order_tax_rule'); foreach ($this->arrProductKeys as $insert_key) { $value = $objFormParam->getValue($insert_key); $arrAddProducts[$insert_key] = is_array($value) ? $value : array(); $arrAddProducts[$insert_key][] = $arrAddProductInfo[$insert_key]; } return $arrAddProducts; } else { //受注商品の数量は、複数配送側の集計で出しているので、重複しても数量を増やさない。 return null; } }
/** * 商品種別ごとにカート内商品の一覧を取得する. * * @param integer $productTypeId 商品種別ID * @param integer $pref_id 税金計算用注文者都道府県ID * @param integer $country_id 税金計算用注文者国ID * @return array カート内商品一覧の配列 */ public function getCartList($productTypeId, $pref_id = 0, $country_id = 0) { /* @var $objProduct Product */ $objProduct = Application::alias('eccube.product'); $max = $this->getMax($productTypeId); $arrRet = array(); /* $const_name = '_CALLED_CARTSESSION_GETCARTLIST_' . $productTypeId; if (defined($const_name)) { $is_first = true; } else { define($const_name, true); $is_first = false; } */ for ($i = 0; $i <= $max; $i++) { if (isset($this->cartSession[$productTypeId][$i]['cart_no']) && $this->cartSession[$productTypeId][$i]['cart_no'] != '') { // 商品情報は常に取得 // TODO: 同一インスタンス内では1回のみ呼ぶようにしたい // TODO: ここの商品の合計処理は getAllProductsTotalや getAllProductsTaxとで類似重複なので統一出来そう /* // 同一セッション内では初回のみDB参照するようにしている if (!$is_first) { $this->setCartSession4getCartList($productTypeId, $i); } */ $this->cartSession[$productTypeId][$i]['productsClass'] =& $objProduct->getDetailAndProductsClass($this->cartSession[$productTypeId][$i]['id']); $price = $this->cartSession[$productTypeId][$i]['productsClass']['price02']; $this->cartSession[$productTypeId][$i]['price'] = $price; $this->cartSession[$productTypeId][$i]['point_rate'] = $this->cartSession[$productTypeId][$i]['productsClass']['point_rate']; $quantity = $this->cartSession[$productTypeId][$i]['quantity']; $arrTaxRule = TaxRuleHelper::getTaxRule($this->cartSession[$productTypeId][$i]['productsClass']['product_id'], $this->cartSession[$productTypeId][$i]['productsClass']['product_class_id'], $pref_id, $country_id); $incTax = $price + TaxRuleHelper::calcTax($price, $arrTaxRule['tax_rate'], $arrTaxRule['tax_rule'], $arrTaxRule['tax_adjust']); $total = $incTax * $quantity; $this->cartSession[$productTypeId][$i]['price_inctax'] = $incTax; $this->cartSession[$productTypeId][$i]['total_inctax'] = $total; $this->cartSession[$productTypeId][$i]['tax_rate'] = $arrTaxRule['tax_rate']; $this->cartSession[$productTypeId][$i]['tax_rule'] = $arrTaxRule['tax_rule']; $this->cartSession[$productTypeId][$i]['tax_adjust'] = $arrTaxRule['tax_adjust']; $arrRet[] = $this->cartSession[$productTypeId][$i]; // セッション変数のデータ量を抑制するため、一部の商品情報を切り捨てる // XXX 上で「常に取得」するのだから、丸ごと切り捨てて良さそうにも感じる。 $this->adjustSessionProductsClass($this->cartSession[$productTypeId][$i]['productsClass']); } } return $arrRet; }
/** * 規格編集画面を表示する * * @param FormParam $objFormParam */ public function doPreEdit(&$objFormParam) { $product_id = $objFormParam->getValue('product_id'); /* @var $objProduct Product */ $objProduct = Application::alias('eccube.product'); $existsProductsClass = $objProduct->getProductsClassFullByProductId($product_id); // 規格のデフォルト値(全ての組み合わせ)を取得し, フォームに反映 $class_id1 = $existsProductsClass[0]['class_id1']; $class_id2 = $existsProductsClass[0]['class_id2']; $objFormParam->setValue('class_id1', $class_id1); $objFormParam->setValue('class_id2', $class_id2); $this->doDisp($objFormParam); /* * 登録済みのデータで, フォームの値を上書きする. * * 登録済みデータと, フォームの値は, 配列の形式が違うため, * 同じ形式の配列を生成し, マージしてフォームの値を上書きする */ $arrKeys = array('classcategory_id1', 'classcategory_id2', 'product_code', 'classcategory_name1', 'classcategory_name2', 'stock', 'stock_unlimited', 'price01', 'price02', 'product_type_id', 'down_filename', 'down_realfilename', 'upload_index', 'tax_rate'); $arrFormValues = $objFormParam->getSwapArray($arrKeys); // フォームの規格1, 規格2をキーにした配列を生成 $arrClassCatKey = array(); foreach ($arrFormValues as $formValue) { $arrClassCatKey[$formValue['classcategory_id1']][$formValue['classcategory_id2']] = $formValue; } // 登録済みデータをマージ foreach ($existsProductsClass as $existsValue) { $arrClassCatKey[$existsValue['classcategory_id1']][$existsValue['classcategory_id2']] = $existsValue; } // 規格のデフォルト値に del_flg をつけてマージ後の1次元配列を生成 $arrMergeProductsClass = array(); foreach ($arrClassCatKey as $arrC1) { foreach ($arrC1 as $arrValues) { $arrValues['del_flg'] = (string) $arrValues['del_flg']; if (Utils::isBlank($arrValues['del_flg']) || $arrValues['del_flg'] === '1') { $arrValues['del_flg'] = '1'; } else { $arrValues['del_flg'] = '0'; } // 消費税率を設定 if (OPTION_PRODUCT_TAX_RULE) { $arrRet = TaxRuleHelper::getTaxRule($arrValues['product_id'], $arrValues['product_class_id']); $arrValues['tax_rate'] = $arrRet['tax_rate']; } $arrMergeProductsClass[] = $arrValues; } } // 登録済みのデータで上書き $objFormParam->setParam(Utils::sfSwapArray($arrMergeProductsClass)); // $arrMergeProductsClass で product_id が配列になってしまうため数値で上書き $objFormParam->setValue('product_id', $product_id); // check を設定 $arrChecks = array(); $index = 0; foreach ($objFormParam->getValue('del_flg') as $key => $val) { if ($val === '0') { $arrChecks[$index] = 1; } $index++; } $objFormParam->setValue('check', $arrChecks); // class_id1, class_id2 を取得値で上書き $objFormParam->setValue('class_id1', $class_id1); $objFormParam->setValue('class_id2', $class_id2); }