File tree Expand file tree Collapse file tree 1 file changed +27
-7
lines changed
app/code/Magento/SalesRule/Model Expand file tree Collapse file tree 1 file changed +27
-7
lines changed Original file line number Diff line number Diff line change @@ -383,13 +383,7 @@ public function initTotals($items, Address $address)
383
383
384
384
foreach ($ items as $ item ) {
385
385
//Skipping child items to avoid double calculations
386
- if ($ item ->getParentItemId () || $ item ->getParentItem ()) {
387
- continue ;
388
- }
389
- if (!$ rule ->getActions ()->validate ($ item )) {
390
- continue ;
391
- }
392
- if (!$ this ->canApplyDiscount ($ item )) {
386
+ if (!$ this ->isValidItemForRule ($ item , $ rule )) {
393
387
continue ;
394
388
}
395
389
$ qty = $ this ->validatorUtility ->getItemQty ($ item , $ rule );
@@ -409,6 +403,32 @@ public function initTotals($items, Address $address)
409
403
return $ this ;
410
404
}
411
405
406
+ /**
407
+ * Determine if quote item is valid for a given sales rule
408
+ * @param AbstractItem $item
409
+ * @param Rule $rule
410
+ * @return bool
411
+ */
412
+ protected function isValidItemForRule (
413
+ AbstractItem $ item ,
414
+ Rule $ rule
415
+ ) {
416
+ /** @var AbstractItem $item */
417
+ if ($ item ->getParentItemId ()) {
418
+ return false ;
419
+ }
420
+ if ($ item ->getParentItem ()) {
421
+ return false ;
422
+ }
423
+ if (!$ rule ->getActions ()->validate ($ item )) {
424
+ return false ;
425
+ }
426
+ if (!$ this ->canApplyDiscount ($ item )) {
427
+ return false ;
428
+ }
429
+ return true ;
430
+ }
431
+
412
432
/**
413
433
* Return item price
414
434
*
You can’t perform that action at this time.
0 commit comments