@@ -97,6 +97,7 @@ class PaymentInformationManagement implements \Magento\Checkout\Api\PaymentInfor
97
97
* @param AddressRepositoryInterface|null $addressRepository
98
98
* @param AddressComparatorInterface|null $addressComparator
99
99
* @codeCoverageIgnore
100
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
100
101
*/
101
102
public function __construct (
102
103
\Magento \Quote \Api \BillingAddressManagementInterface $ billingAddressManagement ,
@@ -165,7 +166,9 @@ public function savePaymentInformationAndPlaceOrder(
165
166
166
167
/**
167
168
* @inheritdoc
169
+ *
168
170
* @throws LocalizedException
171
+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
169
172
*/
170
173
public function savePaymentInformation (
171
174
$ cartId ,
@@ -194,15 +197,16 @@ public function savePaymentInformation(
194
197
$ quote ->setBillingAddress ($ billingAddress );
195
198
$ quote ->setDataChanges (true );
196
199
$ shippingAddress = $ quote ->getShippingAddress ();
197
- $ sameAsBilling = (bool )$ shippingAddress ->getSameAsBilling ()
198
- || $ this ->addressComparator ->isEqual ($ shippingAddress , $ billingAddress );
199
- if ($ sameAsBilling ) {
200
- $ this ->saveNewShippingAddress ($ quote );
201
- }
202
- if ($ shippingAddress && $ shippingAddress ->getShippingMethod ()) {
203
- $ shippingRate = $ shippingAddress ->getShippingRateByCode ($ shippingAddress ->getShippingMethod ());
204
- if ($ shippingRate ) {
205
- $ shippingAddress ->setLimitCarrier ($ shippingRate ->getCarrier ());
200
+ if ($ shippingAddress ) {
201
+ if ((bool )$ shippingAddress ->getSameAsBilling ()
202
+ || $ this ->addressComparator ->isEqual ($ shippingAddress , $ billingAddress )) {
203
+ $ this ->saveNewShippingAddress ($ quote );
204
+ }
205
+ if ($ shippingAddress ->getShippingMethod ()) {
206
+ $ shippingRate = $ shippingAddress ->getShippingRateByCode ($ shippingAddress ->getShippingMethod ());
207
+ if ($ shippingRate ) {
208
+ $ shippingAddress ->setLimitCarrier ($ shippingRate ->getCarrier ());
209
+ }
206
210
}
207
211
}
208
212
}
@@ -241,9 +245,10 @@ private function getLogger()
241
245
* Save shipping address information
242
246
*
243
247
* @param Quote $quote
248
+ * @return void
244
249
* @throws LocalizedException
245
250
*/
246
- private function saveNewShippingAddress (Quote $ quote )
251
+ private function saveNewShippingAddress (Quote $ quote ): void
247
252
{
248
253
$ quote ->getShippingAddress ()->setSameAsBilling (1 );
249
254
$ shippingAddressData = $ quote ->getShippingAddress ()->exportCustomerAddress ();
0 commit comments