is_available() public method

Check if the gateway is available for use.
public is_available ( ) : boolean
return boolean
 /**
  * Amazon Payments Advanced is available if the following conditions are met (on top of WC_Payment_Gateway::is_available)
  * 1) Login App mode is enabled and we have an access token from Amazon
  * 2) Login App mode is *not* enabled and we have an order reference id
  *
  * @return bool
  */
 function is_available()
 {
     $login_app_enabled = 'yes' === $this->enable_login_app;
     $standard_mode_ok = !$login_app_enabled && !empty($this->reference_id);
     $login_app_mode_ok = $login_app_enabled && !empty($this->access_token);
     return parent::is_available() && ($standard_mode_ok || $login_app_mode_ok);
 }
 /**
  * Check if this gateway is enabled
  */
 public function is_available()
 {
     if (!$this->api_key || !$this->mid) {
         return false;
     }
     return parent::is_available();
 }
 /**
  * Check if gateway meets all the requirements to be used
  *
  * @access public
  * @return bool
  */
 function is_available()
 {
     // is enabled check
     $is_available = parent::is_available();
     // Required fields check
     if (!$this->customer_api && !$this->customer_password) {
         $is_available = false;
     }
     return apply_filters('woocommerce_eway_is_available', $is_available);
 }
 /**
  * Check if the gateway is available for use
  *
  * @return bool
  */
 public function is_available()
 {
     $is_available = parent::is_available();
     // Only allow unencrypted connections when testing
     if (!is_ssl() && !$this->testmode) {
         $is_available = false;
     }
     // Required fields check
     if (!$this->merchant_id || !$this->merchant_password) {
         $is_available = false;
     }
     return $is_available;
 }
 /**
  * Disables the gateway under any of these conditions:
  * 1) If the cart does not contain a pre-order
  * 2) If the pre-order amount is charged upfront
  * 3) On the pay page
  *
  * @since 1.0
  * @return bool
  */
 public function is_available()
 {
     $is_available = parent::is_available();
     // on checkout page
     if (!is_page(woocommerce_get_page_id('pay')) || defined('WOOCOMMERCE_CHECKOUT') && WOOCOMMERCE_CHECKOUT) {
         // not available if the cart does not contain a pre-order
         if (WC_Pre_Orders_Cart::cart_contains_pre_order()) {
             // not available when the pre-order amount is charged upfront
             if (WC_Pre_Orders_Product::product_is_charged_upfront(WC_Pre_Orders_Cart::get_pre_order_product())) {
                 $is_available = false;
             }
         } else {
             $is_available = false;
         }
     } else {
         // not available on the pay page (for now)
         $is_available = false;
     }
     return $is_available;
 }
 /**
  * Check If The Gateway Is Available For Use
  *
  * @version 2.5.6
  * @return  bool
  */
 public function is_available()
 {
     // Check min amount
     $min_amount = apply_filters('booster_get_option', 0, $this->min_amount);
     if ($min_amount > 0 && isset(WC()->cart->total) && '' != WC()->cart->total && isset(WC()->cart->fee_total)) {
         $total_excluding_fees = WC()->cart->total - WC()->cart->fee_total;
         if ($total_excluding_fees < $min_amount) {
             return false;
         }
     }
     // Check shipping methods and is virtual
     $order = null;
     if (!$this->enable_for_virtual) {
         if (WC()->cart && !WC()->cart->needs_shipping()) {
             return false;
         }
         if (is_page(wc_get_page_id('checkout')) && 0 < get_query_var('order-pay')) {
             $order_id = absint(get_query_var('order-pay'));
             $order = new WC_Order($order_id);
             // Test if order needs shipping.
             $needs_shipping = false;
             if (0 < sizeof($order->get_items())) {
                 foreach ($order->get_items() as $item) {
                     $_product = $order->get_product_from_item($item);
                     if ($_product->needs_shipping()) {
                         $needs_shipping = true;
                         break;
                     }
                 }
             }
             $needs_shipping = apply_filters('woocommerce_cart_needs_shipping', $needs_shipping);
             if ($needs_shipping) {
                 return false;
             }
         }
     }
     if (!empty($this->enable_for_methods)) {
         // Only apply if all packages are being shipped via ...
         $session_object = WC()->session;
         $chosen_shipping_methods_session = is_object($session_object) ? $session_object->get('chosen_shipping_methods') : null;
         if (isset($chosen_shipping_methods_session)) {
             $chosen_shipping_methods = array_unique($chosen_shipping_methods_session);
         } else {
             $chosen_shipping_methods = array();
         }
         $check_method = false;
         if (is_object($order)) {
             if ($order->shipping_method) {
                 $check_method = $order->shipping_method;
             }
         } elseif (empty($chosen_shipping_methods) || sizeof($chosen_shipping_methods) > 1) {
             $check_method = false;
         } elseif (sizeof($chosen_shipping_methods) == 1) {
             $check_method = $chosen_shipping_methods[0];
         }
         if (!$check_method) {
             return false;
         }
         $found = false;
         foreach ($this->enable_for_methods as $method_id) {
             if (strpos($check_method, $method_id) === 0) {
                 $found = true;
                 break;
             }
         }
         if (!$found) {
             return false;
         }
     }
     return parent::is_available();
 }
