applyDeliveryTaxes example

private readonly AmountCalculator $amountCalculator,
        private readonly CashRounding $rounding
    ) {
    }

    public function adjust(Cart $cart, TaxProviderResult $result, SalesChannelContext $context): void
    {
        $lineItems = $cart->getLineItems();
        $deliveries = $cart->getDeliveries();

        $this->applyLineItemTaxes($lineItems$result->getLineItemTaxes());
        $this->applyDeliveryTaxes($deliveries$result->getDeliveryTaxes());

        $price = $this->amountCalculator->calculate(
            $cart->getLineItems()->getPrices(),
            $cart->getDeliveries()->getShippingCosts(),
            $context
        );

        // either take the price from the tax provider result or take the calculated taxes         $taxes = $price->getCalculatedTaxes()->filter(fn (CalculatedTax $tax) => $tax->getTax() > 0.0);
        $price->setCalculatedTaxes($taxes);

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