Remove all item delivery-addresses that are the same as the default
delivery address of the order

@param ApiOrderInterface $order
544188
protected function removeItemAddressesThatAreEqualToOrderAddress($order)
    {
        $deliveryAddressId = $order->getDeliveryAddress()->getContactAddress()->getId();
        foreach ($order->getItems() as $item) {
            $itemEntity = $item->getEntity();
            $this->removeOrderAddressIfContactAddressIdIsEqualTo($itemEntity, $deliveryAddressId);
        }
    }
404799
protected function removeOrderAddressIfContactAddressIdIsEqualTo($item, $contactAddressId)
    {
        $deliveryAddress = $item->getDeliveryAddress();
        if ($deliveryAddress
            && $deliveryAddress->getContactAddress()
            && $deliveryAddress->getContactAddress()->getID() === $contactAddressId
        ) {
            $item->setDeliveryAddress(null);
            $this->em->remove($deliveryAddress);
        }
    }
151367
public function removeAddress(AddressInterface $address)
    {
        if (!$this->hasAddress($address)) {
            throw new \InvalidArgumentException('Trying to remove an address that does not belong to this contact');
        }

        $this->addresses->removeElement($address);

        if ($address === $this->defaultAddress) {
            if ($this->addresses->count() > 0) {
                $this->defaultAddress = $this->addresses->first();

                return;
            }

            $this->defaultAddress = null;
        }
    }
438220
public function remove_item_by_priority( $priority = 0 ) {
		// Search all items for the same priority.
		$all_items = $this->get_items();
		if ( array_key_exists( $priority, $all_items ) ) {
			// Remove all items with that priority.
			unset( $all_items[ $priority ] );
		}

		// Update the items.
		$this->set_items( $all_items );
	}
230772
public function dispatchAction(Order $order)
    {
        $em = $this->getDoctrine()->getEntityManager();

        $order->dispatchBySeller($this->get('exchange_manager')->getExchange());

        $em->persist($order);
        $em->flush();

        $this->get('notifier')->notify(new OrderDispatchedBySellerEvent($order), $this->getUser());

        return $this->redirect($this->generateUrl('Order_show', array(
            'id' => $order->getNumberForPath()
        )));
    }
240941
public function hold(OrderInterface $order): void
    {
        $this->lockProductVariants($order);

        $this->decoratedOperator->hold($order);
    }
426827
protected function getFormParameters(OrderInterface $order)
    {
        return [
            'PSPID' => $this->getOption('pspid'),
            'orderId' => $order->getReference(),
            'amount' => $order->getTotalInc() * 100,
            'currency' => $order->getCurrency()->getLabel(),
            'language' => $order->getLocale(),
            'CN' => $order->getBillingName(),
            'EMAIL' => $order->getBillingEmail(),
            'ownerZIP' => $order->getBillingPostcode(),
            'owneraddress' => $this->getAddress($order),
            'ownercty' => $order->getBillingCity(),
            'ownertelno' => $order->getBillingPhone() ?: $order->getBillingMobile(),

            'homeurl' => $this->getOption('home_url'),
            'catalogurl' => $this->getOption('catalog_url'),

            'COMPLUS' => '',
            'PARAMPLUS' => 'bank='.$this->getCode(),
            'PARAMVAR' => '',

            'PM' => 'CreditCard',
            'WIN3DS' => 'MAINW',
            'PMLIST' => 'VISA;MasterCard;CB',
            'PMListType' => 2,

            'accepturl' => $this->generateAbsoluteUrlFromOption('url_callback', $order),
            'declineurl' => $this->generateAbsoluteUrlFromOption('url_callback', $order),
            'exceptionurl' => $this->generateAbsoluteUrlFromOption('url_return_ko', $order),
            'cancelurl' => $this->generateAbsoluteUrlFromOption('url_return_ko', $order),

            'operation' => $this->getOperation(),
        ];
    }
617466
protected function _setAddresses( MShop_Order_Item_Base_Interface $order, MShop_Order_Item_Interface $item )
	{
		$addresses = $order->getAddresses();

		if( empty( $addresses ) && $this->_getConfigValue( 'autofill.orderaddress', true ) == true )
		{
			$manager = MShop_Factory::createManager( $this->_getContext(), 'order/base/address' );
			$search = $manager->createSearch();
			$search->setConditions( $search->compare( '==', 'order.base.address.baseid', $item->getBaseId() ) );
			$addresses = $manager->searchItems( $search );

			foreach( $addresses as $address ) {
				$order->setAddress( $address, $address->getType() );
			}
		}
	}
1320482
public function generate(OrderInterface $order)
    {
        if (12 !== \strlen($order->getReference())) {
            throw new \RuntimeException('Invalid reference length');
        }

        return substr($order->getReference(), -6);
    }
1250855
public function order($order)
    {
        $order = $this->prepareNames(func_get_args(),false);
        $this->order = $order;
        return $this;
    }
