WC_Order::get_address PHP Method

get_address() public method

Note: Merges raw data with get_prop data so changes are returned too.
Since: 2.4.0
public get_address ( string $type = 'billing' ) : array
$type string Billing or shipping. Anything else besides 'billing' will return shipping address.
return array The stored address after filter.
    public function get_address($type = 'billing')
    {
        return apply_filters('woocommerce_get_order_address', array_merge($this->data[$type], $this->get_prop($type, 'view')), $type, $this);
    }

Usage Example

 public function get_shipping_data()
 {
     $data = [];
     foreach ($this->get_fraktguiden_shipping_items() as $item_id => $method) {
         $pickup_point_id = wc_get_order_item_meta($item_id, '_fraktguiden_pickup_point_id', true);
         $pickup_point = null;
         $pickup_point_cached = null;
         $pickup_point_postcode = null;
         if ($pickup_point_id) {
             $shipping_address = $this->order->get_address('shipping');
             $request = new WP_Bring_Request();
             $response = $request->get('https://api.bring.com/pickuppoint/api/pickuppoint/' . $shipping_address['country'] . '/id/' . $pickup_point_id . '.json');
             $pickup_point = $response->has_errors() ? null : json_decode($response->get_body())->pickupPoint[0];
             $pickup_point_cached = wc_get_order_item_meta($item_id, '_fraktguiden_pickup_point_cached', true);
             $pickup_point_postcode = wc_get_order_item_meta($item_id, '_fraktguiden_pickup_point_postcode', true);
         }
         $data[] = ['item_id' => $item_id, 'pickup_point' => $pickup_point, 'pickup_point_info_cached' => $pickup_point_cached, 'postcode' => $pickup_point_postcode, 'packages' => json_encode($this->get_packages_for_order_item($item_id))];
     }
     return $data;
 }
All Usage Examples Of WC_Order::get_address
WC_Order