Under the Promotions tab in your admin panel there is a shopping cart price rule int this you can't add minus value to for rule. But now it is possible to add minus value and this value was added as extra fee to cart and checkout.
Note: we are going to change Magento Core files. Please make a backup of your files before continuing.
1). Go to app/code/core/Mage/Rule/Model/Rule.php
Find this:
if ((int)$this->getDiscountAmount() < 0) { Mage::throwException(Mage::helper('rule')->__('Invalid discount amount.')); }
Just add some bars // to comment the code: it look like this
//if ((int)$this->getDiscountAmount() < 0) { //Mage::throwException(Mage::helper('rule')->__('Invalid discount amount.')); //}
2). Now go to: app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Actions.php
find this
'class' => 'validate-not-negative-number',
and coomment it
//'class' => 'validate-not-negative-number',
3). Translate the discount word. Go to app/locale/es_ES (I'm using the Spainish translation so maybe yours would be en_US) Find a file called Mage_Sales.csv. Inside look for the word discount you will find something like:
"Discount (%s)","Discount (%s)"
You can change the value in order to show your own text. For example:
"Discount (%s)","Extra Fee (%s)"
4). If you want to apply this rule to whole cart than do this goto app\code\core\Mage\SalesRule\Model\validator.php find this below code it is near to line 280 to 300.
case 'cart_fixed': $cartRules = $address->getCartFixedRules(); if (!isset($cartRules[$rule->getId()]) > 0) { $cartRules[$rule->getId()] = $rule->getDiscountAmount(); } if ($cartRules[$rule->getId()]) {
replace by
case 'cart_fixed': $cartRules = $address->getCartFixedRules(); if (!isset($cartRules[$rule->getId()])) { $cartRules[$rule->getId()] = $rule->getDiscountAmount(); } if ($cartRules[$rule->getId()]) {
I tried this but I still can`t add negative amount for discount. I have magento 1.5.1.0. I have cleared the chache.
ReplyDeleteAny advice?
Hello HeidisHobbystuggu,
ReplyDeleteI have used it in magento 1.4.0. If i got any solution than i will surely inform you.
Thanks, I figured it out myself. I just made the same commenting in the local files too.
ReplyDeleteThis is very good tutorial, this was also one of the primary problems for many of our Magento customers too. Finally, we have come up with a Magento Extra fee extension (http://www.magikcommerce.com/magento-extra-fee-extension) which helps creating unlimited extra fee for different fee types.
ReplyDeleteI hope this will help your readers.
Thanks
In 1.7 no condition found in Rule.php
ReplyDelete:) got it : magento 1.7 : go to /app/code/core/Mage/Rule/Model/Abstract.php and edit line No. 94 to 96....
ReplyDeleteDashiki Shirt Store for sale provides hundreds of Color Dashiki shirts and pants. We are biggest retail and wholesale of dashiki shirts to plus size dashiki
ReplyDelete