diff --git a/src/Eccube/Controller/ShoppingController.php b/src/Eccube/Controller/ShoppingController.php index f5b5185061f..4d6dde8c12b 100644 --- a/src/Eccube/Controller/ShoppingController.php +++ b/src/Eccube/Controller/ShoppingController.php @@ -1048,9 +1048,14 @@ public function nonmember(Application $app, Request $request) // 非会員用セッションを作成 $app['eccube.service.shopping']->setNonMember($this->sessionKey, $Customer); - $customerAddresses = array(); - $customerAddresses[] = $CustomerAddress; - $app['session']->set($this->sessionCustomerAddressKey, serialize($customerAddresses)); + $CustomerAddressArray = $CustomerAddress->toArray(); + $CustomerAddressArray['Customer'] = $CustomerAddress->getCustomer()->toArray(); + $CustomerAddressArray['Pref'] = $CustomerAddress->getPref()->toArray(); + + $CustomerAddressesArray = array(); + $CustomerAddressesArray[] = $CustomerAddressArray; + + $app['session']->set($this->sessionCustomerAddressKey, json_encode($CustomerAddressesArray)); $event = new EventArgs( array( @@ -1419,12 +1424,15 @@ private function getCustomerAddress(Application $app, $CustomerAddressData) return $CustomerAddressData; } else { $cusAddId = $CustomerAddressData; + $customerAddresses = $app['session']->get($this->sessionCustomerAddressKey); - $customerAddresses = unserialize($customerAddresses); + $customerAddresses = json_decode($customerAddresses, true); + + $customerAddressArray = $customerAddresses[$cusAddId]; - $CustomerAddress = $customerAddresses[$cusAddId]; - $pref = $app['eccube.repository.master.pref']->find($CustomerAddress->getPref()->getId()); - $CustomerAddress->setPref($pref); + $CustomerAddress = new CustomerAddress(); + $CustomerAddress->setPropertiesFromArray($customerAddressArray); + $CustomerAddress->setPref($app['eccube.repository.master.pref']->find($customerAddressArray['Pref']['id'])); return $CustomerAddress; } @@ -1467,11 +1475,15 @@ public function shippingMultipleEdit(Application $app, Request $request) log_info('非会員お届け先追加処理開始'); + $customerAddressArray = $CustomerAddress->toArray(); + $customerAddressArray['Customer'] = $CustomerAddress->getCustomer()->toArray(); + $customerAddressArray['Pref'] = $CustomerAddress->getPref()->toArray(); + // 非会員用のセッションに追加 - $customerAddresses = $app['session']->get($this->sessionCustomerAddressKey); - $customerAddresses = unserialize($customerAddresses); - $customerAddresses[] = $CustomerAddress; - $app['session']->set($this->sessionCustomerAddressKey, serialize($customerAddresses)); + $customerAddresses = json_decode($app['session']->get($this->sessionCustomerAddressKey), true); + $customerAddresses[] = $customerAddressArray; + + $app['session']->set($this->sessionCustomerAddressKey, json_encode($customerAddresses)); $event = new EventArgs( array( diff --git a/src/Eccube/Form/Type/ShippingMultipleItemType.php b/src/Eccube/Form/Type/ShippingMultipleItemType.php index f9939fbffef..13a4c678d7d 100644 --- a/src/Eccube/Form/Type/ShippingMultipleItemType.php +++ b/src/Eccube/Form/Type/ShippingMultipleItemType.php @@ -24,6 +24,7 @@ namespace Eccube\Form\Type; +use Eccube\Entity\CustomerAddress; use Doctrine\ORM\EntityRepository; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; @@ -86,14 +87,21 @@ public function buildForm(FormBuilderInterface $builder, array $options) // 非会員の場合、セッションに設定されたCustomerAddressを設定 if ($app['session']->has('eccube.front.shopping.nonmember.customeraddress')) { $customerAddresses = $app['session']->get('eccube.front.shopping.nonmember.customeraddress'); - $customerAddresses = unserialize($customerAddresses); + $customerAddresses = json_decode($customerAddresses, true); $addresses = array(); - $i = 0; - /** @var \Eccube\Entity\CustomerAddress $CustomerAddress */ - foreach ($customerAddresses as $CustomerAddress) { - $addresses[$i] = $CustomerAddress->getShippingMultipleDefaultName(); - $i++; + /** @var \Eccube\Entity\CustomerAddress $value */ + foreach ($customerAddresses as $value) { + + $customerAddressArray = (array) $value; + $customerAddressArray['Pref'] = (array) $customerAddressArray['Pref']; + + $CustomerAddress = new CustomerAddress(); + $CustomerAddress->setPropertiesFromArray($customerAddressArray); + $CustomerAddress->setCustomer($app['eccube.service.shopping']->getNonMember('eccube.front.shopping.nonmember')); + $CustomerAddress->setPref($app['eccube.repository.master.pref']->find($customerAddressArray['Pref']['id'])); + + $addresses[] = $CustomerAddress->getShippingMultipleDefaultName(); } $form->add('customer_address', 'choice', array( 'choices' => $addresses,