addProducts example

->first();

        static::assertInstanceOf(OrderEntity::class$order);
        static::assertInstanceOf(TagCollection::class$order->getTags());
        static::assertContains($ids->get('tag-1')$order->getTags()->getIds());
        static::assertContains($ids->get('tag-2')$order->getTags()->getIds());
    }

    private function placeOrder(IdsCollection $ids): void
    {
        $cart = $this->cartService->createNew($this->salesChannelContext->getToken());
        $cart = $this->addProducts($cart$ids);

        $ids->set('order', $this->cartService->order($cart$this->salesChannelContext, new RequestDataBag()));
    }

    private function addProducts(Cart $cart, IdsCollection $ids): Cart
    {
        $taxIds = $this->salesChannelContext->getTaxRules()->getIds();
        $ids->set('t1', (string) array_pop($taxIds));

        $this->productRepository->create([
            (new ProductBuilder($ids, 'product'))
                
return $event;
    }

    /** * @param array<int, string[]>|null $productDownloads */
    private function placeOrder(?array $productDownloads = null): string
    {
        $productDownloads ??= [[]];

        $cart = $this->cartService->createNew($this->salesChannelContext->getToken());
        $cart = $this->addProducts($cart$productDownloads);

        return $this->cartService->order($cart$this->salesChannelContext, new RequestDataBag());
    }

    /** * @param array<int, string[]> $productDownloads */
    private function assertOrderWithoutGrantedAccess(string $orderId, array $productDownloads): string
    {
        $criteria = new Criteria([$orderId]);
        $criteria->addAssociation('lineItems.downloads');
        
Home | Imprint | This part of the site doesn't use cookies.