Improve type safety (avoid trying to multiply a string by an int).

This commit is contained in:
barryhughes 2021-08-12 16:27:05 -07:00
parent 9eb0b36174
commit d6fda6768a
2 changed files with 2 additions and 2 deletions

View File

@ -226,7 +226,7 @@ final class WC_Cart_Totals {
$item->taxable = 'taxable' === $cart_item['data']->get_tax_status(); $item->taxable = 'taxable' === $cart_item['data']->get_tax_status();
$item->price_includes_tax = wc_prices_include_tax(); $item->price_includes_tax = wc_prices_include_tax();
$item->quantity = $cart_item['quantity']; $item->quantity = $cart_item['quantity'];
$item->price = wc_add_number_precision_deep( $cart_item['data']->get_price() * $cart_item['quantity'] ); $item->price = wc_add_number_precision_deep( (float) $cart_item['data']->get_price() * (int) $cart_item['quantity'] );
$item->product = $cart_item['data']; $item->product = $cart_item['data'];
$item->tax_rates = $this->get_item_tax_rates( $item ); $item->tax_rates = $this->get_item_tax_rates( $item );
$this->items[ $cart_item_key ] = $item; $this->items[ $cart_item_key ] = $item;

View File

@ -84,7 +84,7 @@ class WC_Discounts {
$item->object = $cart_item; $item->object = $cart_item;
$item->product = $cart_item['data']; $item->product = $cart_item['data'];
$item->quantity = $cart_item['quantity']; $item->quantity = $cart_item['quantity'];
$item->price = wc_add_number_precision_deep( $item->product->get_price() * $item->quantity ); $item->price = wc_add_number_precision_deep( (float) $item->product->get_price() * (int) $item->quantity );
$this->items[ $key ] = $item; $this->items[ $key ] = $item;
} }