From 615b0d164f0a0dcbe9ba974bcab362486944158d Mon Sep 17 00:00:00 2001 From: Hans Mackowiak Date: Mon, 30 Dec 2024 08:42:45 +0100 Subject: [PATCH] Update Mage_SalesRule_Model_Quote_Discount (#4293) * 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 --- app/code/core/Mage/SalesRule/Model/Quote/Discount.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/code/core/Mage/SalesRule/Model/Quote/Discount.php b/app/code/core/Mage/SalesRule/Model/Quote/Discount.php index b4d2a963f96..c2e25dc5f10 100644 --- a/app/code/core/Mage/SalesRule/Model/Quote/Discount.php +++ b/app/code/core/Mage/SalesRule/Model/Quote/Discount.php @@ -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) { @@ -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); @@ -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); } } @@ -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');