WC_Payment_Gateway::is_available PHP Method

is_available() public method

Check if the gateway is available for use.
public is_available ( ) : boolean
return boolean
    public function is_available()
    {
        $is_available = 'yes' === $this->enabled;
        if (WC()->cart && 0 < $this->get_order_total() && 0 < $this->max_amount && $this->max_amount < $this->get_order_total()) {
            $is_available = false;
        }
        return $is_available;
    }

Usage Example

 /**
  * 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);
 }
All Usage Examples Of WC_Payment_Gateway::is_available