Skip to content

Commit 927ac76

Browse files
author
Mike Weis
committed
MAGETWO-33857: Tier Prices are displayed rounded up to 4 characters on "Bundle Product" Frontend details page
- fixed
1 parent 38f9431 commit 927ac76

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

app/code/Magento/Bundle/Pricing/Price/TierPrice.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\Bundle\Pricing\Price;
88

99
use Magento\Catalog\Pricing\Price\RegularPrice;
10+
use Magento\Framework\Pricing\Amount\AmountInterface;
1011

1112
/**
1213
* Bundle tier prices model
@@ -89,4 +90,13 @@ public function isPercentageDiscount()
8990
{
9091
return true;
9192
}
93+
94+
/**
95+
* @param AmountInterface $amount
96+
* @return float
97+
*/
98+
public function getSavePercent(AmountInterface $amount)
99+
{
100+
return round($amount->getBaseAmount());
101+
}
92102
}

app/code/Magento/Bundle/Test/Unit/Pricing/Price/TierPriceTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,4 +183,28 @@ public function providerForGetterTierPriceList()
183183
]
184184
];
185185
}
186+
187+
/**
188+
* @dataProvider providerForTestGetSavePercent
189+
*/
190+
public function testGetSavePercent($baseAmount, $savePercent)
191+
{
192+
$amount = $this->getMockForAbstractClass('Magento\Framework\Pricing\Amount\AmountInterface');
193+
$amount->expects($this->once())->method('getBaseAmount')->willReturn($baseAmount);
194+
195+
$this->assertEquals($savePercent, $this->model->getSavePercent($amount));
196+
}
197+
198+
/**
199+
* @return array
200+
*/
201+
public function providerForTestGetSavePercent()
202+
{
203+
return [
204+
'no fraction' => [10.0000, 10],
205+
'lower half' => [10.1234, 10],
206+
'half way' => [10.5000, 11],
207+
'upper half' => [10.6789, 11],
208+
];
209+
}
186210
}

app/code/Magento/Bundle/view/base/templates/product/price/tier_prices.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ $tierPrices = $tierPriceModel->getTierPriceList();
2222
<?php echo __(
2323
'Buy %1 with %2 discount each',
2424
$price['price_qty'],
25-
'<strong class="benefit">' . $price['price']->getBaseAmount() . '%</strong>'
25+
'<strong class="benefit">' . $tierPriceModel->getSavePercent($price['price']) . '%</strong>'
2626
); ?>
2727
</li>
2828
<?php endforeach; ?>

0 commit comments

Comments
 (0)