Fix type safety issues in product price (#33926)

This commit is contained in:
Kirtan Gajjar 2022-07-20 12:40:18 +05:30 committed by GitHub
parent 4ffd5992a9
commit 2e735ed5f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Add type safety while getting product price

View File

@ -987,7 +987,7 @@ function wc_get_price_including_tax( $product, $args = array() ) {
)
);
$price = '' !== $args['price'] ? max( 0.0, (float) $args['price'] ) : $product->get_price();
$price = '' !== $args['price'] ? max( 0.0, (float) $args['price'] ) : (float) $product->get_price();
$qty = '' !== $args['qty'] ? max( 0.0, (float) $args['qty'] ) : 1;
if ( '' === $price ) {
@ -1071,7 +1071,7 @@ function wc_get_price_excluding_tax( $product, $args = array() ) {
)
);
$price = '' !== $args['price'] ? max( 0.0, (float) $args['price'] ) : $product->get_price();
$price = '' !== $args['price'] ? max( 0.0, (float) $args['price'] ) : (float) $product->get_price();
$qty = '' !== $args['qty'] ? max( 0.0, (float) $args['qty'] ) : 1;
if ( '' === $price ) {