Merge pull request #20212 from rnaby/240518-225308-wc-core-functions-wc_remove_number_precision_deep

wc_remove_number_precision_deep logic simplified
This commit is contained in:
Mike Jolley 2018-05-25 10:39:48 +01:00 committed by GitHub
commit 2a10ef31fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 7 deletions

View File

@ -1604,16 +1604,17 @@ function wc_add_number_precision_deep( $value, $round = true ) {
* *
* @since 3.2.0 * @since 3.2.0
* @param array $value Number to add precision to. * @param array $value Number to add precision to.
* @return int * @return int|array
*/ */
function wc_remove_number_precision_deep( $value ) { function wc_remove_number_precision_deep( $value ) {
if ( is_array( $value ) ) { if ( ! is_array( $value ) ) {
foreach ( $value as $key => $subvalue ) { return wc_remove_number_precision( $value );
$value[ $key ] = wc_remove_number_precision_deep( $subvalue );
} }
} else {
$value = wc_remove_number_precision( $value ); foreach ( $value as $key => $sub_value ) {
$value[ $key ] = wc_remove_number_precision_deep( $sub_value );
} }
return $value; return $value;
} }