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?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityIn 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?
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);
}
}