Automattic\WooCommerce\Blocks\Utils

CartCheckoutUtils::shipping_methods_existpublic staticWC 1.0

Returns true if shipping methods exist in the store. Excludes local pickup and only counts enabled shipping methods.

Method of the class: CartCheckoutUtils{}

No Hooks.

Returns

true|false. true if shipping methods exist.

Usage

$result = CartCheckoutUtils::shipping_methods_exist();

CartCheckoutUtils::shipping_methods_exist() code WC 9.9.3

public static function shipping_methods_exist() {
	// Local pickup is included with legacy shipping methods since they do not support shipping zones.
	$local_pickup_count = count(
		array_filter(
			WC()->shipping()->get_shipping_methods(),
			function ( $method ) {
				return isset( $method->enabled ) && 'yes' === $method->enabled && ! $method->supports( 'shipping-zones' ) && $method->supports( 'local-pickup' );
			}
		)
	);

	$shipping_methods_count = wc_get_shipping_method_count( true, true ) - $local_pickup_count;
	return $shipping_methods_count > 0;
}