@@ -97,6 +97,7 @@ class PaymentInformationManagement implements \Magento\Checkout\Api\PaymentInfor
9797 * @param AddressRepositoryInterface|null $addressRepository
9898 * @param AddressComparatorInterface|null $addressComparator
9999 * @codeCoverageIgnore
100+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
100101 */
101102 public function __construct (
102103 \Magento \Quote \Api \BillingAddressManagementInterface $ billingAddressManagement ,
@@ -165,7 +166,9 @@ public function savePaymentInformationAndPlaceOrder(
165166
166167 /**
167168 * @inheritdoc
169+ *
168170 * @throws LocalizedException
171+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
169172 */
170173 public function savePaymentInformation (
171174 $ cartId ,
@@ -194,15 +197,16 @@ public function savePaymentInformation(
194197 $ quote ->setBillingAddress ($ billingAddress );
195198 $ quote ->setDataChanges (true );
196199 $ 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+ }
206210 }
207211 }
208212 }
@@ -241,9 +245,10 @@ private function getLogger()
241245 * Save shipping address information
242246 *
243247 * @param Quote $quote
248+ * @return void
244249 * @throws LocalizedException
245250 */
246- private function saveNewShippingAddress (Quote $ quote )
251+ private function saveNewShippingAddress (Quote $ quote ): void
247252 {
248253 $ quote ->getShippingAddress ()->setSameAsBilling (1 );
249254 $ shippingAddressData = $ quote ->getShippingAddress ()->exportCustomerAddress ();
0 commit comments