-
12-12-2019 - |
题
我想在B2B客户的目录中展示不税的价格,但通常按税款计算。
我知道这可以用第二个商店视图完成,但没有第二个视图,这是可能的吗?
解决方案
即使是答案所接受的问题,我想提供一些额外的建议:
因为我没有创建一个观察者,而是将克隆的生成的app/code/core/Mage/Tax/Model/Config.php
到本地,我已经使用一些附加物更改了getPriceDisplayType
函数。
仅接受答案仅对组ID检查。我进一步走了并检查了税卡类。它是硬件的,但是在后端也可以通过配置设置,当包裹到观察者或扩展时。
我的修改函数看起来像
public function getPriceDisplayType($store = null)
{
$customerGroupId = Mage::getModel('customer/customer')->getGroupId();
$customerGroup = Mage::getModel('customer/group')->load($customerGroupId);
$customerTaxId = $customerGroup->getTaxClassId($customerGroupId);
if ($customerTaxId == 5) {
$this->changeConfigTemp('tax/cart_display/price', '1');
$this->changeConfigTemp('tax/cart_display/subtotal', '1');
$this->changeConfigTemp('tax/display/type', '1');
$this->changeConfigTemp('tax/sales_display/price', '1');
$this->changeConfigTemp('tax/sales_display/subtotal', '1');
$this->changeConfigTemp('tax/display/show_in_catalog', '1');
} else {
return (int)$this->_getStoreConfig(self::CONFIG_XML_PATH_PRICE_DISPLAY_TYPE, $store);
}
}
.
这已经完成了我所需要的所有,直到现在我没有显示或逻辑“错误”。
设置有点“德国喜欢”,因为在包括税收时显示祖母,而其他值为W / O税。希望这也有助于他人。
其他提示
转到系统>配置>税收,查看最后一个标签“显示”。在“显示产品价格”中选择“包括和不包括税”,然后保存配置。
基于 https://github.com/astorm/chaos 我创建了一个改变的观察者根据页面和用户组,tax/calculation/price_includes_tax
对暂时显示价格的配置价值。
这对评论很短,但它可能有助于某人:
class YourThing_TaxChanger_Model_Observer
{
static protected $_hasRun = false;
public function setup($observer)
{
if($this->_shouldBail($observer))
{
return;
}
$roleId = Mage::getSingleton('customer/session')->getCustomerGroupId();
//echo Mage::getSingleton('customer/group')->load($roleId)->getData('customer_group_code');
$page = Mage::app()->getFrontController()->getRequest()->getControllerName();
// check user group and page
if ($roleId == 2 && (in_array($page, array('product', 'category', 'result'))))
{
// show price without tax
$this->changeConfigTemp('tax/calculation/price_includes_tax', '1');
// germansetup tax info
//$this->changeConfigTemp('tax/sales_display/price', Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX);
}
}
/**
* Change a config value without saving it.
*/
protected function changeConfigTemp($path, $value)
{
$config = Mage::getConfig();
$store = Mage::app()->getStore();
$code = $store->getCode();
$config->setNode("stores/$code/" . $path, $value);
}
protected function _shouldBail($observer)
{
$config = Mage::getConfig();
if(!$config)
{
return true;
}
if(Mage::app()->getStore()->isAdmin())
{
return true;
}
return false;
}
}
.