addPromotionLineItem example

$entityRepository,
            $this->orderConverter,
            $this->createMock(CartService::class),
            $entityRepository,
            $entityRepository,
            $entityRepository,
            $this->createMock(Processor::class),
            $this->cartRuleLoader,
            $this->createMock(PromotionItemBuilder::class)
        );

        $recalculationService->addPromotionLineItem($order->getId(), '', $this->context);
    }

    private function orderEntity(): OrderEntity
    {
        $order = new OrderEntity();
        $order->setId(Uuid::randomHex());
        $order->setSalesChannelId(Uuid::randomHex());
        $order->setTaxStatus(CartPrice::TAX_STATE_FREE);
        $order->setStateId(Uuid::randomHex());

        return $order;
    }
$this->recalculationService->addCustomLineItem($orderId$lineItem$context);

        return new Response(null, Response::HTTP_NO_CONTENT);
    }

    #[Route(path: '/api/_action/order/{orderId}/promotion-item', name: 'api.action.order.add-promotion-item', methods: ['POST'])]     public function addPromotionItemToOrder(string $orderId, Request $request, Context $context): Response
    {
        $code = (string) $request->request->get('code');

        $cart = $this->recalculationService->addPromotionLineItem($orderId$code$context);

        return new CartResponse($cart);
    }

    #[Route(path: '/api/_action/order/{orderId}/toggleAutomaticPromotions', name: 'api.action.order.toggle-automatic-promotions', methods: ['POST'])]     public function toggleAutomaticPromotions(string $orderId, Request $request, Context $context): Response
    {
        $skipAutomaticPromotions = (bool) $request->request->get('skipAutomaticPromotions', true);

        $cart = $this->recalculationService->toggleAutomaticPromotion($orderId$context$skipAutomaticPromotions);

        
Home | Imprint | This part of the site doesn't use cookies.