687428
@Override
	public void removeByCommerceOrderId(long commerceOrderId) {
		for (CommerceOrderItem commerceOrderItem : findByCommerceOrderId(
				commerceOrderId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
			remove(commerceOrderItem);
		}
	}
318162
private function getCurrentShippingMethodCostsCollection(OrderInterface $order) : Collection
    {
        return $this->methodProvider->getShippingMethodCosts($order->getShippingMethod(), new OrderContext($order));
    }
470756
public function copyFrom( MShop_Order_Item_Base_Address_Interface $item )
	{
		$this->setCompany( $item->getCompany() );
		$this->setVatID( $item->getVatID() );
		$this->setSalutation( $item->getSalutation() );
		$this->setTitle( $item->getTitle() );
		$this->setFirstname( $item->getFirstname() );
		$this->setLastname( $item->getLastname() );
		$this->setAddress1( $item->getAddress1() );
		$this->setAddress2( $item->getAddress2() );
		$this->setAddress3( $item->getAddress3() );
		$this->setPostal( $item->getPostal() );
		$this->setCity( $item->getCity() );
		$this->setState( $item->getState() );
		$this->setCountryId( $item->getCountryId() );
		$this->setLanguageId( $item->getLanguageId() );
		$this->setTelephone( $item->getTelephone() );
		$this->setTelefax( $item->getTelefax() );
		$this->setEmail( $item->getEmail() );
		$this->setWebsite( $item->getWebsite() );
		$this->setFlag( $item->getFlag() );
	}
1155051
public function transformFromOrder(OrderInterface $order, InvoiceInterface $invoice)
    {
        $event = new OrderTransformEvent($order);
        $this->eventDispatcher->dispatch(TransformerEvents::PRE_ORDER_TO_INVOICE_TRANSFORM, $event);

        $invoice->setName($order->getBillingName());
        $invoice->setAddress1($order->getBillingAddress1());
        $invoice->setAddress2($order->getBillingAddress2());
        $invoice->setAddress3($order->getBillingAddress3());
        $invoice->setCity($order->getBillingCity());
        $invoice->setCountry($order->getBillingCountryCode());
        $invoice->setPostcode($order->getBillingPostcode());

        $invoice->setEmail($order->getBillingEmail());
        $invoice->setFax($order->getBillingFax());
        $invoice->setMobile($order->getBillingMobile());
        $invoice->setPhone($order->getBillingPhone());
        $invoice->setReference($order->getReference());

        $invoice->setCurrency($order->getCurrency());
        $invoice->setCustomer($order->getCustomer());
        $invoice->setTotalExcl($order->getTotalExcl());
        $invoice->setTotalInc($order->getTotalInc());

        $invoice->setPaymentMethod($order->getPaymentMethod());

        $invoice->setLocale($order->getLocale());

        foreach ($order->getOrderElements() as $orderElement) {
            $invoiceElement = $this->createInvoiceElementFromOrderElement($orderElement);
            $invoiceElement->setInvoice($invoice);
            $invoice->addInvoiceElement($invoiceElement);
        }

        if ($order->getDeliveryCost() > 0) {
            $this->addDelivery($invoice, $order);
        }

        $invoice->setStatus(InvoiceInterface::STATUS_OPEN);

        $event = new InvoiceTransformEvent($invoice);
        $this->eventDispatcher->dispatch(TransformerEvents::POST_ORDER_TO_INVOICE_TRANSFORM, $event);
    }
483583
public function cancel($purchaseOrderId, $order)
    {
        if(!is_numeric($purchaseOrderId)){
            throw new \Exception("purchaseOrderId must be numeric",1448480746);
        }

        $schema = [
            '/orderCancellation' => [
                'namespace' => 'ns3',
                'childNamespace' => 'ns3',
            ],
            '/orderCancellation/orderLines' => [
                'sendItemsAs' => 'orderLine',
            ],
            '/orderCancellation/orderLines/orderLine/orderLineStatuses' => [
                'sendItemsAs' => 'orderLineStatus',
            ],
            '@namespaces' => [
                'ns3' => 'http://walmart.com/mp/v3/orders'
            ],
        ];

        $a2x = new A2X($order, $schema);
        $xml = $a2x->asXml();
        
        return $this->cancelOrder([
            'purchaseOrderId' => $purchaseOrderId,
            'order' => $xml,
        ]);
    }
800258
private function findItemBySubject(OrderInterface $order, $subject)
    {
        return $this->findTransformedItem($order, $this->itemHelper->transform($subject));
    }
109740
private function getOrderUserDefaultAddress(OrderInterface $order)
    {
        if (null === $user = $order->getUser()) {
            throw new OrderException('User is not set.');
        }
        if (null === $address = $user->getAddresses()->first()) { // TODO Default address
            throw new OrderException('Unable to find the user default address.');
        }
        return $address;
    }