Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento: showing prices ex/inc TAX/VAT depending on customer group

Tags:

magento

Previously I have implemented a 'trade only' store front that shows both in and ex-VAT prices for trade customers. They still get billed the VAT, it is just the catalog shows ex-VAT prices as well as the regular inc VAT prices.

I would like to be able to implement the same functionality without creating a new store front, i.e. if someone is in the 'trade' customer group, they get prices shown inc and ex vat. They are still on the same tax rate as everyone else, so I am not looking to have a 0% tax group, what I want is just to be able to switch the prices based on their group. This also includes the labels, so there isn't just a price but a clear indication of inc/ex VAT/TAX.

It took me a while to Google this with 'tax' instead of 'VAT', however, to date I haven't found many clues as to where to start. If there is a reason why this cannot be done easily then I would like to know. Failing that, if there is a frontend hack to try, e.g. some conditional prototype to un-css-hide the prices/labels then that will have to be the route to go.

EDIT

Inspired by Clockworkgeek I did this, not yet the perfect module solution, but something that works for me for now:

Cloned core file to app/code/local/Mage/Tax/Model/Config.php and updated the getPriceDisplayType function:

public function getPriceDisplayType($store = null)
{   $customer = Mage::helper('customer')->getCustomer();
    if ($customer->getGroupId() > 1) {
        return self::DISPLAY_TYPE_BOTH;
    } else {
    return (int)Mage::getStoreConfig(self::CONFIG_XML_PATH_PRICE_DISPLAY_TYPE, $store);
    }
}

This relies on 0 being not logged in, 1 being normal customers and any 'special' group higher than that. I did not think it was working at first, but then I logged in...

like image 319
ʍǝɥʇɐɯ Avatar asked Dec 16 '11 10:12

ʍǝɥʇɐɯ


1 Answers

There is a config setting for whether to include or exclude tax but it is not customer-specific. I believe the most direct way would be to override the point where this is read. The following is pseudocode...

class Your_Module_Model_Config extends Mage_Tax_Model_Config
{
    public function getPriceDisplayType($store = null)
    {
        $customer = Mage::helper('customer')->getCustomer();
        if ($customer->getGroupId() == 'TRADE') {
            return self::DISPLAY_TYPE_BOTH;
        }
        return parent::getPriceDisplayType($store);
    }
}
like image 60
clockworkgeek Avatar answered Oct 23 '22 15:10

clockworkgeek