File tree Expand file tree Collapse file tree 3 files changed +35
-1
lines changed
view/base/templates/product/price Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change 7
7
namespace Magento \Bundle \Pricing \Price ;
8
8
9
9
use Magento \Catalog \Pricing \Price \RegularPrice ;
10
+ use Magento \Framework \Pricing \Amount \AmountInterface ;
10
11
11
12
/**
12
13
* Bundle tier prices model
@@ -89,4 +90,13 @@ public function isPercentageDiscount()
89
90
{
90
91
return true ;
91
92
}
93
+
94
+ /**
95
+ * @param AmountInterface $amount
96
+ * @return float
97
+ */
98
+ public function getSavePercent (AmountInterface $ amount )
99
+ {
100
+ return round ($ amount ->getBaseAmount ());
101
+ }
92
102
}
Original file line number Diff line number Diff line change @@ -183,4 +183,28 @@ public function providerForGetterTierPriceList()
183
183
]
184
184
];
185
185
}
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
+ }
186
210
}
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ $tierPrices = $tierPriceModel->getTierPriceList();
22
22
<?php echo __ (
23
23
'Buy %1 with %2 discount each ' ,
24
24
$ price ['price_qty ' ],
25
- '<strong class="benefit"> ' . $ price ['price ' ]-> getBaseAmount ( ) . '%</strong> '
25
+ '<strong class="benefit"> ' . $ tierPriceModel -> getSavePercent ( $ price ['price ' ]) . '%</strong> '
26
26
); ?>
27
27
</li>
28
28
<?php endforeach ; ?>
You can’t perform that action at this time.
0 commit comments