1

My store's tax rules should be very easy to set up, but I'm having extreme difficulty finding a way to implement the logic I need.

We are based in Florida, so none of our customers will be charged tax unless they are shipping to the state of Florida. Some of our Florida customers are re-sellers and are exempt from tax.

How can I set up my tax logic like this:

IF (customer is in Florida) {
    THEN IF (customer has VAT) {
        No tax charged
    } ELSE (customer does not have VAT) {
        7% tax is charged
} ELSE (not in Florida) {
    No tax charged
}
1

The initial solution I posted ended up being only a partial solution. A big thanks to Marius for answering this question. With his help and some information from this question, I was able to piece together a working solution.

Summary

I have a single tax rule that encompasses all product & customer tax classes. This is essentially hijacking the tax calculation process to check if the customer is in Florida, and if so, do they have the Tax VAT field filled in?

Code

I extended the Tax Calculation rules by creating a file /app/code/local/Mage/Tax/Model/Calculation.php

Here is the final (working) code block:

public function calcTaxAmount($price, $taxRate, $priceIncludeTax = false, $round = true)
{
    $cust = $this->getCustomer();
    $custId = $cust->getId();
    $vat = $cust->getData('taxvat');

    $custAddress = Mage::getModel('customer/address')->load($cust->default_shipping);
    $custState = $custAddress->getData('region');

    $customerLoggedIn = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getRegion();
    $taxRate = $taxRate / 100;

    if ($priceIncludeTax) {
        $amount = $price * (1 - 1 / (1 + $taxRate));
    } else if (strtoupper($custState) === 'FLORIDA' || strtoupper($customerLoggedIn) === 'FLORIDA') {
        if ($vat) {
            $amount = $price;
        } else {
            $amount = $price * $taxRate;
        }
    } else {
        $amount = 0;
    }

    if ($round) {
        return $this->round($amount);
    }

    return $amount;
}

Your Answer

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

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