Eccube\Entity\CustomerAddress::setFromShipping PHP Method

setFromShipping() public method

Set from Shipping.
public setFromShipping ( Shipping $Shipping ) : CustomerAddress
$Shipping Shipping
return CustomerAddress
    public function setFromShipping(Shipping $Shipping)
    {
        $this->setName01($Shipping->getName01())->setName02($Shipping->getName02())->setKana01($Shipping->getKana01())->setKana02($Shipping->getKana02())->setCompanyName($Shipping->getCompanyName())->setTel01($Shipping->getTel01())->setTel02($Shipping->getTel02())->setTel03($Shipping->getTel03())->setFax01($Shipping->getFax01())->setFax02($Shipping->getFax02())->setFax03($Shipping->getFax03())->setZip01($Shipping->getZip01())->setZip02($Shipping->getZip02())->setZipCode($Shipping->getZip01() . $Shipping->getZip02())->setPref($Shipping->getPref())->setAddr01($Shipping->getAddr01())->setAddr02($Shipping->getAddr02());
        return $this;
    }

Usage Example

 /**
  * お届け先の設定(非会員でも使用する)
  */
 public function shippingEdit(Application $app, Request $request, $id)
 {
     // 配送先住所最大値判定
     $Customer = $app->user();
     if ($app->isGranted('IS_AUTHENTICATED_FULLY')) {
         $addressCurrNum = count($app->user()->getCustomerAddresses());
         $addressMax = $app['config']['deliv_addr_max'];
         if ($addressCurrNum >= $addressMax) {
             throw new NotFoundHttpException();
         }
     }
     // カートチェック
     if (!$app['eccube.service.cart']->isLocked()) {
         // カートが存在しない、カートがロックされていない時はエラー
         return $app->redirect($app->url('cart'));
     }
     $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']);
     if (!$Order) {
         $app->addError('front.shopping.order.error');
         return $app->redirect($app->url('shopping_error'));
     }
     $Shipping = $Order->findShipping($id);
     if (!$Shipping) {
         throw new NotFoundHttpException();
     }
     if ($app->isGranted('IS_AUTHENTICATED_FULLY')) {
         $Shipping->clearCustomerAddress();
     }
     $CustomerAddress = new CustomerAddress();
     if ($app->isGranted('IS_AUTHENTICATED_FULLY')) {
         $CustomerAddress->setCustomer($Customer);
     } else {
         $CustomerAddress->setFromShipping($Shipping);
     }
     $builder = $app['form.factory']->createBuilder('shopping_shipping', $CustomerAddress);
     $form = $builder->getForm();
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         // 会員の場合、お届け先情報を新規登録
         $Shipping->setFromCustomerAddress($CustomerAddress);
         if ($Customer instanceof Customer) {
             $app['orm.em']->persist($CustomerAddress);
         }
         // 配送料金の設定
         $app['eccube.service.shopping']->setShippingDeliveryFee($Shipping);
         // 配送先を更新
         $app['orm.em']->flush();
         return $app->redirect($app->url('shopping'));
     }
     return $app->render('Shopping/shipping_edit.twig', array('form' => $form->createView(), 'shippingId' => $id));
 }
All Usage Examples Of Eccube\Entity\CustomerAddress::setFromShipping