WordPress at Your Fingertips
function is not described

WC_Cart::needs_shipping() public WC 1.0

Looks through the cart to see if shipping is actually required.

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

Hooks from the method
Return

true|false. whether or not the cart needs shipping

Usage

$WC_Cart = new WC_Cart();
$WC_Cart->needs_shipping();

Code of WC_Cart::needs_shipping() WC 5.6.0

public function needs_shipping() {
	if ( ! wc_shipping_enabled() || 0 === wc_get_shipping_method_count( true ) ) {
		return false;
	}
	$needs_shipping = false;

	foreach ( $this->get_cart_contents() as $cart_item_key => $values ) {
		if ( $values['data']->needs_shipping() ) {
			$needs_shipping = true;
			break;
		}
	}

	return apply_filters( 'woocommerce_cart_needs_shipping', $needs_shipping );
}