B-219 Sec-55 Noida, India
+918010221733

Extra Fee Shopping Cart Price Rules Magento

Under the Promotions tab in your admin panel:

It’s cool but it’s not cool enough. What I wanted to do is to set a surcharge for one payment method. I needed to add a charge in PayaPal method.
So I found the way you can set negative discounts (what means a surcharge) in the cart total price.

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 the line:

//check if discount amount > 0
if ((int)$this->getDiscountAmount() < 0) {
Mage::throwException(Mage::helper(‘rule’)->__(‘Invalid discount amount.));
}

Just add some bars // to comment the code:

//check if discount amount > 0
//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
Look for:

$fieldset->addField(‘discount_amount’, ‘text’, array(
‘name’ => ‘discount_amount’,
‘required’ => true,
class=> ‘validatenotnegativenumber’,
‘label’ => Mage::helper(’salesrule’)->__(‘Discount amount’),

And again comment like this:

$fieldset->addField(‘discount_amount’, ‘text’, array(
‘name’ => ‘discount_amount’,
‘required’ => true,
// ‘class’ => ‘validate-not-negative-number’,
‘label’ => Mage::helper(’salesrule’)->__(‘Discount amount’),

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)”

Done! Now you’re free to set negative values in the input field:

Fixed amount discount for whole cart
If you select this option the code above will not work entirely.

(Visited 82 times, 1 visits today)

Leave a reply

You must be logged in to post a comment.