【ECCUBE2.13】商品種別を使わず配送方法等を処理分け
商品種別で配送方法等を処理分けすると同時購入が出来ないので、強引に処理分け。
1)処理分け用のフラグを商品情報に追加
商品ステータス(ProductStatus)を使用していなかったため、転用。
※商品ステータスにメール便を追加
2)商品ステータスをカートセッションに追加
[FILE]: data/class/pages/products/LC_Page_Products_Detail.php
public function doCart() { $objCustomer = new SC_Customer_Ex(); $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam, $this->tpl_classcat_find1, $this->tpl_classcat_find2); //商品ID取得 $this_product_id = $this->objFormParam->getValue('product_id'); //商品ステータス取得 $objProduct = new SC_Product_Ex(); $getProductStatus_arr = $objProduct->getProductStatus($this_product_id); $thisProductStatus = $getProductStatus_arr[$this_product_id]['0']; if (count($this->arrErr) == 0) { $objCartSess = new SC_CartSession_Ex(); $product_class_id = $this->objFormParam->getValue('product_class_id'); $objCartSess->addProduct($product_class_id, $this->objFormParam->getValue('quantity'), //商品ステータスをセッションに追加 $thisProductStatus ); // 開いているカテゴリーツリーを維持するためのパラメーター $arrQueryString = array( 'product_id' => $this->objFormParam->getValue('product_id'), ); SC_Response_Ex::sendRedirect(CART_URL, $arrQueryString); SC_Response_Ex::actionExit(); } }
[FILE]:data/class/SC_CartSession.php
public function addProduct($product_class_id, $quantity,$product_status="") { $objProduct = new SC_Product_Ex(); $arrProduct = $objProduct->getProductsClass($product_class_id); $productTypeId = $arrProduct['product_type_id']; $find = false; $max = $this->getMax($productTypeId); for ($i = 0; $i <= $max; $i++) { if ($this->cartSession[$productTypeId][$i]['id'] == $product_class_id) { $val = $this->cartSession[$productTypeId][$i]['quantity'] + $quantity; if (strlen($val) <= INT_LEN) { $this->cartSession[$productTypeId][$i]['quantity'] += $quantity; } $find = true; } } if (!$find) { $this->cartSession[$productTypeId][$max+1]['id'] = $product_class_id; $this->cartSession[$productTypeId][$max+1]['quantity'] = $quantity; $this->cartSession[$productTypeId][$max+1]['cart_no'] = $this->getNextCartID($productTypeId); //商品ステータスを追加 $this->cartSession[$productTypeId][$max+1]['product_status'] = $product_status; } }
3)ステータスによる配送方法の条件設定
※今回はメール便に関する設定
以下の条件をどちらも満たす場合メール便の利用が可能
・メール便対象商品のみがカートに入っている
・カート内の商品合計数が4個未満
[FILE]:data/class/pages/shopping/LC_Page_Shopping_Payment.php
public function action()内
$objPurchase->verifyChangeCart($this->tpl_uniqid, $objCartSess);の下あたり
//メール便不可フラグ $mailPost_delive = true; //メール便個数 $sum_pr_quantity = "0"; //商品ステータス取得 foreach ($objCartSess->cartSession as $arr_cartSession) { foreach ($arr_cartSession as $value) { if(!empty($value['price'])){ //個数取得 $pr_quantity = $value["quantity"]; //商品ステータス取得 $pr_status = $value["product_status"]; //商品ステータスが空(ステータス指定なし)のものがあればFalse if($pr_status == ''){ $mailPost_delive = false; //商品ステータスが1(メール便)のものがあれば合計数をチェック }elseif($pr_status == '1'){ $sum_pr_quantity = $sum_pr_quantity + $pr_quantity; } } } } //合計個数が4個以上ならメール便不可 if($sum_pr_quantity > 3){ $mailPost_delive = false; } //配送方法一覧取得 $this->arrDeliv = $objDelivery->getList($cart_key,'',$mailPost_delive); |php|< [FILES]:data/class/helper/SC_Helper_Delivery.php >|php| //メール便不可フラグ追加 public function getList($product_type_id = null, $has_deleted = false,$mailPost_delive = null) { $objQuery =& SC_Query_Ex::getSingletonInstance(); $col = '*'; $where = ''; $arrVal = array(); if (!$has_deleted) { $where .= 'del_flg = 0'; } if (!is_null($product_type_id)) { if (!$has_deleted) { $where .= ' AND '; } $where .= 'product_type_id = ?'; $arrVal[] = $product_type_id; } //メール便不可の場合の処理 if($mailPost_delive === false){ //echo $mailPost_delive; if (!$has_deleted) { $where .= ' AND deliv_id != 5'; } } $table = 'dtb_deliv'; $objQuery->setOrder('rank DESC'); $arrRet = $objQuery->select($col, $table, $where, $arrVal); return $arrRet; }