Adds WC_Abstract_Order->get_address
Adds a function to retrieve order address in non-localized, raw, non-formatted way.
This commit is contained in:
parent
92c048c9ff
commit
1dfb27f928
|
@ -171,6 +171,44 @@ abstract class WC_Abstract_Order {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the requested address in raw, non-formatted way
|
||||
* @param string $type Billing or shipping. Anything else besides 'billing' will return shipping address
|
||||
* @return array The stored address after filter
|
||||
*/
|
||||
public function get_address( $type = 'billing' ) {
|
||||
|
||||
if ( 'billing' === $type ) {
|
||||
$address = array(
|
||||
'first_name' => $this->billing_first_name,
|
||||
'last_name' => $this->billing_last_name,
|
||||
'company' => $this->billing_company,
|
||||
'address_1' => $this->billing_address_1,
|
||||
'address_2' => $this->billing_address_2,
|
||||
'city' => $this->billing_city,
|
||||
'state' => $this->billing_state,
|
||||
'postcode' => $this->billing_postcode,
|
||||
'country' => $this->billing_country,
|
||||
'email' => $this->billing_email,
|
||||
'phone' => $this->billing_phone,
|
||||
);
|
||||
} else {
|
||||
$address = array(
|
||||
'first_name' => $this->shipping_first_name,
|
||||
'last_name' => $this->shipping_last_name,
|
||||
'company' => $this->shipping_company,
|
||||
'address_1' => $this->shipping_address_1,
|
||||
'address_2' => $this->shipping_address_2,
|
||||
'city' => $this->shipping_city,
|
||||
'state' => $this->shipping_state,
|
||||
'postcode' => $this->shipping_postcode,
|
||||
'country' => $this->shipping_country,
|
||||
);
|
||||
}
|
||||
|
||||
return apply_filters( 'woocommerce_get_order_address', $address, $type, $this );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a product line item to the order
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue