Merge pull request #14460 from woocommerce/add/has_shipping_address

Added has_shipping_address helper method
This commit is contained in:
Claudio Sanches 2017-04-17 11:18:53 -03:00 committed by GitHub
commit 9c33d9bbf3
1 changed files with 11 additions and 1 deletions

View File

@ -813,13 +813,23 @@ class WC_Order extends WC_Abstract_Order {
* @return string
*/
public function get_formatted_shipping_address() {
if ( $this->get_shipping_address_1() || $this->get_shipping_address_2() ) {
if ( $this->has_shipping_address() ) {
return WC()->countries->get_formatted_address( apply_filters( 'woocommerce_order_formatted_shipping_address', $this->get_address( 'shipping' ), $this ) );
} else {
return '';
}
}
/**
* Returns true if the order has a shipping address.
*
* @since 3.0.4
* @return boolean
*/
public function has_shipping_address() {
return $this->get_shipping_address_1() || $this->get_shipping_address_2();
}
/*
|--------------------------------------------------------------------------
| Setters