Domanda

Vorrei mostrare il prezzo senza tasse nel catalogo per i clienti B2B, ma calcola con tasse come normalmente.

So che questo può essere fatto con una seconda vista ma è possibile senza una seconda vista?

È stato utile?

Soluzione

Anche se è una risposta ha accettato la domanda che voglio dare qualche consiglio aggiuntivo:

Poiché non ho creato un osservatore ma clonato app/code/core/Mage/Tax/Model/Config.php in locale, ho cambiato la funzione getPriceDisplayType con alcune aggiunte.

La risposta accettata controlla solo l'ID del gruppo.Sono andato oltre e controllai il taxclassid.È hardcoded ormai ma potrebbe essere fatto tramite un'impostazione di configurazione anche nel back-end, quando avvolto in un osservatore o un'estensione.

Le mie funzioni modificate sembrano

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);
    }
}
.

Questo ha fatto tutto ciò di cui avevo bisogno e non ho avuto un display o "errore" logico fino ad ora.

Le impostazioni sono un po 'tedesche come "poiché i grandtotali sono visualizzati con tasse incluse mentre altri valori sono w / o tasse.Spero che questo aiuti anche gli altri.

Altri suggerimenti

Vai al sistema> Configurazione> Tasse e lì, cerca l'ultima scheda "Display".In "Visualizza i prezzi dei prodotti" sceglie "compreso ed escluso tasse" e quindi salvare Config.

Basato su https://github.com/storm/chaos ho creato un osservatore che cambiaIl valore di configurazione del tax/calculation/price_includes_tax a temporaneo Mostra prezzi senza tasse in base alla pagina e al gruppo di utenti.

Questo è breve sui commenti ma potrebbe aiutare qualcuno:

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;
    }
}
.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a magento.stackexchange
scroll top