Merged in feature/MAW-855-import-code-into-aws (pull request #2)
code import from pantheon * code import from pantheon
This commit is contained in:
@@ -557,18 +557,27 @@ class WC_Order extends WC_Abstract_Order {
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param string $prop Name of prop to get.
|
||||
* @param string $address billing or shipping.
|
||||
* @param string $address_type Type of address; 'billing' or 'shipping'.
|
||||
* @param string $context What the value is for. Valid values are view and edit.
|
||||
* @return mixed
|
||||
*/
|
||||
protected function get_address_prop( $prop, $address = 'billing', $context = 'view' ) {
|
||||
protected function get_address_prop( $prop, $address_type = 'billing', $context = 'view' ) {
|
||||
$value = null;
|
||||
|
||||
if ( array_key_exists( $prop, $this->data[ $address ] ) ) {
|
||||
$value = isset( $this->changes[ $address ][ $prop ] ) ? $this->changes[ $address ][ $prop ] : $this->data[ $address ][ $prop ];
|
||||
if ( array_key_exists( $prop, $this->data[ $address_type ] ) ) {
|
||||
$value = isset( $this->changes[ $address_type ][ $prop ] ) ? $this->changes[ $address_type ][ $prop ] : $this->data[ $address_type ][ $prop ];
|
||||
|
||||
if ( 'view' === $context ) {
|
||||
$value = apply_filters( $this->get_hook_prefix() . $address . '_' . $prop, $value, $this );
|
||||
/**
|
||||
* Filter: 'woocommerce_order_get_[billing|shipping]_[prop]'
|
||||
*
|
||||
* Allow developers to change the returned value for any order address property.
|
||||
*
|
||||
* @since 3.6.0
|
||||
* @param string $value The address property value.
|
||||
* @param WC_Order $order The order object being read.
|
||||
*/
|
||||
$value = apply_filters( $this->get_hook_prefix() . $address_type . '_' . $prop, $value, $this );
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
@@ -896,11 +905,20 @@ class WC_Order extends WC_Abstract_Order {
|
||||
* Note: Merges raw data with get_prop data so changes are returned too.
|
||||
*
|
||||
* @since 2.4.0
|
||||
* @param string $type Billing or shipping. Anything else besides 'billing' will return shipping address.
|
||||
* @param string $address_type Type of address; 'billing' or 'shipping'.
|
||||
* @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 );
|
||||
public function get_address( $address_type = 'billing' ) {
|
||||
/**
|
||||
* Filter: 'woocommerce_get_order_address'
|
||||
*
|
||||
* Allow developers to change the returned value for an order's billing or shipping address.
|
||||
*
|
||||
* @since 2.4.0
|
||||
* @param array $address_data The raw address data merged with the data from get_prop.
|
||||
* @param string $address_type Type of address; 'billing' or 'shipping'.
|
||||
*/
|
||||
return apply_filters( 'woocommerce_get_order_address', array_merge( $this->data[ $address_type ], $this->get_prop( $address_type, 'view' ) ), $address_type, $this );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1067,17 +1085,17 @@ class WC_Order extends WC_Abstract_Order {
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param string $prop Name of prop to set.
|
||||
* @param string $address Name of address to set. billing or shipping.
|
||||
* @param string $address_type Type of address; 'billing' or 'shipping'.
|
||||
* @param mixed $value Value of the prop.
|
||||
*/
|
||||
protected function set_address_prop( $prop, $address, $value ) {
|
||||
if ( array_key_exists( $prop, $this->data[ $address ] ) ) {
|
||||
protected function set_address_prop( $prop, $address_type, $value ) {
|
||||
if ( array_key_exists( $prop, $this->data[ $address_type ] ) ) {
|
||||
if ( true === $this->object_read ) {
|
||||
if ( $value !== $this->data[ $address ][ $prop ] || ( isset( $this->changes[ $address ] ) && array_key_exists( $prop, $this->changes[ $address ] ) ) ) {
|
||||
$this->changes[ $address ][ $prop ] = $value;
|
||||
if ( $value !== $this->data[ $address_type ][ $prop ] || ( isset( $this->changes[ $address_type ] ) && array_key_exists( $prop, $this->changes[ $address_type ] ) ) ) {
|
||||
$this->changes[ $address_type ][ $prop ] = $value;
|
||||
}
|
||||
} else {
|
||||
$this->data[ $address ][ $prop ] = $value;
|
||||
$this->data[ $address_type ][ $prop ] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1784,6 +1802,15 @@ class WC_Order extends WC_Abstract_Order {
|
||||
* @return string
|
||||
*/
|
||||
public function get_cancel_order_url( $redirect = '' ) {
|
||||
/**
|
||||
* Filter the URL to cancel the order in the frontend.
|
||||
*
|
||||
* @since 2.2.0
|
||||
*
|
||||
* @param string $url
|
||||
* @param WC_Order $order Order data.
|
||||
* @param string $redirect Redirect URL.
|
||||
*/
|
||||
return apply_filters(
|
||||
'woocommerce_get_cancel_order_url',
|
||||
wp_nonce_url(
|
||||
@@ -1797,7 +1824,9 @@ class WC_Order extends WC_Abstract_Order {
|
||||
$this->get_cancel_endpoint()
|
||||
),
|
||||
'woocommerce-cancel_order'
|
||||
)
|
||||
),
|
||||
$this,
|
||||
$redirect
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1808,6 +1837,15 @@ class WC_Order extends WC_Abstract_Order {
|
||||
* @return string The unescaped cancel-order URL.
|
||||
*/
|
||||
public function get_cancel_order_url_raw( $redirect = '' ) {
|
||||
/**
|
||||
* Filter the raw URL to cancel the order in the frontend.
|
||||
*
|
||||
* @since 2.2.0
|
||||
*
|
||||
* @param string $url
|
||||
* @param WC_Order $order Order data.
|
||||
* @param string $redirect Redirect URL.
|
||||
*/
|
||||
return apply_filters(
|
||||
'woocommerce_get_cancel_order_url_raw',
|
||||
add_query_arg(
|
||||
@@ -1819,7 +1857,9 @@ class WC_Order extends WC_Abstract_Order {
|
||||
'_wpnonce' => wp_create_nonce( 'woocommerce-cancel_order' ),
|
||||
),
|
||||
$this->get_cancel_endpoint()
|
||||
)
|
||||
),
|
||||
$this,
|
||||
$redirect
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user