I've got this problem that I can't solve. Partly because I can't explain it with the right terms. I'm new to this so sorry for this clumsy question.
Below you can see an overview of my goal.
I'm using Magento CE 1.8.1.0
How do i override the Shopping Cart Price Rule.
In core files app/code/core/Mage/SalesRule/Model/Validator.php in this file Default Code they written. Line 331 to 349 code is here.
$step = $rule->getDiscountStep();
if ($step) {
$qty = floor($qty/$step)*$step;
}
$_rulePct = $rulePercent/100;
$discountAmount = ($qty * $itemPrice - $item->getDiscountAmount()) * $_rulePct;
$baseDiscountAmount = ($qty * $baseItemPrice - $item->getBaseDiscountAmount()) * $_rulePct;
//get discount for original price
$originalDiscountAmount = ($qty * $itemOriginalPrice - $item->getDiscountAmount()) * $_rulePct;
$baseOriginalDiscountAmount = ($qty * $baseItemOriginalPrice - $item->getDiscountAmount()) * $_rulePct;
if (!$rule->getDiscountQty() || $rule->getDiscountQty()>$qty) {
$discountPercent = min(100, $item->getDiscountPercent()+$rulePercent);
$item->setDiscountPercent($discountPercent);
}
This code i want to Edit like this
$step = $rule->getDiscountStep();
if ($step) {
$qty = floor($qty/$step)*$step;
}
$_rulePct = $rulePercent/100;
$discountAmount = ($qty * $itemPrice - $item->getDiscountAmount()) * $_rulePct;
$baseDiscountAmount = ($qty * $baseItemPrice - $item->getBaseDiscountAmount()) * $_rulePct;
//get discount for original price
$originalDiscountAmount = ($qty * $itemOriginalPrice - $item->getDiscountAmount()) * $_rulePct;
$maxlimitamount = 1000; // maximum amount entered in admin panel
if($originalDiscountAmount > $maxlimitamount)
{
$originalDiscountAmount = 1000;
}
$baseOriginalDiscountAmount = ($qty * $baseItemOriginalPrice - $item->getDiscountAmount()) * $_rulePct;
if (!$rule->getDiscountQty() || $rule->getDiscountQty()>$qty) {
$discountPercent = min(100, $item->getDiscountPercent()+$rulePercent);
$item->setDiscountPercent($discountPercent);
}
My Custom Module config.xml
<global>
<models>
<salesrule_resource>
<rewrite>
<rule_collection>SCPR_Pricerule_Model_Resource_Rule_Collection</rule_collection>
</rewrite>
</salesrule_resource>
</models>
</global>
How do i achieve this ?
Any Ideas ?