1

In one of my project I have noticed an issue.
Magento is showing Re-order button even if the it contains the disabled item.
It is not showing the button only considering the last item in the order.

For example : I have ordered three items P1, P2 and P3. I have added the products in the same order in the cart first P1, then P2 and at last P3.
Now in the My orders section, I am seeing the Reorder button [CORRECT Functionality].
Now if I am disabling the the product P1 or P2 from the admin, I am still seeing the Reorder button. [Incorrect]
But if I am disabling the P3, reorder button is not appearing.
For some unknown reason, till now, Magento is considering only the last item.
If anyone has faced any similar issue, please share your thoughts and help me out in fixing it.

1

Magento core function _canReorder() only work for only last item .

If you want to modify and want to disable reorder button then you need to modify the below function. Override the function _canReorder() of /app/code/core/Mage/Sales/Model/Order.php and replace the below piece of code :- from --

foreach ($products as $productId) {
                    $product = Mage::getModel('catalog/product')
                        ->setStoreId($this->getStoreId())
                        ->load($productId);

                }
                if (!$product->getId() || (!$ignoreSalable && !$product->isSalable())) {
                    return false;
                }

to

foreach ($products as $productId) {
                    $product = Mage::getModel('catalog/product')
                        ->setStoreId($this->getStoreId())
                        ->load($productId);
                    if (!$product->getId() || (!$ignoreSalable && !$product->isSalable())) {
                      return false;
                    }
                }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.