public function updateCarts(AddressOnCloneEvent $event)
    {
        $originalAddress = $event->getOriginalAddress();
        $clonedAddress = $event->getClonedAddress();
        $carts = $this
            ->cartRepository
            ->findAllCartsWithAddress($originalAddress);

        foreach ($carts as $cart) {
            /**
             * @var CartInterface $cart
             */
            $deliveryAddress = $cart->getDeliveryAddress();
            $billingAddress = $cart->getBillingAddress();

            if (
                $deliveryAddress instanceof AddressInterface
                && $deliveryAddress->getId() == $originalAddress->getId()
            ) {
                $cart->setDeliveryAddress($clonedAddress);
            }

            if (
                $billingAddress instanceof AddressInterface
                && $billingAddress->getId() == $originalAddress->getId()
            ) {
                $cart->setBillingAddress($clonedAddress);
            }

            $this->cartObjectManager->flush($cart);
        }
    }
public function updateCarts(AddressOnCloneEvent $event)
    {
        $originalAddress = $event->getOriginalAddress();
        $clonedAddress = $event->getClonedAddress();
        $carts = $this
            ->cartRepository
            ->findAllCartsWithAddress($originalAddress);

        foreach ($carts as $cart) {
            /**
             * @var CartInterface $cart
             */
            $deliveryAddress = $cart->getDeliveryAddress();
            $billingAddress = $cart->getBillingAddress();

            if (
                $deliveryAddress instanceof AddressInterface
                && $deliveryAddress->getId() == $originalAddress->getId()
            ) {
                $cart->setDeliveryAddress($clonedAddress);
            }

            if (
                $billingAddress instanceof AddressInterface
                && $billingAddress->getId() == $originalAddress->getId()
            ) {
                $cart->setBillingAddress($clonedAddress);
            }

            $this->cartObjectManager->flush($cart);
        }
    }
public function updateCarts ( AddressOnCloneEvent $ event ) { $ originalAddress = $ event -> getOriginalAddress ( ) ; $ clonedAddress = $ event -> getClonedAddress ( ) ; $ carts = $ this -> cartRepository -> findAllCartsWithAddress ( $ originalAddress ) ; foreach ( $ carts as $ cart ) { /**
             * @var CartInterface $cart
             */ $ deliveryAddress = $ cart -> getDeliveryAddress ( ) ; $ billingAddress = $ cart -> getBillingAddress ( ) ; if ( $ deliveryAddress instanceof AddressInterface && $ deliveryAddress -> getId ( ) == $ originalAddress -> getId ( ) ) { $ cart -> setDeliveryAddress ( $ clonedAddress ) ; } if ( $ billingAddress instanceof AddressInterface && $ billingAddress -> getId ( ) == $ originalAddress -> getId ( ) ) { $ cart -> setBillingAddress ( $ clonedAddress ) ; } $ this -> cartObjectManager -> flush ( $ cart ) ; } }
Updates all the carts with the cloned address.

@param AddressOnCloneEvent $event Event
Updates all the carts with the cloned address .