In my magento website I have products prices are including tax of 12.5%. If the customer is B2B (will come to know if he selects he has c form in the onepagecheckout) then I want to recalculate tax as follows:

  • reduce the 12.5% from the product price. i.e. if my product price is 50000 then reduce 12.5% from the 50000
  • and then add the 2% on the price after reduction of 12.5%

For example:

Product Price : 50000
Base Price: 50000 - 12.5% of Product Price
CST (2%): 2% of the Base Price
Total: Base Price + CST

Please guide me.


What about setting up a customer group for all the B2B customers and tax rules?

|improve this answer|||||

Custom product pricing is achievable by writing a module to extend the getFinalPrice method in Mage_Catalog_Model_Product_Type_Price.

Depending on the type of products you have you may need to extend other pricing code as there are different price methods for configurable and simple products.

Here is an exceprt from a module I wrote that discounts the final product price by a fixed percentage for B2B customers.

First we extend the getFinalPrice method

class PAJ_Price_Model_Simple extends Mage_Catalog_Model_Product_Type_Price
    public function getFinalPrice($qty = null, $product)

        if (is_null($qty) && !is_null($product->getCalculatedFinalPrice())) {
            return $product->getCalculatedFinalPrice();

        $finalPrice = $this->getBasePrice($product, $qty);

        Mage::dispatchEvent('catalog_product_get_final_price', array('product' => $product, 'qty' => $qty));

        $finalPrice = $product->getData('final_price');
        $finalPrice = $this->_applyOptionsPrice($product, $qty, $finalPrice);
        $finalPrice = max(0, $finalPrice);

        // get B2B Final Price
        if ($_B2BFinalPrice=Mage::helper('PAJ_Price/B2BFinalPrice')->getB2BFinalPrice($product,$finalPrice)) { return max(0, $_B2BFinalPrice); }


        return $finalPrice;

As you can see the price calculation is now performed in a helper method B2BFinalPrice. Here you can apply logic that determines whether the customer is B2B i.e. member of a specific group, and then in your example perform the calculation for the final price:

class PAJ_Price_Helper_B2BFinalPrice extends Mage_Core_Helper_Abstract
    public function getB2BFinalPrice($product,$finalPrice)
                    $basePrice=$finalPrice - ($finalPrice * (12.5/100));
                    $cst=$basePrice + ($basePrice * (2/100));


                    return $finalPrice;

Note that this is changing the product final price, not the tax calculation. In this example tax would then be calculated on the final price.

If you are displaying other prices, such as tier prices then you would also need to perform this calculation in your frontend theme to display tier pricing for B2B customers correctly.

To implement a solution like this you need to be familiar with creating custom modules and extending Magento core code.

You also need to do a lot of testing to ensure you are getting the correct results. You do not want to make any mistakes with product pricing!

I haven't looked but you may also find something similar available from Magento connect.

Hope this helps.

|improve this answer|||||

You may please refer Vat exempt by Milople. It removes tax on certain condition may be I guess your Requirement can be achieve by customizing the extension a bit.

|improve this answer|||||

You can add a shopping price rule under which can be found under:

Promotions->Shopping Cart Price Rule 

and then place that rule at certain customer group that you will create. The customer group is located under:

Customers->Customer Groups
|improve this answer|||||

I had done this with myself by adding custom logic in the sales_quote_collect_totals_before observer

Step 1:- Declare Observer in config.xml


Step 2:- Declare Observer's function in Observer.php

public function newTax($observer){
    $quote = $observer->getQuote();
    foreach ($quote->getAllItems() as $quoteItem) {
        if ($quote->getData('customer_cform') === 'true') { // check if customer is b2b customer and selects for the cform option
            $product = $quoteItem->getProduct();
            $product->setTaxClassId(0); // tax class removed.now the price is with no tax
            $basePrice = $product->getFinalPrice() / (1+(12.5/100)); // calcuated 12.5 % of total price and subtracted from the price to get base price
            $final_cst_price = $basePrice * (2/100); // added 2% in the base price to get fincal cst price
            $finalPrice = $basePrice + $final_cst_price;
            $product->setTaxClassId(8); // here 8 is a tax rule defined in the magento admin just to show the split of base price and tax (2%) in the cart page and checkout page
|improve this answer|||||

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.