diff --git a/engine/Shopware/Controllers/Frontend/Checkout.php b/engine/Shopware/Controllers/Frontend/Checkout.php index c9b7f8824a3..c690d059f0e 100644 --- a/engine/Shopware/Controllers/Frontend/Checkout.php +++ b/engine/Shopware/Controllers/Frontend/Checkout.php @@ -353,6 +353,8 @@ public function confirmAction() */ public function finishAction() { + $customerId = $this->session->get('sUserId'); + if ($this->Request()->getParam('sUniqueID') && !empty($this->session['sOrderVariables'])) { $sql = ' SELECT transactionID as sTransactionumber, ordernumber as sOrderNumber @@ -373,8 +375,8 @@ public function finishAction() $orderVariables = $this->session['sOrderVariables']->getArrayCopy(); if (!empty($orderVariables['sOrderNumber'])) { - $orderVariables['sAddresses']['billing'] = $this->getOrderAddress($orderVariables['sOrderNumber'], 'billing'); - $orderVariables['sAddresses']['shipping'] = $this->getOrderAddress($orderVariables['sOrderNumber'], 'shipping'); + $orderVariables['sAddresses']['billing'] = $this->getOrderAddress($orderVariables['sOrderNumber'], $customerId, 'billing'); + $orderVariables['sAddresses']['shipping'] = $this->getOrderAddress($orderVariables['sOrderNumber'], $customerId, 'shipping'); $orderVariables['sAddresses']['equal'] = $this->areAddressesEqual($orderVariables['sAddresses']['billing'], $orderVariables['sAddresses']['shipping']); } @@ -407,8 +409,8 @@ public function finishAction() $orderVariables = $this->session['sOrderVariables']->getArrayCopy(); if (!empty($orderVariables['sOrderNumber'])) { - $orderVariables['sAddresses']['billing'] = $this->getOrderAddress($orderVariables['sOrderNumber'], 'billing'); - $orderVariables['sAddresses']['shipping'] = $this->getOrderAddress($orderVariables['sOrderNumber'], 'shipping'); + $orderVariables['sAddresses']['billing'] = $this->getOrderAddress($orderVariables['sOrderNumber'], $customerId , 'billing'); + $orderVariables['sAddresses']['shipping'] = $this->getOrderAddress($orderVariables['sOrderNumber'], $customerId , 'shipping'); $orderVariables['sAddresses']['equal'] = $this->areAddressesEqual($orderVariables['sAddresses']['billing'], $orderVariables['sAddresses']['shipping']); } @@ -502,9 +504,9 @@ public function finishAction() $this->session->offsetUnset('sComment'); $orderVariables = $this->session['sOrderVariables']->getArrayCopy(); - - $orderVariables['sAddresses']['billing'] = $this->getOrderAddress($orderVariables['sOrderNumber'], 'billing'); - $orderVariables['sAddresses']['shipping'] = $this->getOrderAddress($orderVariables['sOrderNumber'], 'shipping'); + + $orderVariables['sAddresses']['billing'] = $this->getOrderAddress($orderVariables['sOrderNumber'], $customerId, 'billing'); + $orderVariables['sAddresses']['shipping'] = $this->getOrderAddress($orderVariables['sOrderNumber'], $customerId, 'shipping'); $orderVariables['sAddresses']['equal'] = $this->areAddressesEqual($orderVariables['sAddresses']['billing'], $orderVariables['sAddresses']['shipping']); $this->View()->assign($orderVariables); @@ -2131,7 +2133,7 @@ private function isValidAddress(int $addressId, bool $isShippingAddress = false) /** * @return array */ - private function getOrderAddress(string $orderNumber, string $source): array + private function getOrderAddress(string $orderNumber, int $customerId, string $source): array { $builder = $this->get(Connection::class)->createQueryBuilder(); $context = $this->get(ContextServiceInterface::class)->getShopContext(); @@ -2140,8 +2142,9 @@ private function getOrderAddress(string $orderNumber, string $source): array $address = $builder->select(['address.*']) ->from($sourceTable, 'address') - ->join('address', 's_order', '', 'address.orderID = s_order.id AND s_order.ordernumber = :orderNumber') + ->join('address', 's_order', '', 'address.orderID = s_order.id AND s_order.ordernumber = :orderNumber AND s_order.userID = :userID') ->setParameter('orderNumber', $orderNumber) + ->setParameter('userID', $customerId) ->execute() ->fetch();