Beispiel #1
0
 /**
  * @param  string $productClassId
  * @return \Eccube\Service\CartService
  */
 public function removeProduct($productClassId)
 {
     $this->cart->removeCartItemByIdentifier('Eccube\\Entity\\ProductClass', (string) $productClassId);
     // 支払方法の再設定
     if ($this->BaseInfo->getOptionMultipleShipping() == Constant::ENABLED) {
         // 複数配送対応
         $productTypes = array();
         foreach ($this->getCart()->getCartItems() as $item) {
             /* @var $ProductClass \Eccube\Entity\ProductClass */
             $ProductClass = $item->getObject();
             $productTypes[] = $ProductClass->getProductType();
         }
         // 配送業者を取得
         $deliveries = $this->entityManager->getRepository('Eccube\\Entity\\Delivery')->getDeliveries($productTypes);
         // 支払方法を取得
         $payments = $this->entityManager->getRepository('Eccube\\Entity\\Payment')->findAllowedPayments($deliveries);
         $this->getCart()->setPayments($payments);
     }
     return $this;
 }
Beispiel #2
0
 /**
  * 住所などの情報が変更された時に金額の再計算を行う
  */
 public function getAmount(\Eccube\Entity\Order $Order, \Eccube\Entity\Cart $Cart)
 {
     // 初期選択の配送業者をセット
     $shippings = $Order->getShippings();
     $delivery = $shippings[0]->getDelivery();
     $deliveryFee = $this->app['eccube.repository.delivery_fee']->findOneBy(array('Delivery' => $delivery, 'Pref' => $shippings[0]->getPref()));
     // 配送料金の設定
     $payment = $Order->getPayment();
     if (!is_null($payment)) {
         $Order->setPayment($payment);
         $Order->setPaymentMethod($payment->getMethod());
         $Order->setCharge($payment->getCharge());
     }
     $Order->setDeliveryFeeTotal($deliveryFee->getFee());
     $baseInfo = $this->app['eccube.repository.base_info']->get();
     // 配送料無料条件(合計金額)
     $deliveryFreeAmount = $baseInfo->getDeliveryFreeAmount();
     if (!is_null($deliveryFreeAmount)) {
         // 合計金額が設定金額以上であれば送料無料
         if ($Order->getSubTotal() >= $deliveryFreeAmount) {
             $Order->setDeliveryFeeTotal(0);
         }
     }
     // 配送料無料条件(合計数量)
     $deliveryFreeQuantity = $baseInfo->getDeliveryFreeQuantity();
     if (!is_null($deliveryFreeQuantity)) {
         // 合計数量が設定数量以上であれば送料無料
         if ($Cart->getTotalQuantity() >= $deliveryFreeQuantity) {
             $Order->setDeliveryFeeTotal(0);
         }
     }
     $total = $Order->getSubTotal() + $Order->getCharge() + $Order->getDeliveryFeeTotal();
     $Order->setTotal($total);
     $Order->setPaymentTotal($total);
     $this->app['orm.em']->flush();
     return $Order;
 }
Beispiel #3
0
 /**
  * @param  string $productClassId
  * @return \Eccube\Service\CartService
  */
 public function removeProduct($productClassId)
 {
     $this->cart->removeCartItemByIdentifier('Eccube\\Entity\\ProductClass', (string) $productClassId);
     return $this;
 }