File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed
app/code/Magento/SalesRule Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -179,7 +179,7 @@ protected function distributeDiscount(\Magento\Quote\Model\Quote\Item\AbstractIt
179
179
$ roundingDelta [$ key ] = 0.0000001 ;
180
180
}
181
181
foreach ($ item ->getChildren () as $ child ) {
182
- $ ratio = $ child ->getBaseRowTotal () / $ parentBaseRowTotal ;
182
+ $ ratio = $ parentBaseRowTotal != 0 ? $ child ->getBaseRowTotal () / $ parentBaseRowTotal : 0 ;
183
183
foreach ($ keys as $ key ) {
184
184
if (!$ item ->hasData ($ key )) {
185
185
continue ;
Original file line number Diff line number Diff line change @@ -229,7 +229,30 @@ public function collectItemHasChildrenDataProvider()
229
229
{
230
230
$ data = [
231
231
// 3 items, each $100, testing that discount are distributed to item correctly
232
- 'three_items ' => [
232
+ [
233
+ 'child_item_data ' => [
234
+ 'item1 ' => [
235
+ 'base_row_total ' => 0 ,
236
+ ]
237
+ ],
238
+ 'parent_item_data ' => [
239
+ 'discount_amount ' => 20 ,
240
+ 'base_discount_amount ' => 10 ,
241
+ 'original_discount_amount ' => 40 ,
242
+ 'base_original_discount_amount ' => 20 ,
243
+ 'base_row_total ' => 0 ,
244
+ ],
245
+ 'expected_child_item_data ' => [
246
+ 'item1 ' => [
247
+ 'discount_amount ' => 0 ,
248
+ 'base_discount_amount ' => 0 ,
249
+ 'original_discount_amount ' => 0 ,
250
+ 'base_original_discount_amount ' => 0 ,
251
+ ]
252
+ ],
253
+ ],
254
+ [
255
+ // 3 items, each $100, testing that discount are distributed to item correctly
233
256
'child_item_data ' => [
234
257
'item1 ' => [
235
258
'base_row_total ' => 100 ,
You can’t perform that action at this time.
0 commit comments