2

Problem

We are currently implementing the Dots/FastTax plugin to extend from the initial Mage_Tax_Model_Calculation class. By doing so, we are able to provide a dynamic tax rate for both cart estimate tax quote and actual checkout.

The issue, however, is that tax is currently showing on an initial session. In other words, when a user adds an item to the cart and proceeds to checkout cart, you can see a default tax amount. This default tax amount usually is estimated to 8% of the total item cost.

Discussion

The plugin is responsible for one key method extension, that is the calcTaxAmount:

    /**
     * Calculate rated tax based on price and tax rate.
     * If you are using price including tax $priceInclude should be true.
     *
     * @param float $price
     * @param float $taxRate
     * @param boolean $priceIncludeTax
     * @param boolean $round
     * @return float
     */
    public function calcTaxAmount($price, $taxRate, $priceIncludeTax = false, $round = true)
    {
        $taxRate = 0.00;

        if (in_array($this->shippingState, $this->taxableStates)) {
            $dots_helper = Mage::helper('DOTS_FastTax/DOTS');
            $taxRate = $dots_helper->getTaxRate();
        }

        if ($priceIncludeTax) {
            $amount = $price * (1 - 1 / (1 + $taxRate));
        } else {
            $amount = $price * $taxRate;
        }

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

        return $amount;
    }

In the above implementation, we verify that the shipping state (the state to which the product will ship to) is available in a list of pre-configured taxable states (states to which we would like tax to apply). If so, we use a helper object to get the tax rate. The tax returns a decimal value. Since this is the only method to which we extend from the initial object, I am assuming all other behavior is inherited from the parent.

Question

Is there a way to hide the tax rate on cart summary until the user has engaged the Estimate Shipping and Tax Estimate field?

1

Solution

Go to System > Configuration > Sales > Tax > Default Tax Destination Calculation

Set the following options:

  • Default Country: None
  • Default State: *
  • Default Post Code*

This will hide the default tax amount on initial load. Only until a user requests an estimate does the summary update with the appropriate tax amount.

  • Not working for me on CE 1.9.3.0 – Steve Robbins Mar 8 '17 at 19:48
  • @SteveRobbins sorry to hear that. Unfortunately I haven't worked with Magento since this post. I do remember this problem existing and it was a pain trying to find an answer. If you do find something that works, be sure to share it :) – justinpage Mar 8 '17 at 20:51

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.