Skip to content

Commit 615b0d1

Browse files
authored
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
1 parent 4db86e4 commit 615b0d1

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

app/code/core/Mage/SalesRule/Model/Quote/Discount.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function collect(Mage_Sales_Model_Quote_Address $address)
6464
$this->_calculator->init($store->getWebsiteId(), $quote->getCustomerGroupId(), $quote->getCouponCode());
6565
$this->_calculator->initTotals($items, $address);
6666

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

82-
$eventArgs['item'] = $item;
83-
Mage::dispatchEvent('sales_quote_address_discount_item', $eventArgs);
84-
8582
if ($item->getHasChildren() && $item->isChildrenCalculated()) {
8683
foreach ($item->getChildren() as $child) {
8784
$this->_calculator->process($child);
@@ -92,6 +89,8 @@ public function collect(Mage_Sales_Model_Quote_Address $address)
9289
}
9390
} else {
9491
$this->_calculator->process($item);
92+
$eventArgs['item'] = $item;
93+
Mage::dispatchEvent('sales_quote_address_discount_item', $eventArgs);
9594
$this->_aggregateItemDiscount($item);
9695
}
9796
}
@@ -143,7 +142,7 @@ public function fetch(Mage_Sales_Model_Quote_Address $address)
143142

144143
if ($amount != 0) {
145144
$description = $address->getDiscountDescription();
146-
if (strlen($description)) {
145+
if (is_string($description) && strlen($description)) {
147146
$title = Mage::helper('sales')->__('Discount (%s)', $description);
148147
} else {
149148
$title = Mage::helper('sales')->__('Discount');

0 commit comments

Comments
 (0)