Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like ShoppingController often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use ShoppingController, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
39 | class ShoppingController extends AbstractController |
||
|
|||
40 | { |
||
41 | |||
42 | /** |
||
43 | * @var string 非会員用セッションキー |
||
44 | */ |
||
45 | private $sessionKey = 'eccube.front.shopping.nonmember'; |
||
46 | |||
47 | /** |
||
48 | * @var string 非会員用セッションキー |
||
49 | */ |
||
50 | private $sessionCustomerAddressKey = 'eccube.front.shopping.nonmember.customeraddress'; |
||
51 | |||
52 | /** |
||
53 | * @var string 複数配送警告メッセージ |
||
54 | */ |
||
55 | private $sessionMultipleKey = 'eccube.front.shopping.multiple'; |
||
56 | |||
57 | /** |
||
58 | * @var string 受注IDキー |
||
59 | */ |
||
60 | private $sessionOrderKey = 'eccube.front.shopping.order.id'; |
||
61 | |||
62 | /** |
||
63 | * 購入画面表示 |
||
64 | * |
||
65 | * @param Application $app |
||
66 | * @param Request $request |
||
67 | * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response |
||
68 | */ |
||
69 | 11 | public function index(Application $app, Request $request) |
|
70 | { |
||
71 | $cartService = $app['eccube.service.cart']; |
||
72 | |||
73 | // カートチェック |
||
74 | if (!$cartService->isLocked()) { |
||
75 | // カートが存在しない、カートがロックされていない時はエラー |
||
76 | return $app->redirect($app->url('cart')); |
||
77 | } |
||
78 | |||
79 | // カートチェック |
||
80 | if (count($cartService->getCart()->getCartItems()) <= 0) { |
||
81 | // カートが存在しない時はエラー |
||
82 | return $app->redirect($app->url('cart')); |
||
83 | } |
||
84 | |||
85 | // 登録済みの受注情報を取得 |
||
86 | $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']); |
||
87 | |||
88 | // 初回アクセス(受注情報がない)の場合は, 受注情報を作成 |
||
89 | if (is_null($Order)) { |
||
90 | |||
91 | // 未ログインの場合, ログイン画面へリダイレクト. |
||
92 | if (!$app->isGranted('IS_AUTHENTICATED_FULLY')) { |
||
93 | |||
94 | // 非会員でも一度会員登録されていればショッピング画面へ遷移 |
||
95 | $Customer = $app['eccube.service.shopping']->getNonMember($this->sessionKey); |
||
96 | |||
97 | if (is_null($Customer)) { |
||
98 | return $app->redirect($app->url('shopping_login')); |
||
99 | } |
||
100 | |||
101 | } else { |
||
102 | $Customer = $app->user(); |
||
103 | 7 | } |
|
104 | |||
105 | // 受注情報を作成 |
||
106 | $Order = $app['eccube.service.shopping']->createOrder($Customer); |
||
107 | |||
108 | // セッション情報を削除 |
||
109 | $app['session']->remove($this->sessionOrderKey); |
||
110 | $app['session']->remove($this->sessionMultipleKey); |
||
111 | |||
112 | } else { |
||
113 | // 計算処理 |
||
114 | $Order = $app['eccube.service.shopping']->getAmount($Order); |
||
115 | 8 | } |
|
116 | |||
117 | // 受注関連情報を最新状態に更新 |
||
118 | $app['orm.em']->refresh($Order); |
||
119 | |||
120 | // form作成 |
||
121 | $form = $app['eccube.service.shopping']->getShippingForm($Order); |
||
122 | |||
123 | // 複数配送の場合、エラーメッセージを一度だけ表示 |
||
124 | if (!$app['session']->has($this->sessionMultipleKey)) { |
||
125 | if (count($Order->getShippings()) > 1) { |
||
126 | $app->addRequestError('shopping.multiple.delivery'); |
||
127 | } |
||
128 | $app['session']->set($this->sessionMultipleKey, 'multiple'); |
||
129 | } |
||
130 | |||
131 | |||
132 | 8 | return $app->render('Shopping/index.twig', array( |
|
133 | 8 | 'form' => $form->createView(), |
|
134 | 'Order' => $Order, |
||
135 | )); |
||
136 | 11 | } |
|
137 | |||
138 | /** |
||
139 | * 購入処理 |
||
140 | */ |
||
141 | 3 | public function confirm(Application $app, Request $request) |
|
142 | { |
||
143 | |||
144 | $cartService = $app['eccube.service.cart']; |
||
145 | |||
146 | // カートチェック |
||
147 | if (!$cartService->isLocked()) { |
||
148 | // カートが存在しない、カートがロックされていない時はエラー |
||
149 | return $app->redirect($app->url('cart')); |
||
150 | } |
||
151 | |||
152 | $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']); |
||
153 | 3 | if (!$Order) { |
|
154 | $app->addError('front.shopping.order.error'); |
||
155 | return $app->redirect($app->url('shopping_error')); |
||
156 | } |
||
157 | |||
158 | // form作成 |
||
159 | $form = $app['eccube.service.shopping']->getShippingForm($Order); |
||
160 | |||
161 | if ('POST' === $request->getMethod()) { |
||
162 | $form->handleRequest($request); |
||
163 | |||
164 | if ($form->isValid()) { |
||
165 | $data = $form->getData(); |
||
166 | |||
167 | // トランザクション制御 |
||
168 | $em = $app['orm.em']; |
||
169 | $em->getConnection()->beginTransaction(); |
||
170 | try { |
||
171 | // 商品公開ステータスチェック、商品制限数チェック、在庫チェック |
||
172 | $check = $app['eccube.service.shopping']->isOrderProduct($em, $Order); |
||
173 | 3 | if (!$check) { |
|
174 | $em->getConnection()->rollback(); |
||
175 | $em->close(); |
||
176 | |||
177 | $app->addError('front.shopping.stock.error'); |
||
178 | return $app->redirect($app->url('shopping_error')); |
||
179 | } |
||
180 | |||
181 | // 受注情報、配送情報を更新 |
||
182 | $app['eccube.service.shopping']->setOrderUpdate($Order, $data); |
||
183 | // 在庫情報を更新 |
||
184 | $app['eccube.service.shopping']->setStockUpdate($em, $Order); |
||
185 | |||
186 | if ($app->isGranted('ROLE_USER')) { |
||
187 | // 会員の場合、購入金額を更新 |
||
188 | $app['eccube.service.shopping']->setCustomerUpdate($Order, $app->user()); |
||
189 | } |
||
190 | |||
191 | $em->getConnection()->commit(); |
||
192 | $em->flush(); |
||
193 | |||
194 | } catch (\Exception $e) { |
||
195 | $em->getConnection()->rollback(); |
||
196 | $em->close(); |
||
197 | |||
198 | $app->log($e); |
||
199 | |||
200 | $app->addError('front.shopping.system.error'); |
||
201 | return $app->redirect($app->url('shopping_error')); |
||
202 | 3 | } |
|
203 | |||
204 | // カート削除 |
||
205 | $app['eccube.service.cart']->clear()->save(); |
||
206 | |||
207 | // メール送信 |
||
208 | $app['eccube.service.mail']->sendOrderMail($Order); |
||
209 | |||
210 | // 受注IDをセッションにセット |
||
211 | $app['session']->set($this->sessionOrderKey, $Order->getId()); |
||
212 | |||
213 | // 送信履歴を保存. |
||
214 | $MailTemplate = $app['eccube.repository.mail_template']->find(1); |
||
215 | |||
216 | 3 | $body = $app->renderView($MailTemplate->getFileName(), array( |
|
217 | 3 | 'header' => $MailTemplate->getHeader(), |
|
218 | 3 | 'footer' => $MailTemplate->getFooter(), |
|
219 | 'Order' => $Order, |
||
220 | )); |
||
221 | |||
222 | $MailHistory = new MailHistory(); |
||
223 | $MailHistory |
||
224 | ->setSubject('[' . $app['eccube.repository.base_info']->get()->getShopName() . '] ' . $MailTemplate->getSubject()) |
||
225 | 3 | ->setMailBody($body) |
|
226 | 3 | ->setMailTemplate($MailTemplate) |
|
227 | ->setSendDate(new \DateTime()) |
||
228 | ->setOrder($Order); |
||
229 | $app['orm.em']->persist($MailHistory); |
||
230 | $app['orm.em']->flush($MailHistory); |
||
231 | |||
232 | $em->close(); |
||
233 | |||
234 | // 完了画面表示 |
||
235 | return $app->redirect($app->url('shopping_complete')); |
||
236 | |||
237 | } else { |
||
238 | return $app->render('Shopping/index.twig', array( |
||
239 | 'form' => $form->createView(), |
||
240 | 'Order' => $Order, |
||
241 | )); |
||
242 | } |
||
243 | } |
||
244 | |||
245 | return $app->redirect($app->url('cart')); |
||
246 | |||
247 | 3 | } |
|
248 | |||
249 | |||
250 | /** |
||
251 | * 購入完了画面表示 |
||
252 | */ |
||
253 | 1 | public function complete(Application $app) |
|
254 | { |
||
255 | |||
256 | // 受注IDを取得 |
||
257 | $orderId = $app['session']->get($this->sessionOrderKey); |
||
258 | |||
259 | // 受注IDセッションを削除 |
||
260 | $app['session']->remove($this->sessionOrderKey); |
||
261 | |||
262 | 1 | return $app->render('Shopping/complete.twig', array( |
|
263 | 'orderId' => $orderId, |
||
264 | )); |
||
265 | 1 | } |
|
266 | |||
267 | |||
268 | /** |
||
269 | * 配送業者選択処理 |
||
270 | */ |
||
271 | public function delivery(Application $app, Request $request) |
||
350 | |||
351 | /** |
||
352 | * 支払い方法選択処理 |
||
353 | */ |
||
354 | public function payment(Application $app, Request $request) |
||
398 | |||
399 | /** |
||
400 | * お届け先変更がクリックされた場合の処理 |
||
401 | */ |
||
402 | View Code Duplication | public function shippingChange(Application $app, Request $request, $id) |
|
433 | |||
434 | /** |
||
435 | * お届け先の設定一覧からの選択 |
||
436 | */ |
||
437 | public function shipping(Application $app, Request $request, $id) |
||
438 | { |
||
439 | |||
440 | // カートチェック |
||
441 | if (!$app['eccube.service.cart']->isLocked()) { |
||
442 | // カートが存在しない、カートがロックされていない時はエラー |
||
443 | return $app->redirect($app->url('cart')); |
||
444 | } |
||
445 | |||
446 | if ('POST' === $request->getMethod()) { |
||
447 | $address = $request->get('address'); |
||
448 | |||
449 | if (is_null($address)) { |
||
450 | // 選択されていなければエラー |
||
451 | return $app->render( |
||
452 | 'Shopping/shipping.twig', |
||
453 | array( |
||
454 | 'Customer' => $app->user(), |
||
455 | 'shippingId' => $id, |
||
456 | 'error' => true, |
||
457 | ) |
||
458 | ); |
||
459 | } |
||
460 | |||
461 | // 選択されたお届け先情報を取得 |
||
462 | $CustomerAddress = $app['eccube.repository.customer_address']->findOneBy(array( |
||
463 | 'Customer' => $app->user(), |
||
464 | 'id' => $address, |
||
465 | )); |
||
466 | if (is_null($CustomerAddress)) { |
||
467 | throw new NotFoundHttpException(); |
||
468 | } |
||
469 | |||
470 | $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']); |
||
471 | if (!$Order) { |
||
472 | $app->addError('front.shopping.order.error'); |
||
473 | |||
474 | return $app->redirect($app->url('shopping_error')); |
||
475 | } |
||
476 | |||
477 | $Shipping = $Order->findShipping($id); |
||
478 | if (!$Shipping) { |
||
479 | throw new NotFoundHttpException(); |
||
480 | } |
||
481 | |||
482 | // お届け先情報を更新 |
||
483 | $Shipping |
||
484 | ->setName01($CustomerAddress->getName01()) |
||
485 | ->setName02($CustomerAddress->getName02()) |
||
486 | ->setKana01($CustomerAddress->getKana01()) |
||
487 | ->setKana02($CustomerAddress->getKana02()) |
||
488 | ->setCompanyName($CustomerAddress->getCompanyName()) |
||
489 | ->setTel01($CustomerAddress->getTel01()) |
||
490 | ->setTel02($CustomerAddress->getTel02()) |
||
491 | ->setTel03($CustomerAddress->getTel03()) |
||
492 | ->setFax01($CustomerAddress->getFax01()) |
||
493 | ->setFax02($CustomerAddress->getFax02()) |
||
494 | ->setFax03($CustomerAddress->getFax03()) |
||
495 | ->setZip01($CustomerAddress->getZip01()) |
||
496 | ->setZip02($CustomerAddress->getZip02()) |
||
497 | ->setZipCode($CustomerAddress->getZip01() . $CustomerAddress->getZip02()) |
||
498 | ->setPref($CustomerAddress->getPref()) |
||
499 | ->setAddr01($CustomerAddress->getAddr01()) |
||
500 | ->setAddr02($CustomerAddress->getAddr02()); |
||
501 | |||
502 | // 配送料金の設定 |
||
503 | $app['eccube.service.shopping']->setShippingDeliveryFee($Shipping); |
||
504 | |||
505 | // 配送先を更新 |
||
506 | $app['orm.em']->flush(); |
||
507 | |||
508 | return $app->redirect($app->url('shopping')); |
||
509 | |||
510 | } |
||
511 | |||
512 | return $app->render( |
||
513 | 'Shopping/shipping.twig', |
||
514 | array( |
||
515 | 'Customer' => $app->user(), |
||
516 | 'shippingId' => $id, |
||
517 | 'error' => false, |
||
518 | ) |
||
519 | ); |
||
520 | } |
||
521 | |||
522 | /** |
||
523 | * お届け先の設定(非会員)がクリックされた場合の処理 |
||
524 | */ |
||
525 | 5 | View Code Duplication | public function shippingEditChange(Application $app, Request $request, $id) |
526 | { |
||
527 | $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']); |
||
528 | 5 | if (!$Order) { |
|
529 | $app->addError('front.shopping.order.error'); |
||
530 | return $app->redirect($app->url('shopping_error')); |
||
531 | } |
||
532 | |||
533 | $form = $app['eccube.service.shopping']->getShippingForm($Order); |
||
534 | |||
535 | if ('POST' === $request->getMethod()) { |
||
536 | $form->handleRequest($request); |
||
537 | |||
538 | if ($form->isValid()) { |
||
539 | $data = $form->getData(); |
||
540 | 3 | $message = $data['message']; |
|
541 | $Order->setMessage($message); |
||
542 | // 受注情報を更新 |
||
543 | $app['orm.em']->flush(); |
||
544 | // お届け先設定一覧へリダイレクト |
||
545 | return $app->redirect($app->url('shopping_shipping_edit', array('id' => $id))); |
||
546 | } else { |
||
547 | 1 | return $app->render('Shopping/index.twig', array( |
|
548 | 1 | 'form' => $form->createView(), |
|
549 | 'Order' => $Order, |
||
550 | )); |
||
551 | } |
||
552 | } |
||
553 | |||
554 | return $app->redirect($app->url('shopping')); |
||
555 | 5 | } |
|
556 | |||
557 | |||
558 | /** |
||
559 | * お届け先の設定(非会員でも使用する) |
||
560 | */ |
||
561 | 2 | public function shippingEdit(Application $app, Request $request, $id) |
|
562 | { |
||
563 | // 配送先住所最大値判定 |
||
564 | $Customer = $app->user(); |
||
565 | 2 | View Code Duplication | if ($Customer instanceof Customer) { |
566 | error_log("hoge"); |
||
567 | $addressCurrNum = count($app->user()->getCustomerAddresses()); |
||
568 | $addressMax = $app['config']['deliv_addr_max']; |
||
569 | if ($addressCurrNum >= $addressMax) { |
||
570 | throw new NotFoundHttpException(); |
||
571 | } |
||
572 | } |
||
573 | |||
574 | // カートチェック |
||
575 | if (!$app['eccube.service.cart']->isLocked()) { |
||
576 | // カートが存在しない、カートがロックされていない時はエラー |
||
577 | return $app->redirect($app->url('cart')); |
||
578 | } |
||
579 | |||
580 | |||
581 | $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']); |
||
582 | 2 | if (!$Order) { |
|
583 | $app->addError('front.shopping.order.error'); |
||
584 | return $app->redirect($app->url('shopping_error')); |
||
585 | } |
||
586 | |||
587 | $Shipping = $Order->findShipping($id); |
||
588 | 2 | if (!$Shipping) { |
|
589 | throw new NotFoundHttpException(); |
||
590 | } |
||
591 | |||
592 | // 会員の場合、お届け先情報を新規登録 |
||
593 | if ($app->isGranted('IS_AUTHENTICATED_FULLY')) { |
||
594 | $builder = $app['form.factory']->createBuilder('shopping_shipping'); |
||
595 | } else { |
||
596 | // 非会員の場合、お届け先を追加 |
||
597 | $builder = $app['form.factory']->createBuilder('shopping_shipping', $Shipping); |
||
598 | } |
||
599 | |||
600 | $form = $builder->getForm(); |
||
601 | |||
602 | if ('POST' === $request->getMethod()) { |
||
603 | |||
604 | $form->handleRequest($request); |
||
605 | |||
606 | if ($form->isValid()) { |
||
607 | $data = $form->getData(); |
||
608 | |||
609 | // 会員の場合、お届け先情報を新規登録 |
||
610 | if ($app->isGranted('IS_AUTHENTICATED_FULLY')) { |
||
611 | $CustomerAddress = new CustomerAddress(); |
||
612 | $CustomerAddress |
||
613 | ->setCustomer($app->user()) |
||
614 | ->setName01($data['name01']) |
||
615 | ->setName02($data['name02']) |
||
616 | ->setKana01($data['kana01']) |
||
617 | ->setKana02($data['kana02']) |
||
618 | ->setCompanyName($data['company_name']) |
||
619 | ->setTel01($data['tel01']) |
||
620 | ->setTel02($data['tel02']) |
||
621 | ->setTel03($data['tel03']) |
||
622 | ->setZip01($data['zip01']) |
||
623 | ->setZip02($data['zip02']) |
||
624 | ->setZipCode($data['zip01'] . $data['zip02']) |
||
625 | ->setPref($data['pref']) |
||
626 | ->setAddr01($data['addr01']) |
||
627 | ->setAddr02($data['addr02']) |
||
628 | ->setDelFlg(Constant::DISABLED); |
||
629 | |||
630 | $app['orm.em']->persist($CustomerAddress); |
||
631 | |||
632 | } |
||
633 | |||
634 | $Shipping |
||
635 | ->setName01($data['name01']) |
||
636 | ->setName02($data['name02']) |
||
637 | ->setKana01($data['kana01']) |
||
638 | ->setKana02($data['kana02']) |
||
639 | ->setCompanyName($data['company_name']) |
||
640 | ->setTel01($data['tel01']) |
||
641 | ->setTel02($data['tel02']) |
||
642 | ->setTel03($data['tel03']) |
||
643 | ->setZip01($data['zip01']) |
||
644 | ->setZip02($data['zip02']) |
||
645 | ->setZipCode($data['zip01'] . $data['zip02']) |
||
646 | ->setPref($data['pref']) |
||
647 | ->setAddr01($data['addr01']) |
||
648 | ->setAddr02($data['addr02']); |
||
649 | |||
650 | // 配送料金の設定 |
||
651 | $app['eccube.service.shopping']->setShippingDeliveryFee($Shipping); |
||
652 | |||
653 | // 配送先を更新 |
||
654 | $app['orm.em']->flush(); |
||
655 | |||
656 | return $app->redirect($app->url('shopping')); |
||
657 | |||
658 | } |
||
659 | } |
||
660 | |||
661 | 1 | return $app->render('Shopping/shipping_edit.twig', array( |
|
662 | 1 | 'form' => $form->createView(), |
|
663 | 'shippingId' => $id, |
||
664 | )); |
||
665 | |||
666 | 2 | } |
|
667 | |||
668 | /** |
||
669 | * お客様情報の変更(非会員) |
||
670 | */ |
||
671 | public function customer(Application $app, Request $request) |
||
739 | |||
740 | |||
741 | /** |
||
742 | * ログイン |
||
743 | */ |
||
744 | 2 | public function login(Application $app, Request $request) |
|
772 | |||
773 | /** |
||
774 | * 非会員処理 |
||
775 | */ |
||
776 | 11 | public function nonmember(Application $app, Request $request) |
|
777 | { |
||
778 | |||
779 | $cartService = $app['eccube.service.cart']; |
||
780 | |||
781 | // カートチェック |
||
782 | if (!$cartService->isLocked()) { |
||
783 | // カートが存在しない、カートがロックされていない時はエラー |
||
784 | return $app->redirect($app->url('cart')); |
||
785 | } |
||
786 | |||
787 | // ログイン済みの場合は, 購入画面へリダイレクト. |
||
788 | if ($app->isGranted('ROLE_USER')) { |
||
789 | return $app->redirect($app->url('shopping')); |
||
790 | } |
||
791 | |||
792 | // カートチェック |
||
793 | if (count($cartService->getCart()->getCartItems()) <= 0) { |
||
794 | // カートが存在しない時はエラー |
||
795 | return $app->redirect($app->url('cart')); |
||
796 | } |
||
797 | |||
798 | $form = $app['form.factory']->createBuilder('nonmember')->getForm(); |
||
799 | |||
800 | if ('POST' === $request->getMethod()) { |
||
801 | $form->handleRequest($request); |
||
802 | if ($form->isValid()) { |
||
803 | $data = $form->getData(); |
||
804 | $Customer = new Customer(); |
||
805 | $Customer |
||
806 | 8 | ->setName01($data['name01']) |
|
807 | 8 | ->setName02($data['name02']) |
|
808 | 8 | ->setKana01($data['kana01']) |
|
809 | 8 | ->setKana02($data['kana02']) |
|
810 | 8 | ->setCompanyName($data['company_name']) |
|
811 | 8 | ->setEmail($data['email']) |
|
812 | 8 | ->setTel01($data['tel01']) |
|
813 | 8 | ->setTel02($data['tel02']) |
|
814 | 8 | ->setTel03($data['tel03']) |
|
815 | 8 | ->setZip01($data['zip01']) |
|
816 | 8 | ->setZip02($data['zip02']) |
|
817 | 8 | ->setZipCode($data['zip01'] . $data['zip02']) |
|
818 | 8 | ->setPref($data['pref']) |
|
819 | 8 | ->setAddr01($data['addr01']) |
|
820 | ->setAddr02($data['addr02']); |
||
821 | |||
822 | // 非会員複数配送用 |
||
823 | $CustomerAddress = new CustomerAddress(); |
||
824 | $CustomerAddress |
||
825 | 8 | ->setCustomer($Customer) |
|
826 | 8 | ->setName01($data['name01']) |
|
827 | 8 | ->setName02($data['name02']) |
|
828 | 8 | ->setKana01($data['kana01']) |
|
829 | 8 | ->setKana02($data['kana02']) |
|
830 | 8 | ->setCompanyName($data['company_name']) |
|
831 | 8 | ->setTel01($data['tel01']) |
|
832 | 8 | ->setTel02($data['tel02']) |
|
833 | 8 | ->setTel03($data['tel03']) |
|
834 | 8 | ->setZip01($data['zip01']) |
|
835 | 8 | ->setZip02($data['zip02']) |
|
836 | 8 | ->setZipCode($data['zip01'] . $data['zip02']) |
|
837 | 8 | ->setPref($data['pref']) |
|
838 | 8 | ->setAddr01($data['addr01']) |
|
839 | 8 | ->setAddr02($data['addr02']) |
|
840 | ->setDelFlg(Constant::DISABLED); |
||
841 | $Customer->addCustomerAddress($CustomerAddress); |
||
842 | |||
843 | // 受注情報を取得 |
||
844 | $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']); |
||
845 | |||
846 | // 初回アクセス(受注データがない)の場合は, 受注情報を作成 |
||
847 | if (is_null($Order)) { |
||
848 | // 受注情報を作成 |
||
849 | $app['eccube.service.shopping']->createOrder($Customer); |
||
850 | } |
||
851 | |||
852 | // 非会員用セッションを作成 |
||
853 | 8 | $nonMember = array(); |
|
854 | 8 | $nonMember['customer'] = $Customer; |
|
855 | $nonMember['pref'] = $Customer->getPref()->getId(); |
||
856 | $app['session']->set($this->sessionKey, $nonMember); |
||
857 | |||
858 | 8 | $customerAddresses = array(); |
|
859 | 8 | $customerAddresses[] = $CustomerAddress; |
|
860 | $app['session']->set($this->sessionCustomerAddressKey, serialize($customerAddresses)); |
||
861 | |||
862 | return $app->redirect($app->url('shopping')); |
||
863 | |||
864 | } |
||
865 | } |
||
866 | |||
867 | 1 | return $app->render('Shopping/nonmember.twig', array( |
|
868 | 1 | 'form' => $form->createView(), |
|
869 | )); |
||
870 | 11 | } |
|
871 | |||
872 | /** |
||
873 | * 複数配送処理がクリックされた場合の処理 |
||
874 | */ |
||
875 | View Code Duplication | public function shippingMultipleChange(Application $app, Request $request) |
|
906 | |||
907 | |||
908 | /** |
||
909 | * 複数配送処理 |
||
910 | */ |
||
911 | public function shippingMultiple(Application $app, Request $request) |
||
1120 | |||
1121 | /** |
||
1122 | * 非会員用複数配送設定時の新規お届け先の設定 |
||
1123 | */ |
||
1124 | public function shippingMultipleEdit(Application $app, Request $request) |
||
1182 | |||
1183 | /** |
||
1184 | * 購入エラー画面表示 |
||
1185 | */ |
||
1186 | 1 | public function shoppingError(Application $app) |
|
1187 | { |
||
1188 | return $app->render('Shopping/shopping_error.twig'); |
||
1189 | 1 | } |
|
1190 | |||
1191 | /** |
||
1192 | * 非会員でのお客様情報変更時の入力チェック |
||
1193 | */ |
||
1194 | private function customerValidation($app, $data) { |
||
1263 | |||
1264 | } |
||
1265 |