According to HMRC, "the VAT liability [of the shipping charge] is based on the liability of the goods being delivered"*

There does not seem to be a way in Magento of basing the shipping VAT on the tax class of the products in the cart. However, to get an accurate VAT total, that is how they should be calculated.

Is there an extension or workaround that anyone knows of for recent version of Magento CER (i.e. 1.7-1.9)?

1 Answer 1


In the end we wrote an extension that changed the way Magento works for UK shipping, basing the VAT proportion based on the liability of the items in the order. This is how HMRC expects UK shipping tax to be worked out (see https://www.gov.uk/rates-of-vat-on-different-goods-and-services#postage)

The classes/functions that needed to be overridden to make this change were:


In these functions we took the rate calculated by:

$rate = $calc->getRate($addressTaxRequest);

We then multiplied this by a coefficient based on the proportion of taxable items:

    // Iterate over all items with prices to get proportional rate
        $items = $address->getAllItems();
$totalPrice = 0.0;
$totalTax = 0.0;
foreach ($items as $item) {
    // Add to total tax and price
    $totalTax += $item->getTaxAmount();
    $totalPrice += $item->getRowTotalInclTax() - $item->getDiscountAmount();

// Divide total tax by price in order to get weighted tax rate
$weightedTaxRate = ($totalPrice > 0.0) ? ($totalTax / $totalPrice) : 0.0;

// Convert rate to shipping tax rate (invert tax)
$rate = (1.0 / (1.0 - $weightedTaxRate)) - 1.0;

return $rate * 100.0;

This should give the general approach, but note that there is some code to handle edge-cases not included here as it's rather more involved. Also, we had to use conditions in the functions overridden because these core functions have evolved over time so you'd need to base this on the particular version of Magento you are using.

The extension, which is not free, can be found here: https://www.c3media.co.uk/c3-uk-shipping-tax.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.