public function registerOrderStatuses() { $statuses = Status::getStatuses(); foreach ($statuses as $status => $label) { $this->wp->registerPostStatus($status, array('label' => $label, 'public' => false, 'exclude_from_search' => false, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true, 'label_count' => _n_noop($label . ' <span class="count">(%s)</span>', $label . ' <span class="count">(%s)</span>', 'jigoshop'))); } }
/** * Get status slug and name * * @param \Jigoshop\Entity\Order $order * * @return array */ public static function checkGetStatus(\Jigoshop\Entity\Order $order) { $statuses = Status::getStatuses(); $status = $order->getStatus(); if (!isset($statuses[$status])) { $status = Status::PENDING; } return array('status' => $status, 'text' => $statuses[$status]); }
public function getList() { if (!in_array(Permission::READ_ORDERS, $this->permissions)) { $this->notPermittedRequest(); } $defaults = array('post_type' => Types::ORDER, 'posts_per_page' => 10, 'paged' => 1, 'post_status' => array_keys(Status::getStatuses())); $args = array(); if (isset($_GET['pagelen'])) { $args['posts_per_page'] = (int) $_GET['pagelen']; } if (isset($_GET['page'])) { $args['paged'] = (int) $_GET['page']; } $args = array_merge($defaults, $args); $query = new \WP_Query($args); $orders = $this->orderService->findByQuery($query); $response = array('found' => $query->found_posts, 'pages' => $query->max_num_pages, 'orders' => array()); foreach ($orders as $order) { $response['orders'][] = OrderHelper::getBasicData($order); } return $response; }
public function statusFilters($views) { $current = isset($_GET['post_status']) && Entity\Status::exists($_GET['post_status']) ? $_GET['post_status'] : ''; $statuses = Entity\Status::getStatuses(); $counts = $this->wp->wpCountPosts(Types::ORDER, 'readable'); $dates = isset($_GET['m']) ? '&m=' . $_GET['m'] : ''; foreach ($statuses as $status => $label) { $count = isset($counts->{$status}) ? $counts->{$status} : 0; $views[$status] = '<a class="' . $status . ($current == $status ? ' current' : '') . '" href="?post_type=' . Types::ORDER . '&post_status=' . $status . $dates . '">' . $label . ' <span class="count">(' . $count . ')</a>'; } if (!empty($current)) { $views['all'] = str_replace('current', '', $views['all']); } unset($views['publish']); if (isset($views['trash'])) { $trash = $views['trash']; unset($views['draft']); unset($views['trash']); $views['trash'] = $trash; } return $views; }
/** * Finds orders for specified user. * * @param $userId int User ID. * * @return array Orders found. */ public function findForUser($userId) { $query = new \WP_Query(array('post_status' => array_keys(Order\Status::getStatuses()), 'post_type' => Types::ORDER, 'suppress_filters' => false, 'fields' => 'ids', 'order' => 'DESC', 'orderby' => 'post_date', 'numberposts' => -1, 'meta_query' => array(array('key' => 'customer_id', 'value' => $userId)))); return $this->wp->applyFilters('jigoshop\\service\\order\\find_for_user', $this->findByQuery($query), $userId); }
</a></li> <?php } ?> <!-- TODO: Maybe a filter to show/hide insignificant data? --> </ul> <noscript> <div class="alert alert-danger" role="alert"><?php _e('<strong>Warning</strong> Order panel will not work properly without JavaScript.', 'jigoshop'); ?> </div> </noscript> <div class="tab-content form-horizontal"> <div class="tab-pane active" id="order"> <?php Forms::select(array('name' => 'jigoshop_order[status]', 'label' => __('Order status', 'jigoshop'), 'value' => $order->getStatus(), 'options' => Status::getStatuses())); ?> <?php Forms::select(array('name' => 'jigoshop_order[customer]', 'label' => __('Customer', 'jigoshop'), 'value' => $order->getCustomer() ? $order->getCustomer()->getId() : '', 'options' => $customers)); ?> <?php Forms::textarea(array('name' => 'post_excerpt', 'label' => __("Customer's note", 'jigoshop'), 'value' => $order->getCustomerNote())); ?> </div> <div class="tab-pane" id="billing-address"> <?php foreach ($billingFields as $field) { ?> <?php Forms::field($field['type'], $field); ?>
public function getArgs() { return array('id' => 'order_status', 'name' => 'order_status', 'value' => $this->orderStatus, 'multiple' => true, 'classes' => array(), 'options' => Status::getStatuses(), 'size' => 14); }
/** * Displays "Recent Orders" meta box. */ public function recentOrders() { /** @noinspection PhpUnusedLocalVariableInspection */ $statuses = Order\Status::getStatuses(); unset($statuses[Order\Status::CANCELLED], $statuses[Order\Status::REFUNDED]); $orders = $this->orderService->findByQuery(new \WP_Query(array('numberposts' => 10, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => Types::ORDER, 'post_status' => array_keys($statuses)))); Render::output('admin/dashboard/recentOrders', array('orders' => $orders)); }