I have created a custom payment gateway module. Everything works fine, except canceling the order from the backend.
The error: The order(s) cannot be canceled
Any ideas?
I have created a custom payment gateway module. Everything works fine, except canceling the order from the backend.
The error: The order(s) cannot be canceled
Any ideas?
If you look into the function canCancel
under Mage_Sales_Model_Order
then you can see what in what situations an order can or cannot be cancelled.
The following need to be true before an order can be cancelled.
The full code is as follows.
/**
* Retrieve order cancel availability
*
* @return bool
*/
public function canCancel()
{
if (!$this->_canVoidOrder()) {
return false;
}
if ($this->canUnhold()) { // $this->isPaymentReview()
return false;
}
$allInvoiced = true;
foreach ($this->getAllItems() as $item) {
if ($item->getQtyToInvoice()) {
$allInvoiced = false;
break;
}
}
if ($allInvoiced) {
return false;
}
$state = $this->getState();
if ($this->isCanceled() || $state === self::STATE_COMPLETE || $state === self::STATE_CLOSED) {
return false;
}
if ($this->getActionFlag(self::ACTION_FLAG_CANCEL) === false) {
return false;
}
/**
* Use only state for availability detect
*/
/*foreach ($this->getAllItems() as $item) {
if ($item->getQtyToCancel()>0) {
return true;
}
}
return false;*/
return true;
}