Exemplo n.º 1
0
 /**
 * カートの内容を計算する.
 *
 * カートの内容を計算し, 下記のキーを保持する連想配列を返す.
 *
 * - tax: 税額
 * - subtotal: カート内商品の小計
 * - deliv_fee: カート内商品の合計送料
 * - total: 合計金額
 * - payment_total: お支払い合計
 * - add_point: 加算ポイント
 *
 * @param integer       $productTypeId 商品種別ID
 * @param Customer   $objCustomer   ログイン中の Customer インスタンス
 * @param integer       $use_point     今回使用ポイント
 * @param integer|array $deliv_pref    配送先都道府県ID.
                                    複数に配送する場合は都道府県IDの配列
 * @param  integer $charge           手数料
 * @param  integer $discount         値引き
 * @param  integer $deliv_id         配送業者ID
 * @param  integer $order_pref       注文者の都道府県ID
 * @param  integer $order_country_id 注文者の国
 * @return array   カートの計算結果の配列
 */
 public function calculate($productTypeId, Customer &$objCustomer, $use_point = 0, $deliv_pref = '', $charge = 0, $discount = 0, $deliv_id = 0, $order_pref = 0, $order_country_id = 0)
 {
     $results = array();
     $total_point = $this->getAllProductsPoint($productTypeId);
     // MEMO: 税金計算は注文者の住所基準
     $results['tax'] = $this->getAllProductsTax($productTypeId, $order_pref, $order_country_id);
     $results['subtotal'] = $this->getAllProductsTotal($productTypeId, $order_pref, $order_country_id);
     $results['deliv_fee'] = 0;
     // 商品ごとの送料を加算
     if (OPTION_PRODUCT_DELIV_FEE == 1) {
         $cartItems = $this->getCartList($productTypeId);
         foreach ($cartItems as $arrItem) {
             $results['deliv_fee'] += $arrItem['productsClass']['deliv_fee'] * $arrItem['quantity'];
         }
     }
     // 配送業者の送料を加算
     if (OPTION_DELIV_FEE == 1 && !Utils::isBlank($deliv_pref) && !Utils::isBlank($deliv_id)) {
         $results['deliv_fee'] += Application::alias('eccube.helper.delivery')->getDelivFee($deliv_pref, $deliv_id);
     }
     // 送料無料チェック
     if ($this->isDelivFree($productTypeId)) {
         $results['deliv_fee'] = 0;
     }
     // 合計を計算
     $results['total'] = $results['subtotal'];
     $results['total'] += $results['deliv_fee'];
     $results['total'] += $charge;
     $results['total'] -= $discount;
     // お支払い合計
     $results['payment_total'] = $results['total'] - $use_point * POINT_VALUE;
     // 加算ポイントの計算
     if (USE_POINT !== false) {
         $results['add_point'] = Application::alias('eccube.helper.db')->getAddPoint($total_point, $use_point);
         if ($objCustomer != '') {
             // 誕生日月であった場合
             if ($objCustomer->isBirthMonth()) {
                 $results['birth_point'] = BIRTH_MONTH_POINT;
                 $results['add_point'] += $results['birth_point'];
             }
         }
         if ($results['add_point'] < 0) {
             $results['add_point'] = 0;
         }
     }
     return $results;
 }
