WC_Cart::needs_shipping()publicWC 1.0

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

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

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

Возвращает

true|false. whether or not the cart needs shipping

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

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

Код WC_Cart::needs_shipping() WC 8.7.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 $values ) {
		if ( $values['data']->needs_shipping() ) {
			$needs_shipping = true;
			break;
		}
	}

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