There's a number of places in the WooCommerce codebase where the
built-in function 'round' is executed passing a non-numeric value
(not a number and not a string that can be parsed as a number),
for example round(''). In PHP 7 this yields a value of 0, but in
PHP 8 this throws an error.
This commit adds a 'NumberUtil' class with a static 'round' method,
this method checks if the passed value is numeric and if so it just
executes the built-in function, otherwise it returns 0. And all the
calls to 'round' in the codebase are replaced with 'NumberUtil::round'.
We were calculating subtotal to display slightly differently then we would have calculated subtotal in the cart. This was affecting subtotal value in invoices and in order confirmation screen.
This patch updates how we calculate subtotal to display such that we calculate in same way.
We added a trait to move shared logic betweem Orders and Cart. This commit refactors Order class to use that shared logic.
Also adds a test for a failing case.
`WC_Abstract_Order` and `WC_Cart_Totals` have their own logic to calculate totals. This means that we would have to fix in two places. This commit adds a trait which can be used to place shared logic between above two classes.