Skip to content

Commit

Permalink
Merge pull request woocommerce#19866 from rnaby/260418-091223-wc-chec…
Browse files Browse the repository at this point in the history
…kout

get_value method refactored
  • Loading branch information
mikejolley authored Apr 26, 2018
2 parents 6a1cd80 + e1fea55 commit 79c6c6c
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions includes/class-wc-checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -1058,24 +1058,24 @@ public function get_posted_address_data( $key, $type = 'billing' ) {
* @return string
*/
public function get_value( $input ) {
if ( ! empty( $_POST[ $input ] ) ) { // WPCS: input var ok, CSRF OK.
return wc_clean( wp_unslash( $_POST[ $input ] ) ); // WPCS: input var ok, CSRF OK.

} else {

$value = apply_filters( 'woocommerce_checkout_get_value', null, $input );
// WPCS: input var ok, CSRF OK.
if ( ! empty( $_POST[ $input ] ) ) {
// WPCS: input var ok, CSRF OK.
return wc_clean( wp_unslash( $_POST[ $input ] ) );
}

if ( null !== $value ) {
return $value;
}
$value = apply_filters( 'woocommerce_checkout_get_value', null, $input );

if ( is_callable( array( WC()->customer, "get_$input" ) ) ) {
$value = WC()->customer->{"get_$input"}() ? WC()->customer->{"get_$input"}() : null;
} elseif ( WC()->customer->meta_exists( $input ) ) {
$value = WC()->customer->get_meta( $input, true );
}
if ( null !== $value ) {
return $value;
}

return apply_filters( 'default_checkout_' . $input, $value, $input );
if ( is_callable( array( WC()->customer, "get_$input" ) ) ) {
$value = WC()->customer->{"get_$input"}() ? WC()->customer->{"get_$input"}() : null;
} elseif ( WC()->customer->meta_exists( $input ) ) {
$value = WC()->customer->get_meta( $input, true );
}

return apply_filters( 'default_checkout_' . $input, $value, $input );
}
}

0 comments on commit 79c6c6c

Please sign in to comment.