8

I'm running Magento 1.6.2.

I need to determine if an order is paid. If yes, I generate some XML data for export. There is many cases in the Magento order/payment/shipment workflow.

My first guess is when the attribute "state" of the order is defined as "processing", but I'm not sure because of the large amount of possibilities in this workflow. May be this case is not covering all the possibilities ...

Am I right with that ?

6
  • Check if there is an invoice generated for the order.
    – Marius
    Commented Nov 21, 2013 at 15:46
  • Just invoice ? No other stuff ? I'm surprised, it seems too easy to be real aha. Thank you for your help! Commented Nov 21, 2013 at 15:59
  • Usually the presence of an invoice means it's been paid.
    – Marius
    Commented Nov 21, 2013 at 16:00
  • That's not enough in all cases, as an invoice can be unpaid. And it's possible that an invoice doesn't cover all ordered items, so there may be more than one invoice. Commented Nov 21, 2013 at 16:08
  • Checking the state may do depending on your workflow, but the state "processing" may also mean that the order is sent, but not paid yet. I wouldn't use that. Commented Nov 21, 2013 at 16:25

2 Answers 2

23

You can call $order->getBaseTotalDue(). If this is 0, the order is fully paid.

1
  • Thank you Andreas, this answer seems to be the one who fit the most to my answer. Commented Nov 22, 2013 at 9:51
1

See Andreas answer on how to determine if there is anything left to pay. To answer your other question - using state == processing is not good enough. A quick test to show this is to ship an unpaid order - this will also move an order to the processing state even though the order is still unpaid.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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