/** * クーポンが利用されていないかチェック * */ public function onControllerShoppingConfirmBefore($event = null) { $cartService = $this->app['eccube.service.cart']; $preOrderId = $cartService->getPreOrderId(); if (is_null($preOrderId)) { return; } $repository = $this->app['eccube.plugin.coupon.repository.coupon_order']; // クーポン受注情報を取得する $CouponOrder = $repository->findOneBy(array('pre_order_id' => $preOrderId)); if (!$CouponOrder) { return; } if ($this->app->isGranted('ROLE_USER')) { $Customer = $this->app->user(); } else { $Customer = $this->app['eccube.service.shopping']->getNonMember($this->sessionKey); } // クーポンが既に利用されているかチェック $couponUsedOrNot = $this->app['eccube.plugin.coupon.service.coupon']->checkCouponUsedOrNotBefore($CouponOrder->getCouponCd(), $CouponOrder->getOrderId(), $Customer); if ($couponUsedOrNot) { $this->app->addError($this->app->trans('front.plugin.coupon.shopping.sameuser'), 'front.request'); // 既に存在している if (is_null($event)) { header("Location: " . $this->app->url('shopping')); exit; } else { $response = $this->redirect($this->app->url('shopping')); $event->setResponse($response); return; } } }
public function login(Application $app, Request $request) { if ($app->isGranted('IS_AUTHENTICATED_FULLY')) { return $app->redirect($app->url('mypage')); } /* @var $form \Symfony\Component\Form\FormInterface */ $builder = $app['form.factory']->createNamedBuilder('', 'customer_login'); if ($app->isGranted('IS_AUTHENTICATED_REMEMBERED')) { $Customer = $app->user(); if ($Customer) { $builder->get('login_email')->setData($Customer->getEmail()); } } $form = $builder->getForm(); return $app->render('Mypage/login.twig', array('error' => $app['security.last_error']($request), 'form' => $form->createView())); }
public function index(Application $app, Request $request) { /* @var $builder \Symfony\Component\Form\FormBuilderInterface */ $builder = $app['form.factory']->createBuilder('contact'); /* @var $form \Symfony\Component\Form\FormInterface */ $form = $builder->getForm(); if ($app->isGranted('ROLE_USER')) { /* @var $user \Eccube\Entity\Customer */ $user = $app['user']; $form->setData(array('name01' => $user->getName01(), 'name02' => $user->getName02(), 'kana01' => $user->getKana01(), 'kana02' => $user->getKana02(), 'zip01' => $user->getZip01(), 'zip02' => $user->getZip02(), 'pref' => $user->getPref(), 'addr01' => $user->getAddr01(), 'addr02' => $user->getAddr02(), 'tel01' => $user->getTel01(), 'tel02' => $user->getTel02(), 'tel03' => $user->getTel03(), 'email' => $user->getEmail())); } $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { switch ($request->get('mode')) { case 'confirm': $builder->setAttribute('freeze', true); $form = $builder->getForm(); $form->handleRequest($request); return $app->render('Contact/confirm.twig', array('form' => $form->createView())); case 'complete': // メール送信 $app['eccube.service.mail']->sendContactMail($form->getData()); return $app->redirect($app->url('contact_complete')); } } return $app->render('Contact/index.twig', array('form' => $form->createView())); }
/** * お問い合わせ画面. * * @param Application $app * @param Request $request * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response */ public function index(Application $app, Request $request) { $builder = $app['form.factory']->createBuilder('contact'); if ($app->isGranted('ROLE_USER')) { $user = $app['user']; $builder->setData(array('name01' => $user->getName01(), 'name02' => $user->getName02(), 'kana01' => $user->getKana01(), 'kana02' => $user->getKana02(), 'zip01' => $user->getZip01(), 'zip02' => $user->getZip02(), 'pref' => $user->getPref(), 'addr01' => $user->getAddr01(), 'addr02' => $user->getAddr02(), 'tel01' => $user->getTel01(), 'tel02' => $user->getTel02(), 'tel03' => $user->getTel03(), 'email' => $user->getEmail())); } // FRONT_CONTACT_INDEX_INITIALIZE $event = new EventArgs(array('builder' => $builder), $request); $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CONTACT_INDEX_INITIALIZE, $event); $form = $builder->getForm(); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { switch ($request->get('mode')) { case 'confirm': $builder->setAttribute('freeze', true); $form = $builder->getForm(); $form->handleRequest($request); $title = 'お問い合わせ(確認ページ)'; return $app->render('Contact/confirm.twig', array('form' => $form->createView(), 'title' => $title)); case 'complete': $data = $form->getData(); $event = new EventArgs(array('form' => $form, 'data' => $data), $request); $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CONTACT_INDEX_COMPLETE, $event); $data = $event->getArgument('data'); // メール送信 $app['eccube.service.mail']->sendContactMail($data); return $app->redirect($app->url('contact_complete')); } } return $app->render('Contact/index.twig', array('form' => $form->createView())); }
/** * ログイン画面. * * @param Application $app * @param Request $request * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response */ public function login(Application $app, Request $request) { if ($app->isGranted('IS_AUTHENTICATED_FULLY')) { return $app->redirect($app->url('mypage')); } /* @var $form \Symfony\Component\Form\FormInterface */ $builder = $app['form.factory']->createNamedBuilder('', 'customer_login'); if ($app->isGranted('IS_AUTHENTICATED_REMEMBERED')) { $Customer = $app->user(); if ($Customer) { $builder->get('login_email')->setData($Customer->getEmail()); } } $event = new EventArgs(array('builder' => $builder), $request); $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_MYPAGE_MYPAGE_LOGIN_INITIALIZE, $event); $form = $builder->getForm(); return $app->render('Mypage/login.twig', array('error' => $app['security.last_error']($request), 'form' => $form->createView())); }
public function login(Application $app, Request $request) { if ($app->isGranted('ROLE_ADMIN')) { return $app->redirect($app->url('admin_homepage')); } /* @var $form \Symfony\Component\Form\FormInterface */ $form = $app['form.factory']->createNamedBuilder('', 'admin_login')->getForm(); return $app['view']->render('login.twig', array('error' => $app['security.last_error']($request), 'form' => $form->createView())); }
/** * 会員登録画面. * * @param Application $app * @param Request $request * @return \Symfony\Component\HttpFoundation\Response */ public function index(Application $app, Request $request) { if ($app->isGranted('ROLE_USER')) { log_info('認証済のためログイン処理をスキップ'); return $app->redirect($app->url('mypage')); } /** @var $Customer \Eccube\Entity\Customer */ $Customer = $app['eccube.repository.customer']->newCustomer(); /* @var $builder \Symfony\Component\Form\FormBuilderInterface */ $builder = $app['form.factory']->createBuilder('entry', $Customer); $event = new EventArgs(array('builder' => $builder, 'Customer' => $Customer), $request); $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_ENTRY_INDEX_INITIALIZE, $event); /* @var $form \Symfony\Component\Form\FormInterface */ $form = $builder->getForm(); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { switch ($request->get('mode')) { case 'confirm': log_info('会員登録確認開始'); $builder->setAttribute('freeze', true); $form = $builder->getForm(); $form->handleRequest($request); log_info('会員登録確認完了'); return $app->render('Entry/confirm.twig', array('form' => $form->createView())); case 'complete': log_info('会員登録開始'); $Customer->setSalt($app['eccube.repository.customer']->createSalt(5))->setPassword($app['eccube.repository.customer']->encryptPassword($app, $Customer))->setSecretKey($app['eccube.repository.customer']->getUniqueSecretKey($app)); $CustomerAddress = new \Eccube\Entity\CustomerAddress(); $CustomerAddress->setFromCustomer($Customer); $app['orm.em']->persist($Customer); $app['orm.em']->persist($CustomerAddress); $app['orm.em']->flush(); log_info('会員登録完了'); $event = new EventArgs(array('form' => $form, 'Customer' => $Customer, 'CustomerAddress' => $CustomerAddress), $request); $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_ENTRY_INDEX_COMPLETE, $event); $activateUrl = $app->url('entry_activate', array('secret_key' => $Customer->getSecretKey())); /** @var $BaseInfo \Eccube\Entity\BaseInfo */ $BaseInfo = $app['eccube.repository.base_info']->get(); $activateFlg = $BaseInfo->getOptionCustomerActivate(); // 仮会員設定が有効な場合は、確認メールを送信し完了画面表示. if ($activateFlg) { // メール送信 $app['eccube.service.mail']->sendCustomerConfirmMail($Customer, $activateUrl); if ($event->hasResponse()) { return $event->getResponse(); } log_info('仮会員登録完了画面へリダイレクト'); return $app->redirect($app->url('entry_complete')); // 仮会員設定が無効な場合は認証URLへ遷移させ、会員登録を完了させる. } else { log_info('本会員登録画面へリダイレクト'); return $app->redirect($activateUrl); } } } return $app->render('Entry/index.twig', array('form' => $form->createView())); }
public function login(Application $app, Request $request) { if ($app->isGranted('ROLE_ADMIN')) { return $app->redirect($app->url('admin_homepage')); } /* @var $form \Symfony\Component\Form\FormInterface */ $builder = $app['form.factory']->createNamedBuilder('', 'admin_login'); $event = new EventArgs(array('builder' => $builder), $request); $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_ADMIM_LOGIN_INITIALIZE, $event); $form = $builder->getForm(); return $app->render('login.twig', array('error' => $app['security.last_error']($request), 'form' => $form->createView())); }
/** * お届け先情報を作成 * * @param \Eccube\Entity\Shipping $Shipping * @param \Eccube\Entity\Customer|null $Customer * @return \Eccube\Entity\Shipping */ public function copyToShippingFromCustomer(Shipping $Shipping, Customer $Customer = null) { if (is_null($Customer)) { return $Shipping; } $CustomerAddress = $this->app['eccube.repository.customer_address']->findOneBy(array('Customer' => $Customer)); if ($this->app->isGranted('ROLE_USER')) { $Shipping->setName01($CustomerAddress->getName01())->setName02($CustomerAddress->getName02())->setKana01($CustomerAddress->getKana01())->setKana02($CustomerAddress->getKana02())->setCompanyName($CustomerAddress->getCompanyName())->setTel01($CustomerAddress->getTel01())->setTel02($CustomerAddress->getTel02())->setTel03($CustomerAddress->getTel03())->setFax01($CustomerAddress->getFax01())->setFax02($CustomerAddress->getFax02())->setFax03($CustomerAddress->getFax03())->setZip01($CustomerAddress->getZip01())->setZip02($CustomerAddress->getZip02())->setZipCode($CustomerAddress->getZip01() . $CustomerAddress->getZip02())->setPref($CustomerAddress->getPref())->setAddr01($CustomerAddress->getAddr01())->setAddr02($CustomerAddress->getAddr02()); } else { $Shipping->setName01($Customer->getName01())->setName02($Customer->getName02())->setKana01($Customer->getKana01())->setKana02($Customer->getKana02())->setCompanyName($Customer->getCompanyName())->setTel01($Customer->getTel01())->setTel02($Customer->getTel02())->setTel03($Customer->getTel03())->setFax01($Customer->getFax01())->setFax02($Customer->getFax02())->setFax03($Customer->getFax03())->setZip01($Customer->getZip01())->setZip02($Customer->getZip02())->setZipCode($Customer->getZip01() . $Customer->getZip02())->setPref($Customer->getPref())->setAddr01($Customer->getAddr01())->setAddr02($Customer->getAddr02()); } return $Shipping; }
/** * 購入処理を行う * * @param Order $Order * @throws ShoppingException */ public function processPurchase(Order $Order) { $em = $this->app['orm.em']; // 合計金額の再計算 $this->calculatePrice($Order); // 商品公開ステータスチェック、商品制限数チェック、在庫チェック $check = $this->isOrderProduct($em, $Order); if (!$check) { throw new ShoppingException('front.shopping.stock.error'); } // 受注情報、配送情報を更新 $Order = $this->calculateDeliveryFee($Order); $this->setOrderUpdateData($Order); // 在庫情報を更新 $this->setStockUpdate($em, $Order); if ($this->app->isGranted('ROLE_USER')) { // 会員の場合、購入金額を更新 $this->setCustomerUpdate($Order, $this->app->user()); } }
/** * ユーザはクーポン1回のみ利用できる * * @param $couponCd * @param $orderId * @param Customer $Customer * @return bool */ public function checkCouponUsedOrNotBefore($couponCd, $orderId, Customer $Customer) { $repository = $this->app['eccube.plugin.coupon.repository.coupon_order']; if ($this->app->isGranted('ROLE_USER')) { $CouponOrders = $repository->findUseCouponBefore($couponCd, $orderId, $Customer->getId()); } else { $CouponOrders = $repository->findUseCouponBefore($couponCd, $orderId, $Customer->getEmail()); } if ($CouponOrders) { // 存在すれば既に受注として利用されていないかチェック foreach ($CouponOrders as $CouponOrder) { $Order = $this->app['eccube.repository.order']->find($CouponOrder->getOrderId()); if ($Order) { if ($Order->getOrderStatus()->getId() != $this->app['config']['order_processing']) { // 同一のクーポンコードで既に受注データが存在している return true; } } } } return false; }
/** * 非会員処理 */ public function nonmember(Application $app, Request $request) { $cartService = $app['eccube.service.cart']; // カートチェック if (!$cartService->isLocked()) { // カートが存在しない、カートがロックされていない時はエラー return $app->redirect($app->url('cart')); } // ログイン済みの場合は, 購入画面へリダイレクト. if ($app->isGranted('ROLE_USER')) { return $app->redirect($app->url('shopping')); } // カートチェック if (count($cartService->getCart()->getCartItems()) <= 0) { // カートが存在しない時はエラー return $app->redirect($app->url('cart')); } $form = $app['form.factory']->createBuilder('nonmember')->getForm(); if ('POST' === $request->getMethod()) { $form->handleRequest($request); if ($form->isValid()) { $data = $form->getData(); $Customer = new \Eccube\Entity\Customer(); $Customer->setName01($data['name01'])->setName02($data['name02'])->setKana01($data['kana01'])->setKana02($data['kana02'])->setCompanyName($data['company_name'])->setEmail($data['email'])->setTel01($data['tel01'])->setTel02($data['tel02'])->setTel03($data['tel03'])->setZip01($data['zip01'])->setZip02($data['zip02'])->setZipCode($data['zip01'] . $data['zip02'])->setPref($data['pref'])->setAddr01($data['addr01'])->setAddr02($data['addr02']); // 受注関連情報を取得 $preOrderId = $cartService->getPreOrderId(); $Order = $app['eccube.repository.order']->findOneBy(array('pre_order_id' => $preOrderId, 'OrderStatus' => $app['config']['order_processing'])); // 初回アクセス(受注データがない)の場合は, 受注データを作成 if (is_null($Order)) { // ランダムなpre_order_idを作成 $preOrderId = sha1(uniqid(mt_rand(), true)); // 受注情報、受注明細情報、お届け先情報、配送商品情報を作成 $app['eccube.service.order']->registerPreOrderFromCartItems($cartService->getCart()->getCartItems(), $Customer, $preOrderId); $cartService->setPreOrderId($preOrderId); $cartService->save(); } // 非会員用セッションを作成 $arr = array(); $arr['customer'] = $Customer; $arr['pref'] = $Customer->getPref()->getId(); $app['session']->set('eccube.front.shopping.nonmember', $arr); return $app->redirect($app->url('shopping')); } } return $app->render('Shopping/nonmember.twig', array('form' => $form->createView())); }
public function detail(Application $app, Request $request, $id) { $BaseInfo = $app['eccube.repository.base_info']->get(); if ($BaseInfo->getNostockHidden() === Constant::ENABLED) { $app['orm.em']->getFilters()->enable('nostock_hidden'); } /* @var $Product \Eccube\Entity\Product */ $Product = $app['eccube.repository.product']->get($id); if (!$request->getSession()->has('_security_admin') && $Product->getStatus()->getId() !== 1) { throw new NotFoundHttpException(); } if (count($Product->getProductClasses()) < 1) { throw new NotFoundHttpException(); } /* @var $builder \Symfony\Component\Form\FormBuilderInterface */ $builder = $app['form.factory']->createNamedBuilder('', 'add_cart', null, array('product' => $Product, 'id_add_product_id' => false)); /* @var $form \Symfony\Component\Form\FormInterface */ $form = $builder->getForm(); if ($request->getMethod() === 'POST') { $form->handleRequest($request); if ($form->isValid()) { $addCartData = $form->getData(); if ($addCartData['mode'] === 'add_favorite') { if ($app->isGranted('ROLE_USER')) { $Customer = $app->user(); $app['eccube.repository.customer_favorite_product']->addFavorite($Customer, $Product); $app['session']->getFlashBag()->set('product_detail.just_added_favorite', $Product->getId()); return $app->redirect($app->url('product_detail', array('id' => $Product->getId()))); } else { // 非会員の場合、ログイン画面を表示 // ログイン後の画面遷移先を設定 $app->setLoginTargetPath($app->url('product_detail', array('id' => $Product->getId()))); $app['session']->getFlashBag()->set('eccube.add.favorite', true); return $app->redirect($app->url('mypage_login')); } } else { try { $app['eccube.service.cart']->addProduct($addCartData['product_class_id'], $addCartData['quantity'])->save(); } catch (CartException $e) { $app->addRequestError($e->getMessage()); } return $app->redirect($app->url('cart')); } } } else { $addFavorite = $app['session']->getFlashBag()->get('eccube.add.favorite'); if (!empty($addFavorite)) { // お気に入り登録時にログインされていない場合、ログイン後にお気に入り追加処理を行う if ($app->isGranted('ROLE_USER')) { $Customer = $app->user(); $app['eccube.repository.customer_favorite_product']->addFavorite($Customer, $Product); $app['session']->getFlashBag()->set('product_detail.just_added_favorite', $Product->getId()); } } } $is_favorite = false; if ($app->isGranted('ROLE_USER')) { $Customer = $app->user(); $is_favorite = $app['eccube.repository.customer_favorite_product']->isFavorite($Customer, $Product); } return $app->render('Product/detail.twig', array('title' => $this->title, 'subtitle' => $Product->getName(), 'form' => $form->createView(), 'Product' => $Product, 'is_favorite' => $is_favorite)); }
/** * 非会員処理 */ public function nonmember(Application $app, Request $request) { $cartService = $app['eccube.service.cart']; // カートチェック if (!$cartService->isLocked()) { // カートが存在しない、カートがロックされていない時はエラー return $app->redirect($app->url('cart')); } // ログイン済みの場合は, 購入画面へリダイレクト. if ($app->isGranted('ROLE_USER')) { return $app->redirect($app->url('shopping')); } // カートチェック if (count($cartService->getCart()->getCartItems()) <= 0) { // カートが存在しない時はエラー return $app->redirect($app->url('cart')); } $form = $app['form.factory']->createBuilder('nonmember')->getForm(); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $data = $form->getData(); $Customer = new Customer(); $Customer->setName01($data['name01'])->setName02($data['name02'])->setKana01($data['kana01'])->setKana02($data['kana02'])->setCompanyName($data['company_name'])->setEmail($data['email'])->setTel01($data['tel01'])->setTel02($data['tel02'])->setTel03($data['tel03'])->setZip01($data['zip01'])->setZip02($data['zip02'])->setZipCode($data['zip01'] . $data['zip02'])->setPref($data['pref'])->setAddr01($data['addr01'])->setAddr02($data['addr02']); // 非会員複数配送用 $CustomerAddress = new CustomerAddress(); $CustomerAddress->setCustomer($Customer)->setName01($data['name01'])->setName02($data['name02'])->setKana01($data['kana01'])->setKana02($data['kana02'])->setCompanyName($data['company_name'])->setTel01($data['tel01'])->setTel02($data['tel02'])->setTel03($data['tel03'])->setZip01($data['zip01'])->setZip02($data['zip02'])->setZipCode($data['zip01'] . $data['zip02'])->setPref($data['pref'])->setAddr01($data['addr01'])->setAddr02($data['addr02'])->setDelFlg(Constant::DISABLED); $Customer->addCustomerAddress($CustomerAddress); // 受注情報を取得 $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']); // 初回アクセス(受注データがない)の場合は, 受注情報を作成 if (is_null($Order)) { // 受注情報を作成 try { // 受注情報を作成 $app['eccube.service.shopping']->createOrder($Customer); } catch (CartException $e) { $app->addRequestError($e->getMessage()); return $app->redirect($app->url('cart')); } } // 非会員用セッションを作成 $nonMember = array(); $nonMember['customer'] = $Customer; $nonMember['pref'] = $Customer->getPref()->getId(); $app['session']->set($this->sessionKey, $nonMember); $customerAddresses = array(); $customerAddresses[] = $CustomerAddress; $app['session']->set($this->sessionCustomerAddressKey, serialize($customerAddresses)); return $app->redirect($app->url('shopping')); } return $app->render('Shopping/nonmember.twig', array('form' => $form->createView())); }
public function detail(Application $app, Request $request, $id) { if ($app['config']['nostock_hidden']) { $app['orm.em']->getFilters()->enable('nostock_hidden'); } /* @var $Product \Eccube\Entity\Product */ $Product = $app['eccube.repository.product']->get($id); if (!$request->getSession()->has('_security_admin') && $Product->getStatus()->getId() !== 1) { throw new NotFoundHttpException(); } /* @var $builder \Symfony\Component\Form\FormBuilderInterface */ $builder = $app['form.factory']->createNamedBuilder('', 'add_cart', null, array('product' => $Product, 'id_add_product_id' => false)); /* @var $form \Symfony\Component\Form\FormInterface */ $form = $builder->getForm(); if ($request->getMethod() === 'POST') { $form->handleRequest($request); if ($form->isValid()) { $addCartData = $form->getData(); if ($addCartData['mode'] === 'add_favorite') { if ($app->isGranted('ROLE_USER')) { $Customer = $app->user(); $app['eccube.repository.customer_favorite_product']->addFavorite($Customer, $Product); $app['session']->getFlashBag()->set('product_detail.just_added_favorite', $Product->getId()); } return $app->redirect($app->url('product_detail', array('productId' => $Product->getId()))); } else { try { $app['eccube.service.cart']->addProduct($addCartData['product_class_id'], $addCartData['quantity'])->save(); } catch (CartException $e) { $app->addRequestError($e->getMessage()); } return $app->redirect($app->url('cart')); } } } if ($app->isGranted('ROLE_USER')) { $Customer = $app->user(); $is_favorite = $app['eccube.repository.customer_favorite_product']->isFavorite($Customer, $Product); } else { $is_favorite = false; } return $app->render('Product/detail.twig', array('title' => $this->title, 'subtitle' => $Product->getName(), 'form' => $form->createView(), 'Product' => $Product, 'is_favorite' => $is_favorite)); }
public function review(Application $app, Request $request, $id) { /* @var $Product \Eccube\Entity\Product */ $Product = $app['eccube.repository.product']->get($id); if (!$request->getSession()->has('_security_admin') && $Product->getStatus()->getId() !== 1) { throw new NotFoundHttpException(); } if (count($Product->getProductClasses()) < 1) { throw new NotFoundHttpException(); } $ProductReview = new \Plugin\ProductReview\Entity\ProductReview(); /* @var $builder \Symfony\Component\Form\FormBuilderInterface */ $builder = $app['form.factory']->createBuilder('product_review', $ProductReview); /* @var $form \Symfony\Component\Form\FormInterface */ $form = $builder->getForm(); if ($request->getMethod() === 'POST') { $form->handleRequest($request); if ($form->isValid()) { switch ($request->get('mode')) { case 'confirm': $builder->setAttribute('freeze', true); $form = $builder->getForm(); $form->handleRequest($request); return $app['twig']->render('ProductReview/Resource/template/default/confirm.twig', array('form' => $form->createView(), 'Product' => $Product)); break; case 'complete': /** @var $ProductReview \Plugin\ProductReview\Entity\ProductReview */ $ProductReview = $form->getData(); if ($app->isGranted('ROLE_USER')) { $Customer = $app->user(); $ProductReview->setCustomer($Customer); } $ProductReview->setProduct($Product); $Disp = $app['eccube.repository.master.disp']->find(\Eccube\Entity\Master\Disp::DISPLAY_HIDE); $ProductReview->setStatus($Disp); $ProductReview->setDelFlg(Constant::DISABLED); $status = $app['eccube.plugin.product_review.repository.product_review']->save($ProductReview); if (!$status) { $app->addError('front.product_review.system.error'); return $app->redirect($app->url('products_detail_review_error')); } else { return $app->redirect($app->url('products_detail_review_complete', array('id' => $Product->getId()))); } break; } return $app->redirect($app->url('admin_product_review')); } } return $app->render('ProductReview/Resource/template/default/index.twig', array('title' => $this->title, 'subtitle' => $Product->getName(), 'form' => $form->createView(), 'Product' => $Product)); }
/** * 非会員処理 */ public function nonmember(Application $app, Request $request) { $cartService = $app['eccube.service.cart']; // カートチェック if (!$cartService->isLocked()) { // カートが存在しない、カートがロックされていない時はエラー log_info('カートが存在しません'); return $app->redirect($app->url('cart')); } // ログイン済みの場合は, 購入画面へリダイレクト. if ($app->isGranted('ROLE_USER')) { return $app->redirect($app->url('shopping')); } // カートチェック if (count($cartService->getCart()->getCartItems()) <= 0) { // カートが存在しない時はエラー log_info('カートに商品が入っていないためショッピングカート画面にリダイレクト'); return $app->redirect($app->url('cart')); } $builder = $app['form.factory']->createBuilder('nonmember'); $event = new EventArgs(array('builder' => $builder), $request); $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_NONMEMBER_INITIALIZE, $event); $form = $builder->getForm(); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { log_info('非会員お客様情報登録開始'); $data = $form->getData(); $Customer = new Customer(); $Customer->setName01($data['name01'])->setName02($data['name02'])->setKana01($data['kana01'])->setKana02($data['kana02'])->setCompanyName($data['company_name'])->setEmail($data['email'])->setTel01($data['tel01'])->setTel02($data['tel02'])->setTel03($data['tel03'])->setZip01($data['zip01'])->setZip02($data['zip02'])->setZipCode($data['zip01'] . $data['zip02'])->setPref($data['pref'])->setAddr01($data['addr01'])->setAddr02($data['addr02']); // 非会員複数配送用 $CustomerAddress = new CustomerAddress(); $CustomerAddress->setCustomer($Customer)->setName01($data['name01'])->setName02($data['name02'])->setKana01($data['kana01'])->setKana02($data['kana02'])->setCompanyName($data['company_name'])->setTel01($data['tel01'])->setTel02($data['tel02'])->setTel03($data['tel03'])->setZip01($data['zip01'])->setZip02($data['zip02'])->setZipCode($data['zip01'] . $data['zip02'])->setPref($data['pref'])->setAddr01($data['addr01'])->setAddr02($data['addr02'])->setDelFlg(Constant::DISABLED); $Customer->addCustomerAddress($CustomerAddress); // 受注情報を取得 $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']); // 初回アクセス(受注データがない)の場合は, 受注情報を作成 if (is_null($Order)) { // 受注情報を作成 try { // 受注情報を作成 $Order = $app['eccube.service.shopping']->createOrder($Customer); } catch (CartException $e) { $app->addRequestError($e->getMessage()); return $app->redirect($app->url('cart')); } } // 非会員用セッションを作成 $nonMember = array(); $nonMember['customer'] = $Customer; $nonMember['pref'] = $Customer->getPref()->getId(); $app['session']->set($this->sessionKey, $nonMember); $customerAddresses = array(); $customerAddresses[] = $CustomerAddress; $app['session']->set($this->sessionCustomerAddressKey, serialize($customerAddresses)); $event = new EventArgs(array('form' => $form, 'Order' => $Order), $request); $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_NONMEMBER_COMPLETE, $event); if ($event->getResponse() !== null) { return $event->getResponse(); } log_info('非会員お客様情報登録完了', array($Order->getId())); return $app->redirect($app->url('shopping')); } return $app->render('Shopping/nonmember.twig', array('form' => $form->createView())); }