addProductToVersionedOrder example

$order = $this->persistCart($cart);
        $orderId = $order['orderId'];
        $oldTotal = $order['total'];

        // create version of order         $versionId = $this->createVersionedOrder($orderId);
        $versionContext = $this->context->createWithVersionId($versionId);

        $productName = 'Test';
        $productPrice = 10.0;
        $productTaxRate = 19.0;
        $this->addProductToVersionedOrder($productName$productPrice$productTaxRate$orderId$versionId$oldTotal);

        $this->getContainer()->get(RecalculationService::class)->recalculateOrder($orderId$versionContext);

        $criteria = new Criteria();
        $criteria->addFilter(new EqualsFilter('order_delivery.orderId', $orderId));

        /** @var EntityRepository<OrderDeliveryCollection> $orderDeliveryRepository */
        $orderDeliveryRepository = $this->getContainer()->get('order_delivery.repository');
        $deliveries = $orderDeliveryRepository->search($criteria$versionContext);

        $delivery = $deliveries->getEntities()->first();
        
Home | Imprint | This part of the site doesn't use cookies.