WC_Cart::needs_shipping() public WC 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 Cart::needs shipping WC 5.0.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 );
}