Changeset 22975
- Timestamp:
- 2013/07/20 16:18:26 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_13-dev/data/class/SC_CartSession.php
r22960 r22975 110 110 } 111 111 112 /**113 * 商品ごとの合計価格114 * XXX 実際には、「商品」ではなく、「カートの明細行(≒商品規格)」のような気がします。115 *116 * @param integer $id117 * @return string 商品ごとの合計価格(税込み)118 * @deprecated SC_CartSession::getCartList() を使用してください119 */120 function getProductTotal($id, $productTypeId)121 {122 $max = $this->getMax($productTypeId);123 for ($i = 0; $i <= $max; $i++) {124 if (isset($this->cartSession[$productTypeId][$i]['id'])125 && $this->cartSession[$productTypeId][$i]['id'] == $id126 ) {127 // 税込み合計128 $price = $this->cartSession[$productTypeId][$i]['price'];129 $quantity = $this->cartSession[$productTypeId][$i]['quantity'];130 $incTax = SC_Helper_TaxRule_Ex::sfCalcIncTax($price, 0, $id[0]);131 $total = $incTax * $quantity;132 return $total;133 }134 }135 136 return 0;137 }138 139 112 // 値のセット 140 113 function setProductValue($id, $key, $val, $productTypeId) … … 180 153 181 154 // 全商品の合計価格 182 function getAllProductsTotal($productTypeId )155 function getAllProductsTotal($productTypeId, $pref_id = 0, $country_id = 0) 183 156 { 184 157 // 税込み合計 … … 196 169 } 197 170 $quantity = $this->cartSession[$productTypeId][$i]['quantity']; 198 199 171 $incTax = SC_Helper_TaxRule_Ex::sfCalcIncTax($price, 200 172 $this->cartSession[$productTypeId][$i]['productsClass']['product_id'], 201 $this->cartSession[$productTypeId][$i]['id'][0]); 173 $this->cartSession[$productTypeId][$i]['id'][0], 174 $pref_id, $country_id); 175 202 176 $total+= ($incTax * $quantity); 203 177 } 204 205 178 return $total; 206 179 } 207 180 208 181 // 全商品の合計税金 209 function getAllProductsTax($productTypeId )182 function getAllProductsTax($productTypeId, $pref_id = 0, $country_id = 0) 210 183 { 211 184 // 税合計 … … 217 190 $tax = SC_Helper_TaxRule_Ex::sfTax($price, 218 191 $this->cartSession[$productTypeId][$i]['productsClass']['product_id'], 219 $this->cartSession[$productTypeId][$i]['id'][0]); 192 $this->cartSession[$productTypeId][$i]['id'][0], 193 $pref_id, $country_id); 194 220 195 $total+= ($tax * $quantity); 221 196 } … … 362 337 * @param integer $key 363 338 * @return void 339 * 340 * MEMO: せっかく一回だけ読み込みにされてますが、税率対応の関係でちょっと保留 364 341 */ 365 342 function setCartSession4getCartList($productTypeId, $key) … … 391 368 * 392 369 * @param integer $productTypeId 商品種別ID 370 * @param integer $pref_id 税金計算用注文者都道府県ID 371 * @param integer $country_id 税金計算用注文者国ID 393 372 * @return array カート内商品一覧の配列 394 373 */ 395 function getCartList($productTypeId) 396 { 374 function getCartList($productTypeId, $pref_id = 0, $country_id = 0) 375 { 376 $objProduct = new SC_Product_Ex(); 397 377 $max = $this->getMax($productTypeId); 398 378 $arrRet = array(); 379 /* 399 380 400 381 $const_name = '_CALLED_SC_CARTSESSION_GETCARTLIST_' . $productTypeId; … … 406 387 } 407 388 389 */ 408 390 for ($i = 0; $i <= $max; $i++) { 409 391 if (isset($this->cartSession[$productTypeId][$i]['cart_no']) 410 392 && $this->cartSession[$productTypeId][$i]['cart_no'] != '') { 393 411 394 // 商品情報は常に取得 412 395 // TODO: 同一インスタンス内では1回のみ呼ぶようにしたい 396 // TODO: ここの商品の合計処理は getAllProductsTotalや getAllProductsTaxとで類似重複なので統一出来そう 397 /* 413 398 // 同一セッション内では初回のみDB参照するようにしている 414 399 if (!$is_first) { 415 400 $this->setCartSession4getCartList($productTypeId, $i); 416 401 } 402 */ 403 404 $this->cartSession[$productTypeId][$i]['productsClass'] 405 =& $objProduct->getDetailAndProductsClass($this->cartSession[$productTypeId][$i]['id']); 406 407 $price = $this->cartSession[$productTypeId][$i]['productsClass']['price02']; 408 $this->cartSession[$productTypeId][$i]['price'] = $price; 409 410 $this->cartSession[$productTypeId][$i]['point_rate'] 411 = $this->cartSession[$productTypeId][$i]['productsClass']['point_rate']; 412 413 $quantity = $this->cartSession[$productTypeId][$i]['quantity']; 414 415 $arrTaxRule = SC_Helper_TaxRule_Ex::getTaxRule( 416 $this->cartSession[$productTypeId][$i]['productsClass']['product_id'], 417 $this->cartSession[$productTypeId][$i]['id'][0], 418 $pref_id, 419 $country_id); 420 $incTax = $price + SC_Helper_TaxRule_Ex::calcTax($price, $arrTaxRule['tax_rate'], $arrTaxRule['tax_rule'], $arrTaxRule['tax_adjust']); 421 422 $total = $incTax * $quantity; 423 $this->cartSession[$productTypeId][$i]['price_inctax'] = $incTax; 424 $this->cartSession[$productTypeId][$i]['total_inctax'] = $total; 425 $this->cartSession[$productTypeId][$i]['tax_rate'] = $arrTaxRule['tax_rate']; 426 $this->cartSession[$productTypeId][$i]['tax_rule'] = $arrTaxRule['tax_rule']; 427 $this->cartSession[$productTypeId][$i]['tax_adjust'] = $arrTaxRule['tax_adjust']; 417 428 418 429 $arrRet[] = $this->cartSession[$productTypeId][$i]; … … 682 693 * @param integer $discount 値引き 683 694 * @param integer $deliv_id 配送業者ID 695 * @param integer $order_pref 注文者の都道府県ID 696 * @param integer $order_country_id 注文者の国 684 697 * @return array カートの計算結果の配列 685 698 */ 686 699 function calculate($productTypeId, &$objCustomer, $use_point = 0, 687 $deliv_pref = '', $charge = 0, $discount = 0, $deliv_id = 0 700 $deliv_pref = '', $charge = 0, $discount = 0, $deliv_id = 0, 701 $order_pref = 0, $order_country_id = 0 688 702 ) { 703 689 704 $results = array(); 690 705 $total_point = $this->getAllProductsPoint($productTypeId); 691 $results['tax'] = $this->getAllProductsTax($productTypeId); 692 $results['subtotal'] = $this->getAllProductsTotal($productTypeId); 706 // MEMO: 税金計算は注文者の住所基準 707 $results['tax'] = $this->getAllProductsTax($productTypeId, $order_pref, $order_country_id); 708 $results['subtotal'] = $this->getAllProductsTotal($productTypeId, $oder_pref, $order_country_id); 693 709 $results['deliv_fee'] = 0; 694 695 $arrTaxInfo = SC_Helper_TaxRule_Ex::getTaxRule();696 $results['order_tax_rate'] = $arrTaxInfo['tax_rate'];697 $results['order_tax_rule'] = $arrTaxInfo['calc_rule'];698 710 699 711 // 商品ごとの送料を加算
Note: See TracChangeset
for help on using the changeset viewer.