WC_Order::needs_shipping_address
Checks if an order needs display the shipping address, based on shipping method.
Method of the class: WC_Order{}
Hooks from the method
Returns
true|false.
Usage
$WC_Order = new WC_Order(); $WC_Order->needs_shipping_address();
WC_Order::needs_shipping_address() WC Order::needs shipping address code WC 10.6.2
public function needs_shipping_address() {
if ( 'no' === get_option( 'woocommerce_calc_shipping' ) ) {
return false;
}
/**
* Filter to hide the shipping address for an order.
*
* @param array $hide The shipping methods to hide the shipping address for.
* @param WC_Order $this The order object.
* @since 2.7.0
*/
$hide = apply_filters( 'woocommerce_order_hide_shipping_address', LocalPickupUtils::get_local_pickup_method_ids(), $this );
$needs_address = false;
foreach ( $this->get_shipping_methods() as $shipping_method ) {
$shipping_method_id = $shipping_method->get_method_id();
if ( ! in_array( $shipping_method_id, $hide, true ) ) {
$needs_address = true;
break;
}
}
return apply_filters( 'woocommerce_order_needs_shipping_address', $needs_address, $hide, $this );
}