I'm a building a function that should retrieve all the payments made in the last hour, and update the order status from pending to processing.
The problem is that, for some reason some of the orders (pending) return false
when I do this:
$orderModel = Mage::getModel('sales/order');
$order = $orderModel->load($entityId);
//$order->canInvoice() --> false
Do you have any idea/ sugestion?
Thanks
Best Answer
As per invoice
generation is depending
upon oncanInvoice()
function of sales model:Explanation:
Condition1:
if ($this->canUnhold() || $this->isPaymentReview())
means if Order state is unhold or order state is payment review (this->getState() === self::STATE_PAYMENT_REVIEW;)Condition2:
if ($this->isCanceled() || $state === self::STATE_COMPLETE || $state === self::STATE_CLOSED) {
Condition 3:
if ($this->getActionFlag(self::ACTION_FLAG_INVOICE)
,If current action is invoiceCondition4:
if ($item->getQtyToInvoice()>0 && !$item->getLockedDoInvoice()) {
if order all item qty_to_invoice valueis less than 1 and all item locked_do_invoice is null (In Sales_flat_order_item table).
Hope ,you will understand