#[Route(path: 'api/_action/calculate-prices', name: 'api.action.calculate-prices', methods: ['POST'])]
public function calculatePrices(Request
$request, Context
$context): JsonResponse
{ if (!
$request->request->
has('taxId'
)) { throw CartException::
taxIdParameterIsMissing();
} $taxId =
$request->request->
getAlnum('taxId'
);
$productPrices =
$request->request->
all('prices'
);
if (empty($productPrices)) { throw CartException::
pricesParameterIsMissing();
} $tax =
$this->taxRepository->
search(new Criteria([$taxId]),
$context)->
get($taxId);
if (!
$tax instanceof TaxEntity
) { throw CartException::
taxRuleNotFound($taxId);
} $data =
[];
$taxRate =
$tax->
getTaxRate();
foreach ($productPrices as $productId =>
$prices) { $calculatedPrices =
[];