Skip to content

Commit

Permalink
Update Mage_SalesRule_Model_Quote_Discount (#4293)
Browse files Browse the repository at this point in the history
* DiscountDescription should only be string or null (not array)
* strlen needs a type check for string before
* sales_quote_address_discount_item needs to be done after calculator->process
  • Loading branch information
Hanmac authored Dec 30, 2024
1 parent 4db86e4 commit 615b0d1
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions app/code/core/Mage/SalesRule/Model/Quote/Discount.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function collect(Mage_Sales_Model_Quote_Address $address)
$this->_calculator->init($store->getWebsiteId(), $quote->getCustomerGroupId(), $quote->getCouponCode());
$this->_calculator->initTotals($items, $address);

$address->setDiscountDescription([]);
$address->setDiscountDescription('');
/** @var Mage_Sales_Model_Quote_Item[] $items */
$items = $this->_calculator->sortItemsByPriority($items);
foreach ($items as $item) {
Expand All @@ -79,9 +79,6 @@ public function collect(Mage_Sales_Model_Quote_Address $address)
continue;
}

$eventArgs['item'] = $item;
Mage::dispatchEvent('sales_quote_address_discount_item', $eventArgs);

if ($item->getHasChildren() && $item->isChildrenCalculated()) {
foreach ($item->getChildren() as $child) {
$this->_calculator->process($child);
Expand All @@ -92,6 +89,8 @@ public function collect(Mage_Sales_Model_Quote_Address $address)
}
} else {
$this->_calculator->process($item);
$eventArgs['item'] = $item;
Mage::dispatchEvent('sales_quote_address_discount_item', $eventArgs);
$this->_aggregateItemDiscount($item);
}
}
Expand Down Expand Up @@ -143,7 +142,7 @@ public function fetch(Mage_Sales_Model_Quote_Address $address)

if ($amount != 0) {
$description = $address->getDiscountDescription();
if (strlen($description)) {
if (is_string($description) && strlen($description)) {
$title = Mage::helper('sales')->__('Discount (%s)', $description);
} else {
$title = Mage::helper('sales')->__('Discount');
Expand Down

0 comments on commit 615b0d1

Please # to comment.