예제 #1
0
 /**
  * Finds items specified using WordPress query.
  *
  * @param $query \WP_Query WordPress query.
  * @return array Collection of found items.
  */
 public function findByQuery($query)
 {
     $hash = hash('md5', serialize($query->query_vars));
     if (!isset($this->queries[$hash])) {
         $this->queries[$hash] = $this->service->findByQuery($query);
     }
     return $this->queries[$hash];
 }
예제 #2
0
 public function render()
 {
     if (!$this->wp->isUserLoggedIn()) {
         return Render::get('user/login', array());
     }
     $content = $this->wp->getPostField('post_content', $this->options->getPageId(Pages::ACCOUNT));
     $content = do_shortcode($content);
     $customer = $this->customerService->getCurrent();
     $query = new \WP_Query(array('post_type' => Types::ORDER, 'post_status' => array(Status::PENDING, Status::ON_HOLD), 'posts_per_page' => $this->options->get('shopping.unpaid_orders_number'), 'meta_query' => array(array('key' => 'customer_id', 'value' => $this->wp->getCurrentUserId(), 'compare' => '='))));
     $orders = $this->orderService->findByQuery($query);
     $permalink = get_permalink();
     return Render::get('user/account', array('content' => $content, 'messages' => $this->messages, 'customer' => $customer, 'unpaidOrders' => $orders, 'editBillingAddressUrl' => Api::getEndpointUrl('edit-address', 'billing', $permalink), 'editShippingAddressUrl' => Api::getEndpointUrl('edit-address', 'shipping', $permalink), 'changePasswordUrl' => Api::getEndpointUrl('change-password', '', $permalink), 'myOrdersUrl' => Api::getEndpointUrl('orders', '', $permalink)));
 }
예제 #3
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));
 }