Esempio n. 1
0
 /**
  * Display the widget in the sidebar.
  *
  * @param array $args     Sidebar arguments.
  * @param array $instance Instance.
  */
 public function widget($args, $instance)
 {
     // Hide widget if page is the cart or checkout
     if (Pages::isCart() || Pages::isCheckout()) {
         return;
     }
     // Set the widget title
     $title = apply_filters('widget_title', $instance['title'] ? $instance['title'] : __('Cart', 'jigoshop'), $instance, $this->id_base);
     Render::output('widget/cart/widget', array_merge($args, array('title' => $title, 'cart' => self::$cart->getCurrent(), 'cart_url' => get_permalink(self::$options->getPageId(\Jigoshop\Frontend\Pages::CART)), 'checkout_url' => get_permalink(self::$options->getPageId(\Jigoshop\Frontend\Pages::CHECKOUT)))));
 }
Esempio n. 2
0
 public function getPage(Container $container)
 {
     if (!Pages::isJigoshop() && !Pages::isAjax()) {
         return $container->get('jigoshop.page.dummy');
     }
     $this->wp->doAction('jigoshop\\page_resolver\\before');
     if (Pages::isCheckoutThankYou()) {
         return $container->get('jigoshop.page.checkout.thank_you');
     }
     if (Pages::isCheckoutPay()) {
         return $container->get('jigoshop.page.checkout.pay');
     }
     if (Pages::isCheckout()) {
         return $container->get('jigoshop.page.checkout');
     }
     if (Pages::isCart()) {
         return $container->get('jigoshop.page.cart');
     }
     if (Pages::isProductCategory()) {
         return $container->get('jigoshop.page.product_category_list');
     }
     if (Pages::isProductTag()) {
         return $container->get('jigoshop.page.product_tag_list');
     }
     if (Pages::isProductList()) {
         return $container->get('jigoshop.page.product_list');
     }
     if (Pages::isProduct()) {
         return $container->get('jigoshop.page.product');
     }
     if (Pages::isAccountOrders()) {
         return $container->get('jigoshop.page.account.orders');
     }
     if (Pages::isAccountEditAddress()) {
         return $container->get('jigoshop.page.account.edit_address');
     }
     if (Pages::isAccountChangePassword()) {
         return $container->get('jigoshop.page.account.change_password');
     }
     if (Pages::isAccount()) {
         return $container->get('jigoshop.page.account');
     }
 }
Esempio n. 3
0
 /**
  * Find and fetches saved cart.
  * If cart is not found - returns new empty one.
  *
  * @param $id string Id of cart to fetch.
  *
  * @return \Jigoshop\Entity\Cart Prepared cart instance.
  */
 public function get($id)
 {
     if (!isset($this->carts[$id])) {
         $cart = new Cart($this->options->get('tax.classes'));
         $cart->setCustomer($this->customerService->getCurrent());
         $cart->getCustomer()->selectTaxAddress($this->options->get('taxes.shipping') ? 'shipping' : 'billing');
         // Fetch data from session if available
         $cart->setId($id);
         $state = $this->getStateFromSession($id);
         if (isset($_POST['jigoshop_order']) && Pages::isCheckout()) {
             $state = $this->getStateFromCheckout($state);
         }
         // TODO: Support for transients?
         $cart = $this->orderFactory->fill($cart, $state);
         $this->carts[$id] = $this->wp->applyFilters('jigoshop\\service\\cart\\get', $cart, $state);
     }
     return $this->carts[$id];
 }