3

In shopping cart price rule we have condition as subtotal but I want condition for final price ie. total cart price after coupon code applied.

How to do that?

  • "after coupon code is applied"? so you're trying to add two shopping cart rules, right? one with coupon code and other after applying coupon code – Shathish Oct 21 '13 at 10:51
  • yes trying to use two shopping cart rules. in one of the rule I want condition based on discounted cart price. Here is situation, we have free shipping discount cart price rule which applicable if total cart price is above specific value but if customer use coupon code then customer get free shipping benefit even if total cart price is below threshold value as free shipping rule is based on subtotal. – Sandesh Oct 21 '13 at 11:25
2

I followed the instructions in the following post:

https://stackoverflow.com/a/16808826

..which works on my Magento CE 1.7.0.2 install. You end up with an extra condition in your Shopping Cart Price Rules, "Subtotal with Discount" which will correctly return the current subtotal minus any existing discounts (perfect for free shipping rules!)

Hope this helps.

edit: As requested below, here is the code - you'd need to rewrite Mage_SalesRule_Model_Rule_Condition_Address and amend the class name etc accordingly:

class YourCompany_SalesRule_Model_Rule_Condition_Address extends Mage_SalesRule_Model_Rule_Condition_Address {

    /**
     * (non-PHPdoc)
     * @see Mage_SalesRule_Model_Rule_Condition_Address::loadAttributeOptions()
     */
    public function loadAttributeOptions()
    {
        parent::loadAttributeOptions();

        $attributes = $this->getAttributeOption();

        $attributes['base_subtotal_with_discount'] = Mage::helper('salesrule')->__('Subtotal with discount');

        $this->setAttributeOption($attributes);

        return $this;
    }


    /**
     * (non-PHPdoc)
     * @see Mage_SalesRule_Model_Rule_Condition_Address::getInputType()
     */
    public function getInputType()
    {
        if ($this->getAttribute() == 'base_subtotal_with_discount')
            return 'numeric';

        return parent::getInputType();
    }


    /**
     * Add field "base_subtotal_with_discount" to address.
     * It is need to validate the "base_subtotal_with_discount" attribute
     * 
     * @see Mage_SalesRule_Model_Rule_Condition_Address::validate()
     */
    public function validate(Varien_Object $address)
    {
        $address->setBaseSubtotalWithDiscount($address->getBaseSubtotal() + $address->getDiscountAmount());

        return parent::validate($address);
    }
}
  • 2
    feel free to add the code mentioned in the answer here as links can die. – David Manners Jul 9 '14 at 14:49
  • I am able to do this with base_subtotal. However when I try with base_subtotal_with_discount, the salesrule in admin does not really show anything. Where do I add base_subtotal_with_discount? – Thang Pham Jul 24 '14 at 9:14

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.