Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement fix for wrong sAddresses data issue. consider userId to get… #2702

Open
wants to merge 3 commits into
base: 5.7
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions engine/Shopware/Controllers/Frontend/Checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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']);
}

Expand Down Expand Up @@ -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']);
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -2131,7 +2133,7 @@ private function isValidAddress(int $addressId, bool $isShippingAddress = false)
/**
* @return array<string, mixed>
*/
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();
Expand All @@ -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();

Expand Down
Loading