Exemplo n.º 1
0
 /**
  * Updates menu items to enable "Shop" item when necessary.
  *
  * @param $items array Menu items.
  *
  * @return array Updated menu items.
  */
 public function menu($items)
 {
     if ($this->wp->getQueryParameter('post_type', false) == Types::PRODUCT) {
         foreach ($items as $item) {
             /** @var $item \WP_Post */
             /** @noinspection PhpUndefinedFieldInspection */
             if ($item->object_id == $this->options->getPageId(Pages::SHOP)) {
                 /** @noinspection PhpUndefinedFieldInspection */
                 $item->classes[] = 'current-menu-item';
             }
         }
     }
     return $items;
 }
Exemplo n.º 2
0
 public function render()
 {
     if (!$this->wp->isUserLoggedIn()) {
         return Render::get('user/login', array());
     }
     $order = $this->wp->getQueryParameter('orders');
     $accountUrl = $this->wp->getPermalink($this->options->getPageId(Pages::ACCOUNT));
     if (!empty($order) && is_numeric($order)) {
         $order = $this->orderService->find($order);
         /** @var Entity $order */
         return Render::get('user/account/orders/single', array('messages' => $this->messages, 'order' => $order, 'myAccountUrl' => $accountUrl, 'listUrl' => Api::getEndpointUrl('orders', '', $accountUrl), 'showWithTax' => $this->options->get('tax.price_tax') == 'with_tax', 'getTaxLabel' => function ($taxClass) use($order) {
             return Tax::getLabel($taxClass, $order);
         }));
     }
     $customer = $this->customerService->getCurrent();
     $orders = $this->orderService->findForUser($customer->getId());
     return Render::get('user/account/orders', array('messages' => $this->messages, 'customer' => $customer, 'orders' => $orders, 'myAccountUrl' => $accountUrl));
 }
Exemplo n.º 3
0
 public function render()
 {
     /** @var Order $order */
     $order = $this->orderService->find((int) $this->wp->getQueryParameter('pay'));
     $render = $this->wp->applyFilters('jigoshop\\pay\\render', '', $order);
     if (!empty($render)) {
         return Render::get('shop/checkout/payment', array('messages' => $this->messages, 'content' => $render, 'order' => $order));
     }
     $termsUrl = '';
     $termsPage = $this->options->get('advanced.pages.terms');
     if ($termsPage > 0) {
         $termsUrl = $this->wp->getPageLink($termsPage);
     }
     $accountUrl = $this->wp->getPermalink($this->options->getPageId(Pages::ACCOUNT));
     return Render::get('shop/checkout/pay', array('messages' => $this->messages, 'order' => $order, 'showWithTax' => $this->options->get('tax.price_tax') == 'with_tax', 'termsUrl' => $termsUrl, 'myAccountUrl' => $accountUrl, 'myOrdersUrl' => Api::getEndpointUrl('orders', '', $accountUrl), 'paymentMethods' => $this->paymentService->getEnabled(), 'getTaxLabel' => function ($taxClass) use($order) {
         return Tax::getLabel($taxClass, $order);
     }));
 }
Exemplo n.º 4
0
 /**
  * Filter products by category, uses slugs for option values.
  * Props to: Andrew Benbow - chromeorange.co.uk
  */
 public function categoryFilter()
 {
     $type = $this->wp->getTypeNow();
     if ($type != Types::PRODUCT) {
         return;
     }
     $query = array('pad_counts' => 1, 'hierarchical' => true, 'hide_empty' => true, 'show_count' => true, 'selected' => $this->wp->getQueryParameter(Types::PRODUCT_CATEGORY));
     $terms = $this->wp->getTerms(Types::PRODUCT_CATEGORY, $query);
     if (!$terms) {
         return;
     }
     $current = isset($_GET[Types::PRODUCT_CATEGORY]) ? $_GET[Types::PRODUCT_CATEGORY] : '';
     $walker = new \Jigoshop\Web\CategoryWalker($this->wp, 'admin/products/categoryFilter/item');
     Render::output('admin/products/categoryFilter', array('terms' => $terms, 'current' => $current, 'walker' => $walker, 'query' => $query));
 }
Exemplo n.º 5
0
 public function render()
 {
     if (!$this->wp->isUserLoggedIn()) {
         return Render::get('user/login', array());
     }
     $customer = $this->customerService->getCurrent();
     switch ($this->wp->getQueryParameter('edit-address')) {
         case 'shipping':
             $address = $customer->getShippingAddress();
             break;
         case 'billing':
         default:
             $address = $customer->getBillingAddress();
             break;
     }
     return Render::get('user/account/edit_address', array('messages' => $this->messages, 'customer' => $customer, 'address' => $address, 'myAccountUrl' => $this->wp->getPermalink($this->options->getPageId(Pages::ACCOUNT))));
 }