Eccube\Controller\ShoppingController::shipping PHP Method

shipping() public method

お届け先の設定一覧からの選択
public shipping ( Application $app, Request $request, $id )
$app Eccube\Application
$request Symfony\Component\HttpFoundation\Request
    public function shipping(Application $app, Request $request, $id)
    {
        // カートチェック
        if (!$app['eccube.service.cart']->isLocked()) {
            // カートが存在しない、カートがロックされていない時はエラー
            log_info('カートが存在しません');
            return $app->redirect($app->url('cart'));
        }
        if ('POST' === $request->getMethod()) {
            $address = $request->get('address');
            if (is_null($address)) {
                // 選択されていなければエラー
                log_info('お届け先入力チェックエラー');
                return $app->render('Shopping/shipping.twig', array('Customer' => $app->user(), 'shippingId' => $id, 'error' => true));
            }
            // 選択されたお届け先情報を取得
            $CustomerAddress = $app['eccube.repository.customer_address']->findOneBy(array('Customer' => $app->user(), 'id' => $address));
            if (is_null($CustomerAddress)) {
                throw new NotFoundHttpException('選択されたお届け先住所が存在しない');
            }
            $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']);
            if (!$Order) {
                log_info('購入処理中の受注情報がないため購入エラー');
                $app->addError('front.shopping.order.error');
                return $app->redirect($app->url('shopping_error'));
            }
            $Shipping = $Order->findShipping($id);
            if (!$Shipping) {
                throw new NotFoundHttpException('お届け先情報が存在しない');
            }
            log_info('お届先情報更新開始', array($Shipping->getId()));
            // お届け先情報を更新
            $Shipping->setFromCustomerAddress($CustomerAddress);
            // 配送料金の設定
            $app['eccube.service.shopping']->setShippingDeliveryFee($Shipping);
            // 合計金額の再計算
            $Order = $app['eccube.service.shopping']->getAmount($Order);
            // 配送先を更新
            $app['orm.em']->flush();
            $event = new EventArgs(array('Order' => $Order, 'shippingId' => $id), $request);
            $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_SHIPPING_COMPLETE, $event);
            log_info('お届先情報更新完了', array($Shipping->getId()));
            return $app->redirect($app->url('shopping'));
        }
        return $app->render('Shopping/shipping.twig', array('Customer' => $app->user(), 'shippingId' => $id, 'error' => false));
    }