示例#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)))));
 }
示例#2
0
 /**
  * @return bool Whether current method is enabled and able to work.
  */
 public function isEnabled()
 {
     $cart = $this->cartService->getCurrent();
     $post = $this->wp->getGlobalPost();
     if ($post === null || $post->post_type != Types::ORDER) {
         $customer = $cart->getCustomer();
     } else {
         // TODO: Get rid of this hack for customer fetching
         $customer = unserialize($this->wp->getPostMeta($post->ID, 'customer', true));
     }
     return $this->options['enabled'] && ($this->options['available_for'] === 'all' || in_array($customer->getShippingAddress()->getCountry(), $this->options['countries']));
 }
示例#3
0
 /**
  * @return bool Whether current method is enabled and able to work.
  */
 public function isEnabled()
 {
     $cart = $this->cartService->getCurrent();
     $post = $this->wp->getGlobalPost();
     if ($post === null || $post->post_type != Types::ORDER) {
         $customer = $cart->getCustomer();
     } else {
         // TODO: Get rid of this hack for customer fetching
         $customer = maybe_unserialize($this->wp->getPostMeta($post->ID, 'customer', true));
     }
     if (empty($customer)) {
         return $this->options['enabled'];
     }
     return $this->options['enabled'] && $customer->getShippingAddress()->getCountry() == $this->baseCountry;
 }
示例#4
0
 /**
  * @return bool Whether current method is enabled and able to work.
  */
 public function isEnabled()
 {
     $cart = $this->cartService->getCurrent();
     $post = $this->wp->getGlobalPost();
     if ($post === null || $post->post_type != Types::ORDER) {
         $customer = $cart->getCustomer();
     } else {
         // TODO: Get rid of this hack for customer fetching
         $customer = unserialize($this->wp->getPostMeta($post->ID, 'customer', true));
     }
     $freeShippingCoupon = array_reduce($cart->getCoupons(), function ($value, $coupon) {
         /** @var $coupon Coupon */
         return $value || $coupon->isFreeShipping();
     }, false);
     return $this->options['enabled'] && ($freeShippingCoupon || $cart->getProductSubtotal() >= $this->options['minimum'] && ($this->options['available_for'] === 'all' || in_array($customer->getShippingAddress()->getCountry(), $this->options['countries'])));
 }
示例#5
0
 public function render()
 {
     $cart = $this->cartService->getCurrent();
     $content = $this->wp->getPostField('post_content', $this->options->getPageId(Pages::CART));
     $content = do_shortcode($content);
     $termsUrl = '';
     $termsPage = $this->options->get('advanced.pages.terms');
     if ($termsPage > 0) {
         $termsUrl = $this->wp->getPermalink($termsPage);
     }
     return Render::get('shop/cart', array('content' => $content, 'cart' => $cart, 'messages' => $this->messages, 'productService' => $this->productService, 'customer' => $this->customerService->getCurrent(), 'shippingMethods' => $this->shippingService->getEnabled(), 'shopUrl' => $this->wp->getPermalink($this->options->getPageId(Pages::SHOP)), 'showWithTax' => $this->options->get('tax.price_tax') == 'with_tax', 'showShippingCalculator' => $this->options->get('shipping.calculator'), 'termsUrl' => $termsUrl));
 }
示例#6
0
 /**
  * Renders page template.
  *
  * @return string Page template.
  */
 public function render()
 {
     $content = $this->wp->getPostField('post_content', $this->options->getPageId(Pages::CHECKOUT));
     $content = do_shortcode($content);
     $cart = $this->cartService->getCurrent();
     $billingFields = $this->getBillingFields($cart->getCustomer()->getBillingAddress());
     $shippingFields = $this->getShippingFields($cart->getCustomer()->getShippingAddress());
     $termsUrl = '';
     $termsPage = $this->options->get('advanced.pages.terms');
     if ($termsPage > 0) {
         $termsUrl = $this->wp->getPageLink($termsPage);
     }
     $verificationMessage = $this->options->get('shopping.enable_verification_message') ? $this->options->get('shopping.verification_message') : '';
     return Render::get('shop/checkout', array('cartUrl' => $this->wp->getPermalink($this->options->getPageId(Pages::CART)), 'content' => $content, 'cart' => $cart, 'messages' => $this->messages, 'shippingMethods' => $this->shippingService->getEnabled(), 'paymentMethods' => $this->paymentService->getEnabled(), 'billingFields' => $billingFields, 'shippingFields' => $shippingFields, 'showWithTax' => $this->options->get('tax.price_tax') == 'with_tax', 'showLoginForm' => $this->options->get('shopping.show_login_form') && !$this->wp->isUserLoggedIn(), 'allowRegistration' => $this->options->get('shopping.allow_registration') && !$this->wp->isUserLoggedIn(), 'showRegistrationForm' => $this->options->get('shopping.allow_registration') && !$this->options->get('shopping.guest_purchases') && !$this->wp->isUserLoggedIn(), 'alwaysShowShipping' => $this->options->get('shipping.always_show_shipping'), 'verificationMessage' => $verificationMessage, 'differentShipping' => isset($_POST['jigoshop_order']) ? $_POST['jigoshop_order']['different_shipping_address'] == 'on' : false, 'termsUrl' => $termsUrl, 'defaultGateway' => $this->options->get('payment.default_gateway')));
 }