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:
Just add some bars // to comment the code:
2. Now go to: app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Actions.php
Look for:
And again comment like this:
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:
You can change the value in order to show your own text. For example:
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.
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.’));
}
if ((int)$this->getDiscountAmount() < 0) {
Mage::throwException(Mage::helper(‘rule’)->__(‘Invalid discount amount.’));
}
//check if discount amount > 0
//if ((int)$this->getDiscountAmount() < 0) {
//Mage::throwException(Mage::helper(‘rule’)->__(‘Invalid discount amount.’));
//}
//if ((int)$this->getDiscountAmount() < 0) {
//Mage::throwException(Mage::helper(‘rule’)->__(‘Invalid discount amount.’));
//}
Look for:
$fieldset->addField(‘discount_amount’, ‘text’, array(
‘name’ => ‘discount_amount’,
‘required’ => true,
‘class’ => ‘validate-not-negative-number’,
‘label’ => Mage::helper(’salesrule’)->__(‘Discount amount’),
‘name’ => ‘discount_amount’,
‘required’ => true,
‘class’ => ‘validate-not-negative-number’,
‘label’ => Mage::helper(’salesrule’)->__(‘Discount amount’),
$fieldset->addField(‘discount_amount’, ‘text’, array(
‘name’ => ‘discount_amount’,
‘required’ => true,
// ‘class’ => ‘validate-not-negative-number’,
‘label’ => Mage::helper(’salesrule’)->__(‘Discount amount’),
‘name’ => ‘discount_amount’,
‘required’ => true,
// ‘class’ => ‘validate-not-negative-number’,
‘label’ => Mage::helper(’salesrule’)->__(‘Discount amount’),
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)"
"Discount (%s)","Extra Fee (%s)"
If you select this option the code above will not work entirely.
No comments:
Post a Comment