Skip to content

[Reorder] #30686 - Allow developers to filter order items for reorder #30687

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions app/code/Magento/Sales/Helper/Reorder.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,18 @@ public function canReorder($orderId)
return true;
}
}

/**
* Check is it possible to reorder one item.
*
* @param \Magento\Sales\Model\Order\Item $item
* @param \Magento\Catalog\Model\Product $product
* @return bool
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function canReorderItem($item, $product)
Copy link

@BarnyShergold BarnyShergold Oct 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing return type on prototype

Suggested change
public function canReorderItem($item, $product)
public function canReorderItem($item, $product): bool

{
return true;
}
}
3 changes: 3 additions & 0 deletions app/code/Magento/Sales/Model/Reorder/Reorder.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ private function addItemsToCart(Quote $cart, ItemCollection $orderItems, string
}
$product = $products[$productId];
foreach ($orderItems as $orderItem) {
if (!$this->reorderHelper->canReorderItem($orderItem, $product)) {
continue;
}
$this->addItemToCart($orderItem, $cart, clone $product);
}
}
Expand Down