Skip to content

Commit b6a5ca2

Browse files
author
Oleksii Korshenko
authored
MAGETWO-64714: [GitHub] [PR] Fix quote's outdated shipping address overwriting PayPal Express shipping address #8568
2 parents 6001299 + 7a112ec commit b6a5ca2

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

app/code/Magento/Braintree/Model/Paypal/Helper/QuoteUpdater.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ private function updateQuote(Quote $quote, array $details)
8484

8585
$quote->collectTotals();
8686

87+
/**
88+
* Unset shipping assignment to prevent from saving / applying outdated data
89+
* @see \Magento\Quote\Model\QuoteRepository\SaveHandler::processShippingAssignment
90+
*/
91+
if ($quote->getExtensionAttributes()) {
92+
$quote->getExtensionAttributes()->setShippingAssignments(null);
93+
}
94+
8795
$this->quoteRepository->save($quote);
8896
}
8997

@@ -122,6 +130,11 @@ private function updateShippingAddress(Quote $quote, array $details)
122130
$shippingAddress->setCollectShippingRates(true);
123131

124132
$this->updateAddressData($shippingAddress, $details['shippingAddress']);
133+
134+
// PayPal's address supposes not saving against customer account
135+
$shippingAddress->setSaveInAddressBook(false);
136+
$shippingAddress->setSameAsBilling(false);
137+
$shippingAddress->unsCustomerAddressId();
125138
}
126139

127140
/**
@@ -144,6 +157,11 @@ private function updateBillingAddress(Quote $quote, array $details)
144157
$billingAddress->setFirstname($details['firstName']);
145158
$billingAddress->setLastname($details['lastName']);
146159
$billingAddress->setEmail($details['email']);
160+
161+
// PayPal's address supposes not saving against customer account
162+
$billingAddress->setSaveInAddressBook(false);
163+
$billingAddress->setSameAsBilling(false);
164+
$billingAddress->unsCustomerAddressId();
147165
}
148166

149167
/**

0 commit comments

Comments
 (0)