protected function setItemDeliveryAddress(
        $addressData,
        ApiItemInterface $item,
        ContactInterface $contact = null,
        AccountInterface $account = null
    ) {
        if ($item->getDeliveryAddress() === null) {
            // Create new delivery address.
            $deliveryAddress = new $this->orderAddressEntity();
            // Persist entities.
            $this->em->persist($deliveryAddress);
            // Assign to order.
            $item->setDeliveryAddress($deliveryAddress);
        }

        if (is_array($addressData)) {
            // Set order-address.
            $this->orderAddressManager->setOrderAddress(
                $item->getDeliveryAddress(),
                $addressData,
                $contact,
                $account
            );
        } elseif (is_int($addressData)) {
            $contactAddressId = $addressData;
            // Create order-address and assign contact-address data.
            $deliveryAddress = $item->getEntity()->getDeliveryAddress();

            $orderAddress = $this->orderAddressManager->getAndSetOrderAddressByContactAddressId(
                $contactAddressId,
                $contact,
                $account,
                $deliveryAddress
            );

            // Set delivery address.
            $item->setDeliveryAddress($orderAddress);

            // If new delivery address persist.
            if (!$deliveryAddress) {
                $this->em->persist($orderAddress);
            }
        }
    }
protected function setItemDeliveryAddress(
        $addressData,
        ApiItemInterface $item,
        ContactInterface $contact = null,
        AccountInterface $account = null
    ) {
        if ($item->getDeliveryAddress() === null) {
            // Create new delivery address.
            $deliveryAddress = new $this->orderAddressEntity();
            // Persist entities.
            $this->em->persist($deliveryAddress);
            // Assign to order.
            $item->setDeliveryAddress($deliveryAddress);
        }

        if (is_array($addressData)) {
            // Set order-address.
            $this->orderAddressManager->setOrderAddress(
                $item->getDeliveryAddress(),
                $addressData,
                $contact,
                $account
            );
        } elseif (is_int($addressData)) {
            $contactAddressId = $addressData;
            // Create order-address and assign contact-address data.
            $deliveryAddress = $item->getEntity()->getDeliveryAddress();

            $orderAddress = $this->orderAddressManager->getAndSetOrderAddressByContactAddressId(
                $contactAddressId,
                $contact,
                $account,
                $deliveryAddress
            );

            // Set delivery address.
            $item->setDeliveryAddress($orderAddress);

            // If new delivery address persist.
            if (!$deliveryAddress) {
                $this->em->persist($orderAddress);
            }
        }
    }
protected function setItemDeliveryAddress ( $ addressData , ApiItemInterface $ item , ContactInterface $ contact = null , AccountInterface $ account = null ) { if ( $ item -> getDeliveryAddress ( ) === null ) { // Create new delivery address. $ deliveryAddress = new $ this -> orderAddressEntity ( ) ; // Persist entities. $ this -> em -> persist ( $ deliveryAddress ) ; // Assign to order. $ item -> setDeliveryAddress ( $ deliveryAddress ) ; } if ( is_array ( $ addressData ) ) { // Set order-address. $ this -> orderAddressManager -> setOrderAddress ( $ item -> getDeliveryAddress ( ) , $ addressData , $ contact , $ account ) ; } elseif ( is_int ( $ addressData ) ) { $ contactAddressId = $ addressData ; // Create order-address and assign contact-address data. $ deliveryAddress = $ item -> getEntity ( ) -> getDeliveryAddress ( ) ; $ orderAddress = $ this -> orderAddressManager -> getAndSetOrderAddressByContactAddressId ( $ contactAddressId , $ contact , $ account , $ deliveryAddress ) ; // Set delivery address. $ item -> setDeliveryAddress ( $ orderAddress ) ; // If new delivery address persist. if ( ! $ deliveryAddress ) { $ this -> em -> persist ( $ orderAddress ) ; } } }
Sets delivery address for an item.

@param array|int $addressData
@param ApiItemInterface $item
@param ContactInterface $contact
@param AccountInterface $account

@throws ItemDependencyNotFoundException
@throws ItemException
Sets delivery address for an item .