|
23 | 23 | * @SuppressWarnings(PHPMD.TooManyFields)
|
24 | 24 | * @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
|
25 | 25 | * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
| 26 | + * @SuppressWarnings(PHPMD.CookieAndSessionMisuse) |
26 | 27 | * @since 100.0.2
|
27 | 28 | */
|
28 | 29 | class Multishipping extends \Magento\Framework\DataObject
|
@@ -526,6 +527,7 @@ protected function _addShippingItem($quoteItemId, $data)
|
526 | 527 | $quoteItem->setQty($quoteItem->getMultishippingQty());
|
527 | 528 | try {
|
528 | 529 | $address = $this->addressRepository->getById($addressId);
|
| 530 | + // phpcs:ignore Magento2.CodeAnalysis.EmptyBlock |
529 | 531 | } catch (\Exception $e) {
|
530 | 532 | }
|
531 | 533 | if (isset($address)) {
|
@@ -565,6 +567,7 @@ public function updateQuoteCustomerShippingAddress($addressId)
|
565 | 567 | }
|
566 | 568 | try {
|
567 | 569 | $address = $this->addressRepository->getById($addressId);
|
| 570 | + // phpcs:ignore Magento2.CodeAnalysis.EmptyBlock |
568 | 571 | } catch (\Exception $e) {
|
569 | 572 | //
|
570 | 573 | }
|
@@ -592,6 +595,7 @@ public function setQuoteCustomerBillingAddress($addressId)
|
592 | 595 | }
|
593 | 596 | try {
|
594 | 597 | $address = $this->addressRepository->getById($addressId);
|
| 598 | + // phpcs:ignore Magento2.CodeAnalysis.EmptyBlock |
595 | 599 | } catch (\Exception $e) {
|
596 | 600 | //
|
597 | 601 | }
|
@@ -825,7 +829,7 @@ public function createOrders()
|
825 | 829 | if ($order->getCanSendNewEmailFlag()) {
|
826 | 830 | $this->orderSender->send($order);
|
827 | 831 | }
|
828 |
| - $placedAddressItems = array_merge($placedAddressItems, $this->getQuoteAddressItems($order)); |
| 832 | + $placedAddressItems = $this->getPlacedAddressItems($order); |
829 | 833 | }
|
830 | 834 |
|
831 | 835 | $addressErrors = [];
|
@@ -1090,10 +1094,14 @@ public function getCustomer()
|
1090 | 1094 | */
|
1091 | 1095 | protected function isAddressIdApplicable($addressId)
|
1092 | 1096 | {
|
1093 |
| - $applicableAddressIds = array_map(function ($address) { |
1094 |
| - /** @var \Magento\Customer\Api\Data\AddressInterface $address */ |
1095 |
| - return $address->getId(); |
1096 |
| - }, $this->getCustomer()->getAddresses()); |
| 1097 | + $applicableAddressIds = array_map( |
| 1098 | + function ($address) { |
| 1099 | + /** @var \Magento\Customer\Api\Data\AddressInterface $address */ |
| 1100 | + return $address->getId(); |
| 1101 | + }, |
| 1102 | + $this->getCustomer()->getAddresses() |
| 1103 | + ); |
| 1104 | + |
1097 | 1105 | return !is_numeric($addressId) || in_array($addressId, $applicableAddressIds);
|
1098 | 1106 | }
|
1099 | 1107 |
|
@@ -1279,4 +1287,20 @@ private function getQuoteAddressItems(OrderInterface $order): array
|
1279 | 1287 |
|
1280 | 1288 | return $placedAddressItems;
|
1281 | 1289 | }
|
| 1290 | + |
| 1291 | + /** |
| 1292 | + * Returns placed address items |
| 1293 | + * |
| 1294 | + * @param OrderInterface $order |
| 1295 | + * @return array |
| 1296 | + */ |
| 1297 | + private function getPlacedAddressItems(OrderInterface $order): array |
| 1298 | + { |
| 1299 | + $placedAddressItems = []; |
| 1300 | + foreach ($this->getQuoteAddressItems($order) as $key => $quoteAddressItem) { |
| 1301 | + $placedAddressItems[$key] = $quoteAddressItem; |
| 1302 | + } |
| 1303 | + |
| 1304 | + return $placedAddressItems; |
| 1305 | + } |
1282 | 1306 | }
|
0 commit comments