WC_Shipping::load_shipping_methods()publicWC 1.0

Loads all shipping methods which are hooked in. If a $package is passed, some methods may add themselves conditionally and zones will be used.

Метод класса: WC_Shipping{}

Хуки из метода

Возвращает

WC_Shipping_Method[].

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

$WC_Shipping = new WC_Shipping();
$WC_Shipping->load_shipping_methods( $package );
$package(массив)
Package information.
По умолчанию: array()

Код WC_Shipping::load_shipping_methods() WC 8.7.0

public function load_shipping_methods( $package = array() ) {
	if ( ! empty( $package ) ) {
		$debug_mode             = 'yes' === get_option( 'woocommerce_shipping_debug_mode', 'no' );
		$shipping_zone          = WC_Shipping_Zones::get_zone_matching_package( $package );
		$this->shipping_methods = $shipping_zone->get_shipping_methods( true );

		// translators: %s: shipping zone name.
		$matched_zone_notice = sprintf( __( 'Customer matched zone "%s"', 'woocommerce' ), $shipping_zone->get_zone_name() );

		// Debug output.
		if ( $debug_mode && ! Constants::is_defined( 'WOOCOMMERCE_CHECKOUT' ) && ! Constants::is_defined( 'WC_DOING_AJAX' ) && ! wc_has_notice( $matched_zone_notice ) ) {
			wc_add_notice( $matched_zone_notice );
		}
	} else {
		$this->shipping_methods = array();
	}

	// For the settings in the backend, and for non-shipping zone methods, we still need to load any registered classes here.
	foreach ( $this->get_shipping_method_class_names() as $method_id => $method_class ) {
		$this->register_shipping_method( $method_class );
	}

	// Methods can register themselves manually through this hook if necessary.
	do_action( 'woocommerce_load_shipping_methods', $package );

	// Return loaded methods.
	return $this->get_shipping_methods();
}