The method responsible for reordering is Mage_Sales_Model_Order::_canReorder()
. The method _canReorder
is called by Mage_Sales_Model_Order::canReorder()
. This is actually called to see if you can reorder. I understood that part.
I know that the reorder button doesn't show up when an item is out of stock. How can I make ignore this condition and allow customer to reorder by excluding the out of stock item?
The _canReorder
function looks like this:
protected function _canReorder($ignoreSalable = false)
{
if ($this->canUnhold() || $this->isPaymentReview()) {
return false;
}
if ($this->getActionFlag(self::ACTION_FLAG_REORDER) === false) {
return false;
}
$products = [];
$itemsCollection = $this->getItemsCollection();
foreach ($itemsCollection as $item) {
$products[] = $item->getProductId();
}
if (!empty($products)) {
$productsCollection = $this->productListFactory->create()
->setStoreId($this->getStoreId())
->addIdFilter($products)
->addAttributeToSelect('status')
->load();
foreach ($itemsCollection as $item) {
$product = $productsCollection->getItemById($item->getProductId());
if (!$product) {
return false;
}
if (!$ignoreSalable && !$product->isSalable()) {
return false;
}
}
}
return true;
}
Where is the part that detects "out of stock" item and how can I add logic to exclude out of stock item from reordering cart?
I'm new to Magento, so any help would be appreciated. Thank you.