/** 
  * Get destination address for order
  *
  * @since 4.2
  * @return (array) associative array containing customer address
  */
 public function get_destination_address()
 {
     // Retrieve "tax based on" option
     $tax_based_on = get_option('woocommerce_tax_based_on');
     // Return origin address if this is a local pickup order
     if (wt_is_local_pickup($this->get_shipping_method()) || $tax_based_on == 'base') {
         return wootax_get_address(apply_filters('wootax_pickup_address', WT_DEFAULT_ADDRESS, $this->addresses, -1));
     }
     // Initialize blank address array
     $address = array();
     // Fetch BOTH billing and shipping address
     $addresses = array('billing' => array('address_1' => WC()->customer->get_address(), 'address_2' => WC()->customer->get_address_2(), 'country' => WC()->customer->get_country(), 'state' => WC()->customer->get_state(), 'city' => WC()->customer->get_city(), 'zip5' => WC()->customer->get_postcode()), 'shipping' => array('address_1' => WC()->customer->get_shipping_address(), 'address_2' => WC()->customer->get_shipping_address_2(), 'country' => WC()->customer->get_shipping_country(), 'state' => WC()->customer->get_shipping_state(), 'city' => WC()->customer->get_shipping_city(), 'zip5' => WC()->customer->get_shipping_postcode()));
     // Attempt to fetch address preferred according to "tax based on" option; otherwise, return billing address
     $address_1 = $addresses['billing']['address_1'];
     $address_2 = $addresses['billing']['address_2'];
     $country = $addresses['billing']['country'];
     $state = $addresses['billing']['state'];
     $city = $addresses['billing']['city'];
     $zip5 = $addresses['billing']['zip5'];
     if ($tax_based_on) {
         $address_1 = !empty($addresses[$tax_based_on]['address_1']) ? $addresses[$tax_based_on]['address_1'] : $address_1;
         $address_2 = !empty($addresses[$tax_based_on]['address_2']) ? $addresses[$tax_based_on]['address_2'] : $address_2;
         $country = !empty($addresses[$tax_based_on]['country']) ? $addresses[$tax_based_on]['country'] : $country;
         $state = !empty($addresses[$tax_based_on]['state']) ? $addresses[$tax_based_on]['state'] : $state;
         $city = !empty($addresses[$tax_based_on]['city']) ? $addresses[$tax_based_on]['city'] : $city;
         $zip5 = !empty($addresses[$tax_based_on]['zip5']) ? $addresses[$tax_based_on]['zip5'] : $zip5;
     }
     // Build/return Address array
     $parsed_zip = parse_zip($zip5);
     $address['Address1'] = $address_1;
     $address['Address2'] = $address_2;
     $address['Country'] = $country;
     $address['State'] = $state;
     $address['City'] = $city;
     $address['Zip5'] = $parsed_zip['zip5'];
     $address['Zip4'] = $parsed_zip['zip4'];
     return $address;
 }
 /** 
  * Set destination address for order
  * This is either the customer billing address or shipping address depending on the shop settings
  * Can also be a business address if a local pickup method is being used
  *
  * @since 4.2
  * @return void
  */
 public function set_destination_address()
 {
     // Retrieve "tax based on" option
     $tax_based_on = get_option('woocommerce_tax_based_on');
     // Return origin address if this is a local pickup order
     if (wt_is_local_pickup($this->get_shipping_method()) || $tax_based_on == 'base') {
         return wootax_get_address(apply_filters('wootax_pickup_address', WT_DEFAULT_ADDRESS, WT_Orders::$addresses, $this->order_id));
     }
     // Attempt to fetch preferred address according to "tax based on" option; return billing by default
     $address_1 = $this->order->billing_address_1;
     $address_2 = $this->order->billing_address_2;
     $country = $this->order->billing_country;
     $state = $this->order->billing_state;
     $city = $this->order->billing_city;
     $zip5 = $this->order->billing_postcode;
     if ($tax_based_on == 'shipping') {
         $address_1 = !empty($this->order->shipping_address_1) ? $this->order->shipping_address_1 : $address_1;
         $address_2 = !empty($this->order->shipping_address_2) ? $this->order->shipping_address_2 : $address_2;
         $country = !empty($this->order->shipping_country) ? $this->order->shipping_country : $country;
         $state = !empty($this->order->shipping_state) ? $this->order->shipping_state : $state;
         $city = !empty($this->order->shipping_city) ? $this->order->shipping_city : $city;
         $zip5 = !empty($this->order->shipping_postcode) ? $this->order->shipping_postcode : $zip5;
     }
     // If address isn't saved yet, we will fall back to POSTed fields
     $post_zip = isset($_POST['postcode']) ? $_POST['postcode'] : '';
     $post_country = isset($_POST['country']) ? $_POST['country'] : '';
     $post_state = isset($_POST['state']) ? $_POST['state'] : '';
     $post_city = isset($_POST['city']) ? $_POST['city'] : '';
     // Parse ZIP code, splitting it into its 5 and 4-digit components
     $parsed_zip = parse_zip(!empty($zip5) ? $zip5 : $post_zip);
     // Return final address
     $address = array('Address1' => !empty($address_1) ? $address_1 : '', 'Address2' => !empty($address_2) ? $address_2 : '', 'Country' => !empty($country) ? $country : $post_country, 'State' => !empty($state) ? $state : $post_state, 'City' => !empty($city) ? $city : $post_city, 'Zip5' => $parsed_zip['zip5'], 'Zip4' => $parsed_zip['zip4']);
     $this->destination_address = $address;
 }
 /**
  * Get destination address information from original order
  *
  * @since 4.2
  */
 public function get_destination_address($order)
 {
     // Initialize blank address array
     $address = array();
     // Construct final address arraya
     $parsed_zip = parse_zip($order->shipping_postcode);
     $address['Address1'] = $order->shipping_address_1;
     $address['Address2'] = $order->shipping_address_2;
     $address['Country'] = $order->shipping_country;
     $address['State'] = $order->shipping_state;
     $address['City'] = $order->shipping_city;
     $address['Zip5'] = $parsed_zip['zip5'];
     $address['Zip4'] = $parsed_zip['zip4'];
     // Return final address
     return $address;
 }