0

I am trying to override the shipping tax amount for the for the checkout, eg:

enter image description here

I have created some custom shipping methods which are pulling in from Shipper HQ but I would like to change the VAT rate being used to calculated shipping. At the moment it's set to the standard 20% but I need to change it so that the Shipping Excl. Tax field will reflect the calculated VAT according my custom VAT rate, if that makes sense?

I have tried to manually change the shipping_tax_amount using the following code in the \Magento\Quote\Model\Quote\Address model:

foreach ($shippingRates as $shippingRate) {
    $rate = $this->_addressRateFactory->create()->importShippingRate($shippingRate);
    if (!$item) {
        $this->addShippingRate($rate);
    }

    if ($this->getShippingMethod() == $rate->getCode()) {
        if ($item) {
            $item->setBaseShippingAmount($rate->getPrice());
        } else {

            /** @var \Magento\Store\Api\Data\StoreInterface */
            $store = $this->storeManager->getStore();
            $amountPrice = $store->getBaseCurrency()
                ->convert($rate->getPrice(), $store->getCurrentCurrencyCode());

            $this->setBaseShippingAmount($rate->getPrice());
            $this->setShippingAmount($amountPrice);
            $this->setShippingTaxAmount(15.00);
        }

        $found = true;
    }
}

But the values don't seem to change if try put an order through again re-calculating shipping rates etc.

I'd be really grateful for some help with this one. Cheers guys!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.