Ejemplo n.º 7
0
 /**
  * Check if the gateway is available for use
  *
  * @return bool
  */
 public function is_available()
 {
     if (!parent::is_available()) {
         return false;
     }
     if (WC()->cart && $this->get_order_total() > 0) {
         // Validate min amount
         if (0 < $this->min_amount && $this->min_amount > $this->get_order_total()) {
             return false;
         }
         // Validate max amount
         if (0 < $this->max_amount && $this->max_amount < $this->get_order_total()) {
             return false;
         }
     }
     return true;
 }
 /**
  * Checks for proper gateway configuration (required fields populated, etc)
  * and that there are no missing dependencies
  *
  * @since 2.0
  */
 public function is_available()
 {
     // is enabled check
     $is_available = parent::is_available();
     // proper configuration
     if (!$this->get_access_key() || !$this->get_secret_key()) {
         $is_available = false;
     }
     // all dependencies met
     if (count($GLOBALS['wc_amazon_fps']->get_missing_dependencies()) > 0) {
         $is_available = false;
     }
     return apply_filters('wc_gateway_amazon_fps_is_available', $is_available);
 }
Ejemplo n.º 9
0
 /**
  * Check If The Gateway Is Available For Use
  *
  * @return bool
  */
 public function is_available()
 {
     if (!empty($this->enable_for_methods)) {
         // Only apply if all packages are being shipped via local pickup
         $chosen_shipping_methods = array_unique(WC()->session->get('chosen_shipping_methods'));
         $check_method = false;
         if (is_page(wc_get_page_id('checkout')) && !empty($wp->query_vars['order-pay'])) {
             $order_id = absint($wp->query_vars['order-pay']);
             $order = new WC_Order($order_id);
             if ($order->shipping_method) {
                 $check_method = $order->shipping_method;
             }
         } elseif (empty($chosen_shipping_methods) || sizeof($chosen_shipping_methods) > 1) {
             $check_method = false;
         } elseif (sizeof($chosen_shipping_methods) == 1) {
             $check_method = $chosen_shipping_methods[0];
         }
         if (!$check_method) {
             return false;
         }
         $found = false;
         foreach ($this->enable_for_methods as $method_id) {
             if (strpos($check_method, $method_id) === 0) {
                 $found = true;
                 break;
             }
         }
         if (!$found) {
             return false;
         }
     }
     return parent::is_available();
 }
 /**
  * Returns a value indicating the the Gateway is available or not.
  *
  * @return bool
  */
 public function is_available()
 {
     if (!parent::is_available()) {
         return false;
     }
     $errors = array();
     if (empty($this->email)) {
         $errors[] = __('Skrill Gateway - Email address is not configured.', $this->texdomain);
     }
     if (empty($this->secret_word)) {
         $errors[] = __('Skrill Gateway - Secret word is not configured.', $this->texdomain);
     }
     $currency = get_woocommerce_currency();
     if (!$this->is_currency_supported($currency)) {
         $errors[] = sprintf(__('Skrill Gateway - Currency not supported: "%s".', $this->texdomain), $currency);
     }
     // If, for any reason, the gateway is enabled, but not available due to
     // misconfiguration, log the issues and trigger a warning so that the Admin
     // can take the appropriate corrective action(s)
     if (!empty($errors)) {
         $errors[] = __('Skrill Gateway disabled.', $this->text_domain);
         foreach ($errors as $error_msg) {
             $this->log($error_msg);
             trigger_error($error_msg, E_USER_WARNING);
         }
         return false;
     }
     return true;
 }
 /**
  * Checks for proper gateway configuration (required fields populated, etc)
  * and that there are no missing dependencies
  *
  * @since 2.0
  */
 public function is_available()
 {
     global $wc_braintree;
     // is enabled check
     $is_available = parent::is_available();
     // proper configuration
     if (!$this->get_merchant_id() || !$this->get_public_key() || !$this->get_private_key() || !$this->get_cse_key()) {
         $is_available = false;
     }
     // all dependencies met
     if (count($wc_braintree->get_missing_dependencies()) > 0) {
         $is_available = false;
     }
     return apply_filters('wc_gateway_braintree_is_available', $is_available);
 }
 /**
  * Checks for proper gateway configuration including:
  *
  * + gateway enabled
  * + correct configuration (gateway specific)
  * + any dependencies met
  * + required currency
  * + required country
  *
  * @since 1.0.0
  * @see WC_Payment_Gateway::is_available()
  * @return true if this gateway is available for checkout, false otherwise
  */
 public function is_available()
 {
     // is enabled check
     $is_available = parent::is_available();
     // proper configuration
     if (!$this->is_configured()) {
         $is_available = false;
     }
     // all plugin dependencies met
     if (count($this->get_plugin()->get_missing_dependencies()) > 0) {
         $is_available = false;
     }
     // any required currencies?
     if (!$this->currency_is_accepted()) {
         $is_available = false;
     }
     // any required countries?
     if ($this->countries && WC()->customer && WC()->customer->get_country() && !in_array(WC()->customer->get_country(), $this->countries)) {
         $is_available = false;
     }
     /**
      * Payment Gateway Is Available Filter.
      *
      * Allow actors to modify whether the gateway is available or not.
      *
      * @since 1.0.0
      * @param bool $is_available
      */
     return apply_filters('wc_gateway_' . $this->get_id() . '_is_available', $is_available);
 }
 /**
  * Checks for proper gateway configuration including:
  *
  * + gateway enabled
  * + correct configuration (gateway specific)
  * + any dependencies met
  * + required currency
  * + required country
  *
  * @since 1.0.0
  * @see WC_Payment_Gateway::is_available()
  * @return true if this gateway is available for checkout, false otherwise
  */
 public function is_available()
 {
     // is enabled check
     $is_available = parent::is_available();
     // proper configuration
     if (!$this->is_configured()) {
         $is_available = false;
     }
     // all plugin dependencies met
     if (count($this->get_plugin()->get_missing_dependencies()) > 0) {
         $is_available = false;
     }
     // any required currencies?
     if (!$this->currency_is_accepted()) {
         $is_available = false;
     }
     // any required countries?
     if ($this->countries && WC()->customer && WC()->customer->get_country() && !in_array(WC()->customer->get_country(), $this->countries)) {
         $is_available = false;
     }
     return apply_filters('wc_gateway_' . $this->get_id() . '_is_available', $is_available);
 }
