Esempio n. 1
0
 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')));
     }
 }
Esempio n. 2
0
 /**
  * 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]);
 }
Esempio n. 3
0
 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;
 }
Esempio n. 4
0
 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']) ? '&amp;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 . '&amp;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;
 }
Esempio n. 5
0
?>
<dl class="dl-horizontal">
	<dt><?php 
_e('Order number', 'jigoshop');
?>
</dt>
	<dd><?php 
echo $order->getNumber();
?>
</dd>
	<dt><?php 
_e('Status', 'jigoshop');
?>
</dt>
	<dd><?php 
echo Status::getName($order->getStatus());
?>
</dd>
</dl>
<div class="col-md-6">
	<div class="panel panel-default">
		<div class="panel-heading">
			<h3 class="panel-title"><?php 
_e('Billing address', 'jigoshop');
?>
</h3>
		</div>
		<div class="panel-body clearfix">
			<?php 
Render::output('user/account/address', array('address' => $order->getCustomer()->getBillingAddress()));
?>
Esempio n. 6
0
 /**
  * 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);
 }
Esempio n. 7
0
</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);
    ?>
Esempio n. 8
0
 public function getArgs()
 {
     return array('id' => 'order_status', 'name' => 'order_status', 'value' => $this->orderStatus, 'multiple' => true, 'classes' => array(), 'options' => Status::getStatuses(), 'size' => 14);
 }
Esempio n. 9
0
 /**
  * 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));
 }