/**
  * Create a new mailing address destination from a magento order address.
  *
  * @param Mage_Customer_Model_Address_Abstract
  * @param IOrderDestinationIterable Used to create the new email address destination payload
  * @return IEmailAddressDestination
  */
 protected function _buildVirtualDestination(Mage_Customer_Model_Address_Abstract $address, IOrderDestinationIterable $destinations)
 {
     $destination = $destinations->getEmptyEmailAddress();
     return $this->_transferPersonNameData($address, $destination)->setEmailAddress($address->getEmail());
 }
 /**
  * Remove any ship groups that no longer contain items.
  *
  * @param IShipGroupIterable
  * @return IShipGroupIterable
  */
 protected function removeEmptyShipGroups(IShipGroupIterable $shipGroups, IOrderDestinationIterable $destinations)
 {
     // Can't loop over the iterable and modify it at the same time.
     // Collect items that need to be removed from the iterable but don't
     // modify the iterable.
     $emptyShipGroups = [];
     foreach ($shipGroups as $shipGroup) {
         if ($shipGroup->getItemReferences()->count() === 0) {
             $emptyShipGroups[] = $shipGroup;
         }
     }
     // Go through the items that need to be removed and remove each from
     // the iterable.
     foreach ($emptyShipGroups as $removeShipGroup) {
         // Destinations are stored separate from the ship group. Any destinations
         // for empty ship groups are no longer necessary so remove them with
         // the rest of the ship group.
         $destinations->offsetUnset($removeShipGroup->getDestination());
         $shipGroups->offsetUnset($removeShipGroup);
     }
     return $shipGroups;
 }