Inheritance: extends Eccube\Entity\AbstractEntity
 /**
  * 非会員用複数配送設定時の新規お届け先の設定
  */
 public function shippingMultipleEdit(Application $app, Request $request)
 {
     // カートチェック
     if (!$app['eccube.service.cart']->isLocked()) {
         // カートが存在しない、カートがロックされていない時はエラー
         return $app->redirect($app->url('cart'));
     }
     // 非会員用Customerを取得
     $Customer = $app['eccube.service.shopping']->getNonMember($this->sessionKey);
     $CustomerAddress = new CustomerAddress();
     $CustomerAddress->setCustomer($Customer);
     $Customer->addCustomerAddress($CustomerAddress);
     $form = $app['form.factory']->createBuilder('shopping_shipping', $CustomerAddress)->getForm();
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         // 非会員用のセッションに追加
         $customerAddresses = $app['session']->get($this->sessionCustomerAddressKey);
         $customerAddresses = unserialize($customerAddresses);
         $customerAddresses[] = $CustomerAddress;
         $app['session']->set($this->sessionCustomerAddressKey, serialize($customerAddresses));
         return $app->redirect($app->url('shopping_shipping_multiple'));
     }
     return $app->render('Shopping/shipping_multiple_edit.twig', array('form' => $form->createView()));
 }
Exemple #2
0
 /**
  * 非会員の Customer オブジェクトを生成して返す.
  *
  * @param string $email メールアドレス. null の場合は, ランダムなメールアドレスが生成される.
  * @return \Eccube\Entity\Customer
  */
 public function createNonMember($email = null)
 {
     $sessionKey = 'eccube.front.shopping.nonmember';
     $sessionCustomerAddressKey = 'eccube.front.shopping.nonmember.customeraddress';
     $faker = $this->getFaker();
     $Customer = new Customer();
     if (is_null($email)) {
         $email = $faker->email;
     }
     $Pref = $this->app['eccube.repository.master.pref']->find(1);
     $Customer->setName01($faker->lastName)->setName02($faker->firstName)->setEmail($email)->setPref($Pref)->setDelFlg(Constant::DISABLED);
     $CustomerAddress = new CustomerAddress();
     $CustomerAddress->setCustomer($Customer)->setDelFlg(Constant::DISABLED);
     $CustomerAddress->copyProperties($Customer);
     $Customer->addCustomerAddress($CustomerAddress);
     $nonMember = array();
     $nonMember['customer'] = $Customer;
     $nonMember['pref'] = $Customer->getPref()->getId();
     $this->app['session']->set($sessionKey, $nonMember);
     $customerAddresses = array();
     $customerAddresses[] = $CustomerAddress;
     $this->app['session']->set($sessionCustomerAddressKey, serialize($customerAddresses));
     return $Customer;
 }
Exemple #3
0
 /**
  * 非会員の Customer オブジェクトを生成して返す.
  *
  * @param string $email メールアドレス. null の場合は, ランダムなメールアドレスが生成される.
  * @return \Eccube\Entity\Customer
  */
 public function createNonMember($email = null)
 {
     $sessionKey = 'eccube.front.shopping.nonmember';
     $sessionCustomerAddressKey = 'eccube.front.shopping.nonmember.customeraddress';
     $faker = $this->getFaker();
     $Customer = new Customer();
     if (is_null($email)) {
         $email = $faker->safeEmail;
     }
     $Pref = $this->app['eccube.repository.master.pref']->find($faker->numberBetween(1, 47));
     $tel = explode('-', $faker->phoneNumber);
     $fax = explode('-', $faker->phoneNumber);
     $Customer->setName01($faker->lastName)->setName02($faker->firstName)->setKana01($faker->lastKanaName)->setKana02($faker->firstKanaName)->setCompanyName($faker->company)->setEmail($email)->setZip01($faker->postcode1())->setZip02($faker->postcode2())->setPref($Pref)->setAddr01($faker->city)->setAddr02($faker->streetAddress)->setTel01($tel[0])->setTel02($tel[1])->setTel03($tel[2])->setFax01($fax[0])->setFax02($fax[1])->setFax03($fax[2])->setDelFlg(Constant::DISABLED);
     $CustomerAddress = new CustomerAddress();
     $CustomerAddress->setCustomer($Customer)->setDelFlg(Constant::DISABLED);
     $CustomerAddress->copyProperties($Customer);
     $Customer->addCustomerAddress($CustomerAddress);
     $nonMember = array();
     $nonMember['customer'] = $Customer;
     $nonMember['pref'] = $Customer->getPref()->getId();
     $this->app['session']->set($sessionKey, $nonMember);
     $customerAddresses = array();
     $customerAddresses[] = $CustomerAddress;
     $this->app['session']->set($sessionCustomerAddressKey, serialize($customerAddresses));
     return $Customer;
 }
