@@ -187,7 +187,8 @@ public function testGetCustomerOrderWithBundleProduct()
187
187
'product_sku ' => 'simple1 ' ,
188
188
'product_name ' => 'Simple Product1 ' ,
189
189
'product_type ' => 'simple ' ,
190
- 'quantity_ordered ' => 1
190
+ 'quantity_ordered ' => 1 ,
191
+ 'discounts ' => null
191
192
]
192
193
]
193
194
],
@@ -198,7 +199,8 @@ public function testGetCustomerOrderWithBundleProduct()
198
199
'product_sku ' => 'simple2 ' ,
199
200
'product_name ' => 'Simple Product2 ' ,
200
201
'product_type ' => 'simple ' ,
201
- 'quantity_ordered ' => 2
202
+ 'quantity_ordered ' => 2 ,
203
+ 'discounts ' => null
202
204
]
203
205
]
204
206
],
@@ -219,16 +221,6 @@ public function testGetCustomerOrderWithBundleProductWithTaxesAndDiscounts()
219
221
{
220
222
$ qty = 4 ;
221
223
$ bundleSku = 'bundle-product-two-dropdown-options ' ;
222
- $ simpleProductSku = 'simple2 ' ;
223
- /** @var Product $simple */
224
- $ simple = $ this ->productRepository ->get ($ simpleProductSku );
225
- $ stockData =[
226
- StockItemInterface::QTY => 200 ,
227
- StockItemInterface::MANAGE_STOCK =>true ,
228
- StockItemInterface::IS_IN_STOCK =>true
229
- ];
230
- $ simple ->setQuantityAndStockStatus ($ stockData );
231
- $ this ->productRepository ->save ($ simple );
232
224
/** @var Product $bundleProduct */
233
225
$ bundleProduct = $ this ->productRepository ->get ($ bundleSku );
234
226
/** @var $typeInstance \Magento\Bundle\Model\Product\Type */
@@ -241,7 +233,6 @@ public function testGetCustomerOrderWithBundleProductWithTaxesAndDiscounts()
241
233
/** @var Selection $selection */
242
234
$ selection1 = $ typeInstance ->getSelectionsCollection ([$ option1 ->getId ()], $ bundleProduct )->getFirstItem ();
243
235
$ selectionId1 = (int )$ selection1 ->getSelectionId ();
244
-
245
236
$ selection2 = $ typeInstance ->getSelectionsCollection ([$ option2 ->getId ()], $ bundleProduct )->getLastItem ();
246
237
$ selectionId2 = (int )$ selection2 ->getSelectionId ();
247
238
@@ -259,22 +250,16 @@ public function testGetCustomerOrderWithBundleProductWithTaxesAndDiscounts()
259
250
260
251
$ bundledItemInTheOrder = $ customerOrderItems ['items ' ][0 ];
261
252
$ this ->assertEquals ('bundle-product-two-dropdown-options-simple1-simple2 ' , $ bundledItemInTheOrder ['product_sku ' ]);
262
- $ this ->assertArrayHasKey ('child_items ' , $ bundledItemInTheOrder );
263
- $ childItemInTheOrder = $ bundledItemInTheOrder ['child_items ' ][0 ];
264
- $ this ->assertNotEmpty ($ childItemInTheOrder );
265
- $ this ->assertEquals ('simple1 ' , $ childItemInTheOrder ['product_sku ' ]);
266
- $ this ->assertEquals (
267
- 0 ,
268
- $ childItemInTheOrder ['discounts ' ][0 ]['amount ' ]['value ' ]
269
- );
270
- $ this ->assertEquals (
271
- 'USD ' ,
272
- $ childItemInTheOrder ['discounts ' ][0 ]['amount ' ]['currency ' ]
273
- );
274
- $ this ->assertEquals (
275
- 'null ' ,
276
- $ childItemInTheOrder ['discounts ' ][0 ]['label ' ]
277
- );
253
+ $ this ->assertArrayHasKey ('bundle_options ' , $ bundledItemInTheOrder );
254
+ $ childItemsInTheOrder = $ bundledItemInTheOrder ['bundle_options ' ];
255
+ $ this ->assertNotEmpty ($ childItemsInTheOrder );
256
+ $ this ->assertCount (2 , $ childItemsInTheOrder );
257
+ $ this ->assertEquals ('Drop Down Option 1 ' , $ childItemsInTheOrder [0 ]['label ' ]);
258
+ $ this ->assertEquals ('Drop Down Option 2 ' , $ childItemsInTheOrder [1 ]['label ' ]);
259
+
260
+ $ this ->assertEquals ('simple1 ' , $ childItemsInTheOrder [0 ]['items ' ][0 ]['product_sku ' ]);
261
+ $ this ->assertEquals ('simple2 ' , $ childItemsInTheOrder [1 ]['items ' ][0 ]['product_sku ' ]);
262
+
278
263
$ this ->assertTotalsOnBundleProductWithTaxesAndDiscounts ($ customerOrderItems );
279
264
$ this ->deleteOrder ();
280
265
}
@@ -369,10 +354,6 @@ private function assertTotalsOnBundleProductWithTaxesAndDiscounts(array $custome
369
354
2 ,
370
355
$ customerOrderItem ['total ' ]['shipping_handling ' ]['discounts ' ][0 ]['amount ' ]['value ' ]
371
356
);
372
- $ this ->assertEquals (
373
- 'USD ' ,
374
- $ customerOrderItem ['total ' ]['shipping_handling ' ]['discounts ' ][0 ]['amount ' ]['currency ' ]
375
- );
376
357
$ this ->assertEquals (
377
358
'null ' ,
378
359
$ customerOrderItem ['total ' ]['shipping_handling ' ]['discounts ' ][0 ]['label ' ]
@@ -1477,15 +1458,16 @@ private function getCustomerOrderQueryBundleProduct($orderNumber)
1477
1458
product_url_key
1478
1459
product_sale_price{value}
1479
1460
quantity_ordered
1480
- __typename
1461
+ discounts{amount{value} label}
1481
1462
... on BundleOrderItem{
1482
1463
bundle_options{
1483
1464
__typename
1484
1465
label
1485
- items{ product_sku product_name product_type quantity_ordered}
1466
+ items{product_sku product_name product_type quantity_ordered discounts{amount{value} }
1486
1467
}
1487
1468
}
1488
1469
}
1470
+ }
1489
1471
total {
1490
1472
base_grand_total{value currency}
1491
1473
grand_total{value currency}
@@ -1498,6 +1480,7 @@ private function getCustomerOrderQueryBundleProduct($orderNumber)
1498
1480
amount_including_tax{value}
1499
1481
amount_excluding_tax{value}
1500
1482
total_amount{value}
1483
+ discounts{amount{value} label}
1501
1484
taxes {amount{value} title rate}
1502
1485
}
1503
1486
discounts {amount{value currency} label}
0 commit comments