WordPress at Your Fingertips
function is not described

WC_Shipping_Method::is_available() public WC 1.0

Is this method available?

{} It's a method of the class: WC_Shipping_Method{}

Return

true|false.

Usage

$WC_Shipping_Method = new WC_Shipping_Method();
$WC_Shipping_Method->is_available( $package );
$package(array) (required)
Package.

Code of WC_Shipping_Method::is_available() WC 5.8.0

public function is_available( $package ) {
	$available = $this->is_enabled();

	// Country availability (legacy, for non-zone based methods).
	if ( ! $this->instance_id && $available ) {
		$countries = is_array( $this->countries ) ? $this->countries : array();

		switch ( $this->availability ) {
			case 'specific':
			case 'including':
				$available = in_array( $package['destination']['country'], array_intersect( $countries, array_keys( WC()->countries->get_shipping_countries() ) ) );
				break;
			case 'excluding':
				$available = in_array( $package['destination']['country'], array_diff( array_keys( WC()->countries->get_shipping_countries() ), $countries ) );
				break;
			default:
				$available = in_array( $package['destination']['country'], array_keys( WC()->countries->get_shipping_countries() ) );
				break;
		}
	}

	return apply_filters( 'woocommerce_shipping_' . $this->id . '_is_available', $available, $package, $this );
}