Exemple #4
0
 /**
  * CustomerAddress から個人情報を設定.
  * 
  * @param \Eccube\Entity\CustomerAddress $CustomerAddress
  * @return \Eccube\Entity\Shipping
  */
 public function setFromCustomerAddress(CustomerAddress $CustomerAddress)
 {
     $this->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());
     return $this;
 }
 /**
  * 非会員用複数配送設定時の新規お届け先の設定
  */
 public function shippingMultipleEdit(Application $app, Request $request)
 {
     // カートチェック
     if (!$app['eccube.service.cart']->isLocked()) {
         // カートが存在しない、カートがロックされていない時はエラー
         return $app->redirect($app->url('cart'));
     }
     $form = $app['form.factory']->createBuilder('shopping_shipping')->getForm();
     if ('POST' === $request->getMethod()) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             $data = $form->getData();
             // 非会員用Customerを取得
             $Customer = $app['eccube.service.shopping']->getNonMember($this->sessionKey);
             $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);
             // 非会員用のセッションに追加
             $customerAddresses = $app['session']->get($this->sessionCustomerAddressKey);
             $customerAddresses = unserialize($customerAddresses);
             $customerAddresses[] = $CustomerAddress;
             $app['session']->set($this->sessionCustomerAddressKey, serialize($customerAddresses));
             return $app->redirect($app->url('shopping_shipping_multiple'));
         }
     }
     return $app->render('Shopping/shipping_multiple_edit.twig', array('form' => $form->createView()));
 }
 /**
  * 非会員用複数配送設定時の新規お届け先の設定
  */
 public function shippingMultipleEdit(Application $app, Request $request)
 {
     // カートチェック
     if (!$app['eccube.service.cart']->isLocked()) {
         log_info('カートが存在しません');
         // カートが存在しない、カートがロックされていない時はエラー
         return $app->redirect($app->url('cart'));
     }
     // 非会員用Customerを取得
     $Customer = $app['eccube.service.shopping']->getNonMember($this->sessionKey);
     $CustomerAddress = new CustomerAddress();
     $CustomerAddress->setCustomer($Customer);
     $Customer->addCustomerAddress($CustomerAddress);
     $builder = $app['form.factory']->createBuilder('shopping_shipping', $CustomerAddress);
     $event = new EventArgs(array('builder' => $builder, 'Customer' => $Customer), $request);
     $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_SHIPPING_MULTIPLE_EDIT_INITIALIZE, $event);
     $form = $builder->getForm();
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         log_info('非会員お届け先追加処理開始');
         // 非会員用のセッションに追加
         $customerAddresses = $app['session']->get($this->sessionCustomerAddressKey);
         $customerAddresses = unserialize($customerAddresses);
         $customerAddresses[] = $CustomerAddress;
         $app['session']->set($this->sessionCustomerAddressKey, serialize($customerAddresses));
         $event = new EventArgs(array('form' => $form, 'CustomerAddresses' => $customerAddresses), $request);
         $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_SHIPPING_MULTIPLE_EDIT_COMPLETE, $event);
         log_info('非会員お届け先追加処理完了');
         return $app->redirect($app->url('shopping_shipping_multiple'));
     }
     return $app->render('Shopping/shipping_multiple_edit.twig', array('form' => $form->createView()));
 }