Ejemplo n.º 14
0
 /**
  * Check If The Gateway Is Available For Use
  *
  * @access public
  * @return bool
  */
 function is_available()
 {
     global $woocommerce;
     if (!empty($this->enable_for_methods)) {
         if (is_page(woocommerce_get_page_id('pay'))) {
             $order_id = (int) $_GET['order_id'];
             $order = new WC_Order($order_id);
             if (!$order->shipping_method) {
                 return false;
             }
             $chosen_method = $order->shipping_method;
         } elseif (empty($woocommerce->session->chosen_shipping_method)) {
             return false;
         } else {
             $chosen_method = $woocommerce->session->chosen_shipping_method;
         }
         $found = false;
         foreach ($this->enable_for_methods as $method_id) {
             if (strpos($chosen_method, $method_id) === 0) {
                 $found = true;
                 break;
             }
         }
         if (!$found) {
             return false;
         }
     }
     return parent::is_available();
 }
Ejemplo n.º 15
0
 /**
  * Check if this gateway is enabled and available in the user's country and for specific users
  *
  * @access public
  * @return bool
  */
 public function is_available()
 {
     global $current_user;
     get_currentuserinfo();
     $is_available = 'yes' === $this->enabled ? true : false;
     if ($this->get_option('debug') == 'yes') {
         $available_in_countries = $new_arr = array_map('trim', explode(',', $this->get_option('countries')));
         $available_to_customer_ids = $new_arr = array_map('trim', explode(',', $this->get_option('customer_ids')));
         $shipping_country = WC()->customer->get_shipping_country();
         if (!in_array($shipping_country, $available_in_countries)) {
             return false;
         }
         if (!in_array($current_user->user_email, $available_to_customer_ids)) {
             return false;
         }
     }
     return parent::is_available();
 }
Ejemplo n.º 16
0
 /**
  * Check if this gateway is enabled and configured.
  *
  * @see WC_Payment_Gateway::is_available()
  */
 public function is_available()
 {
     // proper configuration
     if (!$this->get_merchant_id() || !$this->get_shared_secret()) {
         return false;
     }
     // all dependencies met
     if (count(wc_realex()->get_missing_dependencies()) > 0) {
         return false;
     }
     return parent::is_available();
 }
