WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Платформа для конвертации и монетизации трафика
функция не описана

WC_Shipping_Legacy_Free_Shipping::is_available() public WC 1.0

Check if package is available.

{} Это метод класса: WC_Shipping_Legacy_Free_Shipping{}

Хуки из метода
Возвращает

true/false.

Использование

$WC_Shipping_Legacy_Free_Shipping = new WC_Shipping_Legacy_Free_Shipping();
$WC_Shipping_Legacy_Free_Shipping->is_available( $package );
$package(массив) (обязательный)
Package information.

Код WC_Shipping_Legacy_Free_Shipping::is_available() WC 4.7.1

<?php
public function is_available( $package ) {
	if ( 'no' === $this->enabled ) {
		return false;
	}

	if ( 'specific' === $this->availability ) {
		$ship_to_countries = $this->countries;
	} else {
		$ship_to_countries = array_keys( WC()->countries->get_shipping_countries() );
	}

	if ( is_array( $ship_to_countries ) && ! in_array( $package['destination']['country'], $ship_to_countries, true ) ) {
		return false;
	}

	// Enabled logic.
	$is_available       = false;
	$has_coupon         = false;
	$has_met_min_amount = false;

	if ( in_array( $this->requires, array( 'coupon', 'either', 'both' ), true ) ) {
		$coupons = WC()->cart->get_coupons();

		if ( $coupons ) {
			foreach ( $coupons as $code => $coupon ) {
				if ( $coupon->is_valid() && $coupon->get_free_shipping() ) {
					$has_coupon = true;
				}
			}
		}
	}

	if ( in_array( $this->requires, array( 'min_amount', 'either', 'both' ), true ) ) {
		$total = WC()->cart->get_displayed_subtotal();

		if ( WC()->cart->display_prices_including_tax() ) {
			$total = NumberUtil::round( $total - ( WC()->cart->get_discount_total() + WC()->cart->get_discount_tax() ), wc_get_price_decimals() );
		} else {
			$total = NumberUtil::round( $total - WC()->cart->get_discount_total(), wc_get_price_decimals() );
		}

		if ( $total >= $this->min_amount ) {
			$has_met_min_amount = true;
		}
	}

	switch ( $this->requires ) {
		case 'min_amount':
			if ( $has_met_min_amount ) {
				$is_available = true;
			}
			break;
		case 'coupon':
			if ( $has_coupon ) {
				$is_available = true;
			}
			break;
		case 'both':
			if ( $has_met_min_amount && $has_coupon ) {
				$is_available = true;
			}
			break;
		case 'either':
			if ( $has_met_min_amount || $has_coupon ) {
				$is_available = true;
			}
			break;
		default:
			$is_available = true;
			break;
	}

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