/** * Adds various extra data to specified orders. * * @param array $orders Orders array * @param bool $single Whether only one order is specified; only in this case modified order data array is returned * @return null|array */ public static function workupOrders(&$orders, $single = false) { if ($single) { $orders = array($orders); } $workflow = new shopWorkflow(); $states = $workflow->getAllStates(); foreach ($orders as &$order) { $order['id_str'] = self::encodeOrderId($order['id']); $order['total_str'] = wa_currency($order['total'], $order['currency']); if (!empty($order['create_datetime'])) { $order['create_datetime_str'] = wa_date('humandatetime', $order['create_datetime']); } $state = isset($states[$order['state_id']]) ? $states[$order['state_id']] : null; $icon = ''; $style = ''; if ($state) { /** * @var shopWorkflowState $state */ $icon = $state->getOption('icon'); $style = $state->getStyle(); } $order['icon'] = $icon; $order['style'] = $style; if (isset($order['params'])) { // shipping_address_formatted $shipping_address = self::getOrderAddress($order['params'], 'shipping'); $formatter = new waContactAddressOneLineFormatter(); $order['shipping_address_formatted'] = $formatter->format(array('data' => $shipping_address)); $order['shipping_address_formatted'] = $order['shipping_address_formatted']['value']; // Shipping and payment option names if (isset($order['params']['shipping_name'])) { $order['shipping_name'] = htmlspecialchars($order['params']['shipping_name']); } else { $order['shipping_name'] = '<span class="hint">' . _w('not specified') . '</span>'; } if (isset($order['params']['payment_name'])) { $order['payment_name'] = htmlspecialchars($order['params']['payment_name']); } else { $order['payment_name'] = '<span class="hint">' . _w('not specified') . '</span>'; } } } if ($single) { $orders = $orders[0]; return $orders; } }
public function getStates() { $workflow = new shopWorkflow(); return $workflow->getAllStates(); }