From 4e2127ac8e50c36b07fa9950930d8ffc0aced397 Mon Sep 17 00:00:00 2001 From: Hans Mackowiak Date: Fri, 18 Oct 2024 14:45:49 +0200 Subject: [PATCH] Update Mage_SalesRule_Model_Quote_Discount * 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 c6fe7f7cd68..8d81e9e81ef 100644 --- a/app/code/core/Mage/SalesRule/Model/Quote/Discount.php +++ b/app/code/core/Mage/SalesRule/Model/Quote/Discount.php @@ -63,7 +63,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) { @@ -78,9 +78,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); @@ -91,6 +88,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); } } @@ -142,7 +141,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');