Ejemplo n.º 17
0
 public function validate_fields()
 {
     return parent::is_available();
 }
 /**
  * Returns a value indicating the the Gateway is available or not. It's called
  * automatically by WooCommerce before allowing customers to use the gateway
  * for payment.
  *
  * @return bool
  */
 public function is_available()
 {
     // Test if is valid for use.
     $available = parent::is_available() && $this->check_environment() && $this->using_supported_currency() && $this->checks_for_webservice();
     return $available;
 }
 public function is_available()
 {
     $order = null;
     if (empty($this->authorizenet_apilogin) || empty($this->authorizenet_transactionkey)) {
         return false;
     }
     if (!empty($this->authorizenet_enable_for_methods)) {
         // Only apply if all packages are being shipped via local pickup
         $chosen_shipping_methods_session = WC()->session->get('chosen_shipping_methods');
         if (isset($chosen_shipping_methods_session)) {
             $chosen_shipping_methods = array_unique($chosen_shipping_methods_session);
         } else {
             $chosen_shipping_methods = array();
         }
         $check_method = false;
         if (is_object($order)) {
             if ($order->shipping_method) {
                 $check_method = $order->shipping_method;
             }
         } elseif (empty($chosen_shipping_methods) || sizeof($chosen_shipping_methods) > 1) {
             $check_method = false;
         } elseif (sizeof($chosen_shipping_methods) == 1) {
             $check_method = $chosen_shipping_methods[0];
         }
         if (!$check_method) {
             return false;
         }
         $found = false;
         foreach ($this->authorizenet_enable_for_methods as $method_id) {
             if (strpos($check_method, $method_id) === 0) {
                 $found = true;
                 break;
             }
         }
         if (!$found) {
             return false;
         }
     }
     return parent::is_available();
 }
 /**
  * Checks for proper gateway configuration (required fields populated, etc)
  * and that there are no missing dependencies
  *
  * @see WC_Payment_Gateway::is_available()
  */
 public function is_available()
 {
     // proper configuration
     if (!$this->get_ssl_merchant_id() || !$this->get_ssl_user_id() || !$this->get_ssl_pin()) {
         return false;
     }
     // all dependencies met
     if (count(wc_elavon_vm()->get_missing_dependencies()) > 0) {
         return false;
     }
     return parent::is_available();
 }
 /**
  * Check If The Gateway Is Available For Use
  *
  * @return bool
  */
 public function is_available()
 {
     $order = null;
     if (!$this->enable_for_virtual) {
         if (WC()->cart && !WC()->cart->needs_shipping()) {
             return false;
         }
         if (is_page(wc_get_page_id('checkout')) && 0 < get_query_var('order-pay')) {
             $order_id = absint(get_query_var('order-pay'));
             $order = new WC_Order($order_id);
             // Test if order needs shipping.
             $needs_shipping = false;
             if (0 < sizeof($order->get_items())) {
                 foreach ($order->get_items() as $item) {
                     $_product = $order->get_product_from_item($item);
                     if ($_product->needs_shipping()) {
                         $needs_shipping = true;
                         break;
                     }
                 }
             }
             $needs_shipping = apply_filters('woocommerce_cart_needs_shipping', $needs_shipping);
             if ($needs_shipping) {
                 return false;
             }
         }
     }
     if (!empty($this->enable_for_methods)) {
         // Only apply if all packages are being shipped via local pickup
         $chosen_shipping_methods_session = WC()->session->get('chosen_shipping_methods');
         if (isset($chosen_shipping_methods_session)) {
             $chosen_shipping_methods = array_unique($chosen_shipping_methods_session);
         } else {
             $chosen_shipping_methods = array();
         }
         $check_method = false;
         if (is_object($order)) {
             if ($order->shipping_method) {
                 $check_method = $order->shipping_method;
             }
         } elseif (empty($chosen_shipping_methods) || sizeof($chosen_shipping_methods) > 1) {
             $check_method = false;
         } elseif (sizeof($chosen_shipping_methods) == 1) {
             $check_method = $chosen_shipping_methods[0];
         }
         if (!$check_method) {
             return false;
         }
         $found = false;
         foreach ($this->enable_for_methods as $method_id) {
             if (strpos($check_method, $method_id) === 0) {
                 $found = true;
                 break;
             }
         }
         if (!$found) {
             return false;
         }
     }
     return parent::is_available();
 }
 /**
  * Returns a value indicating the the Gateway is available or not. It's called
  * automatically by WooCommerce before allowing customers to use the gateway
  * for payment.
  *
  * @return bool
  */
 public function is_available()
 {
     // Test if is valid for use.
     $available = parent::is_available() && 'yes' == $this->get_option('enabled') && !empty($this->api_key) && !empty($this->encryption_key) && $this->using_supported_currency();
     return $available;
 }