taxRuleNotFound example



        $taxId = (string) $request->request->get('taxId');
        $price = (float) $request->request->get('price');
        $quantity = $request->request->getInt('quantity', 1);
        $output = (string) $request->request->get('output', 'gross');
        $preCalculated = $request->request->getBoolean('calculated', true);

        $taxes = $this->taxRepository->search(new Criteria([$taxId])$context);
        $tax = $taxes->get($taxId);
        if (!$tax instanceof TaxEntity) {
            throw CartException::taxRuleNotFound($taxId);
        }

        $data = $this->calculatePrice($price$tax->getTaxRate()$quantity$output$preCalculated);

        return new JsonResponse(
            ['data' => $data]
        );
    }

    #[Route(path: 'api/_action/calculate-prices', name: 'api.action.calculate-prices', methods: ['POST'])]     public function calculatePrices(Request $request, Context $context): JsonResponse
    {
Home | Imprint | This part of the site doesn't use cookies.