Exemplo n.º 2
0
 /**
  * 複数配送情報を一時保存する.
  *
  * 会員ログインしている場合は, その他のお届け先から住所情報を取得する.
  *
  * @param   integer         $uniqid       一時受注テーブルのユニークID
  * @param   FormParam       $objFormParam FormParam インスタンス
  * @param   Customer        $objCustomer  Customer インスタンス
  * @param   PurchaseHelper  $objPurchase  PurchaseHelper インスタンス
  * @param   AddressHelper   $objAddress
  * @return  void
  */
 public function saveMultipleShippings($uniqid, FormParam &$objFormParam, Customer &$objCustomer, PurchaseHelper &$objPurchase, AddressHelper &$objAddress)
 {
     $arrValues = array();
     $arrItemTemp = array();
     $arrParams = $objFormParam->getSwapArray();
     foreach ($arrParams as $arrParam) {
         $other_deliv_id = $arrParam['shipping'];
         if ($objCustomer->isLoginSuccess(true)) {
             if ($other_deliv_id != 0) {
                 $otherDeliv = $objAddress->getAddress($other_deliv_id, $objCustomer->getValue('customer_id'));
                 if (!$otherDeliv) {
                     Utils::sfDispSiteError(FREE_ERROR_MSG, '', false, "入力値が不正です。<br />正しい値を入力してください。");
                     Application::alias('eccube.response')->actionExit();
                 }
                 foreach ($otherDeliv as $key => $val) {
                     $arrValues[$other_deliv_id]['shipping_' . $key] = $val;
                 }
             } else {
                 $objPurchase->copyFromCustomer($arrValues[0], $objCustomer, 'shipping');
             }
         } else {
             $arrValues = $objPurchase->getShippingTemp();
         }
         if (!isset($arrItemTemp[$other_deliv_id])) {
             $arrItemTemp[$other_deliv_id] = array();
         }
         if (!isset($arrItemTemp[$other_deliv_id][$arrParam['product_class_id']])) {
             $arrItemTemp[$other_deliv_id][$arrParam['product_class_id']] = 0;
         }
         $arrItemTemp[$other_deliv_id][$arrParam['product_class_id']] += $arrParam['quantity'];
     }
     $objPurchase->clearShipmentItemTemp();
     foreach ($arrValues as $shipping_id => $arrVal) {
         $objPurchase->saveShippingTemp($arrVal, $shipping_id);
     }
     foreach ($arrItemTemp as $other_deliv_id => $arrProductClassIds) {
         foreach ($arrProductClassIds as $product_class_id => $quantity) {
             if ($quantity == 0) {
                 continue;
             }
             $objPurchase->setShipmentItemTemp($other_deliv_id, $product_class_id, $quantity);
         }
     }
     //不必要な配送先を削除
     foreach ($_SESSION['shipping'] as $id => $arrShipping) {
         if (!isset($arrShipping['shipment_item'])) {
             $objPurchase->unsetOneShippingTemp($id);
         }
     }
     // $arrValues[0] には, 購入者の情報が格納されている
     $objPurchase->saveOrderTemp($uniqid, $arrValues[0], $objCustomer);
 }
Exemplo n.º 3
0
 /**
  * Add product to authenticated user's favorites. (for Smart phone)
  *
  * @param  Customer $objCustomer
  * @return void
  */
 public function doAddFavoriteSphone(Customer $objCustomer)
 {
     // ログイン中のユーザが商品をお気に入りにいれる処理(スマートフォン用)
     if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0) {
         $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam);
         if (count($this->arrErr) == 0) {
             if ($this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'), $objCustomer->getValue('customer_id'))) {
                 $objPlugin = PluginHelper::getSingletonInstance($this->plugin_activate_flg);
                 $objPlugin->doAction('LC_Page_Products_Detail_action_add_favorite_sphone', array($this));
                 print 'true';
                 Application::alias('eccube.response')->actionExit();
             }
         }
         print 'error';
         Application::alias('eccube.response')->actionExit();
     }
 }
Exemplo n.º 4
0
 /**
  * セッションに保持している情報を破棄する.
  *
  * 通常、受注処理(completeOrder)完了後に呼び出され、
  * セッション情報を破棄する.
  *
  * 決済モジュール画面から確認画面に「戻る」場合を考慮し、
  * セッション情報を破棄しないカスタマイズを、モジュール側で
  * 加える機会を与える.
  *
  * $orderId が使われていない。
  *
  * @param integer        $orderId        注文番号
  * @param CartSession $objCartSession カート情報のインスタンス
  * @param Customer    $objCustomer    Customer インスタンス
  * @param integer        $cartKey        登録を行うカート情報のキー
  */
 public function cleanupSession($orderId, &$objCartSession, &$objCustomer, $cartKey)
 {
     // カートの内容を削除する.
     $objCartSession->delAllProducts($cartKey);
     Application::alias('eccube.site_session')->unsetUniqId();
     // セッションの配送情報を破棄する.
     $this->unsetAllShippingTemp(true);
     $objCustomer->updateSession();
 }