From 7840fb6e5f99fcc6c9b25e05c6f40d73137f6d79 Mon Sep 17 00:00:00 2001 From: Iain Patterson Date: Mon, 13 May 2013 05:57:02 -0400 Subject: [PATCH] Added get_order_state() and get_order_state_string(). Return an order state with get_order_state(). Return a string representation of an order state with get_order_state_string(). --- lib/functions.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/functions.php b/lib/functions.php index 8db2720..2b35663 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -257,6 +257,25 @@ return sprintf("%s on %s", get_order_parcel_string($order), $order->getDate()); } + function get_order_state_string($order_state = null) { + global $states; + + if (is_null($order_state)) return null; + + for ($i = 0; $i < count($states); $i++) { + if ($order_state->getState() & (1 << $i)) { + return $states[$i]; + } + } + + return "unknown"; + } + + function get_order_state($order) { + $q = new OrderStateQuery(); + return $q->filterByOrderId($order->getId())->orderByUpdated('desc')->findOne(); + } + function get_order_summary($order) { $ret = "Order " . $order->getStrongLink($order->getId()) . ": " . get_order_displayname($order); -- 2.7.4