Question

I want to add to sales rules for cart a rule where to add subtotal with TAX because I cannot relay on subtotal without TAX as I have products with different TAX class and different VAT values.

For example I have a product with VAT 19% and a product with VAT 9%, the I cannot trust the subtotal without TAX value, as it will depend on what type of products I add to the cart, in order for the rule to work correctly.

I want to apply a rule for subtotal bigger than 200 but I need to have subtotal with TAX.

How can I do this?

No correct solution

OTHER TIPS

You could try something like this as a rewrite. I'm assuming you already know how to write a custom module.

/etc/config.xml


<config>
    <global>
        <models>
            <salesrule>
                <rewrite>      
                      <rule_condition_address>Vendor_Module_Model_SalesRule_Rule_Condition_Address</rule_condition_address>
                </rewrite>
            </salesrule>
        </models>
    </global>
</config>

Rewrite class

class Vendor_Module_Model_SalesRule_Rule_Condition_Address extends Mage_SalesRule_Model_Rule_Condition_Address
{
    public function loadAttributeOptions()

    {

        parent::loadAttributeOptions();

        $attributes = $this->getAttributeOption();

        $attributes['base_subtotal_with_tax'] = Mage::helper('salesrule')->__('Subtotal after tax');

        $this->setAttributeOption($attributes);

        return $this;

    }

    /**
     * (non-PHPdoc)
     * @see Mage_SalesRule_Model_Rule_Condition_Address::getInputType()
     */

    public function getInputType()

    {

        if ($this->getAttribute() == 'base_subtotal_with_tax')

            return 'numeric';

        return parent::getInputType();

    }

    /**
     * Add field "base_subtotal_with_tax" to address.
     * It is need to validate the "base_subtotal_with_tax" attribute
     * @see Mage_SalesRule_Model_Rule_Condition_Address::validate()
     */

    public function validate(Varien_Object $address)

    {


        $subAfterDiscount = // code to calculate subtotal with tax

        $address->setData('base_subtotal_with_tax', $subAfterDiscount);

        return parent::validate($address);

    }

}
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top