Beispiel #1
0
 /**
  * 商品側の総量計算&セット
  *
  * @param  FormParam $objFormParam FormParam インスタンス
  * @return void
  */
 public function setProductsQuantity(&$objFormParam)
 {
     $arrShipmentsItems = $objFormParam->getSwapArray(array('shipment_product_class_id', 'shipment_quantity'));
     // 配送先が存在する時のみ、商品個数の再設定を行います
     if (!Utils::isBlank($arrShipmentsItems)) {
         $arrUpdateQuantity = array();
         foreach ($arrShipmentsItems as $arritems) {
             foreach ($arritems['shipment_product_class_id'] as $relation_index => $shipment_product_class_id) {
                 $arrUpdateQuantity[$shipment_product_class_id] += $arritems['shipment_quantity'][$relation_index];
             }
         }
         $arrProductsClass = $objFormParam->getValue('product_class_id');
         $arrQuantity = array();
         foreach ($arrProductsClass as $relation_key => $product_class_id) {
             $arrQuantity[$relation_key] = isset($arrUpdateQuantity[$product_class_id]) ? $arrUpdateQuantity[$product_class_id] : 0;
         }
         $objFormParam->setParam(array('quantity' => $arrQuantity));
     }
 }
Beispiel #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);
 }