Skip to content

Commit

Permalink
Fixed storing changed billing/delivery addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
aimeos committed Nov 22, 2019
1 parent 18be864 commit 175b79e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,8 @@ protected function setAddress( \Aimeos\MW\View\Iface $view )
throw new \Aimeos\Client\Html\Exception( sprintf( 'At least one billing address part is missing or invalid' ) );
}

\Aimeos\Controller\Frontend::create( $context, 'customer' )->uses( [] )->add( $params )->store();
$cntl = \Aimeos\Controller\Frontend::create( $context, 'customer' )->uses( [] );
$params = $cntl->add( $params )->store()->get()->getPaymentAddress()->toArray();
}

$basketCtrl->addAddress( $type, $params, 0 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ protected function setAddress( \Aimeos\MW\View\Iface $view )
{
$address = null;
$context = $this->getContext();
$basketCtrl = \Aimeos\Controller\Frontend::create( $context, 'basket' );
$ctrl = \Aimeos\Controller\Frontend::create( $context, 'basket' );

/** client/html/checkout/standard/address/delivery/disable-new
* Disables the option to enter a different delivery address for an order
Expand Down Expand Up @@ -479,7 +479,7 @@ protected function setAddress( \Aimeos\MW\View\Iface $view )
throw new \Aimeos\Client\Html\Exception( sprintf( 'At least one delivery address part is missing or invalid' ) );
}

$basketCtrl->addAddress( $type, $params, 0 );
$ctrl->addAddress( $type, $params, 0 );
}
else if( ( $option = $view->param( 'ca_deliveryoption', 'null' ) ) !== '-1' ) // existing address
{
Expand All @@ -489,16 +489,18 @@ protected function setAddress( \Aimeos\MW\View\Iface $view )
throw new \Aimeos\Client\Html\Exception( sprintf( 'At least one delivery address part is missing or invalid' ) );
}

$cntl = \Aimeos\Controller\Frontend::create( $context, 'customer' );
$custCntl = \Aimeos\Controller\Frontend::create( $context, 'customer' );

if( ( $address = $cntl->uses( ['customer/address'] )->get()->getAddressItem( $option ) ) !== null )
if( ( $address = $custCntl->uses( ['customer/address'] )->get()->getAddressItem( $option ) ) !== null )
{
$data = $params;
$cntl->addAddressItem( $address->fromArray( $data ), $option )->store();
$params = array_replace( $address->toArray(), $params );
$addr = $ctrl->addAddress( $type, $params, 0 )->get()->getAddress( $type, 0 )->setAddressId( $option );
$custCntl->addAddressItem( $address->copyFrom( $addr ), $option )->store();
}
else
{
$ctrl->addAddress( $type, $params, 0 );
}

$basketCtrl->addAddress( $type, $params, 0 );
$basketCtrl->get()->getAddress( $type, 0 )->setAddressId( $option );
}
else
{
Expand Down

0 comments on commit 175b79e

Please sign in to comment.