Adds a new filter to allow customization of the stock check message when a product is out of stock, but accounting for what's already in the cart. It mimics the existing woocommerce_cart_product_not_enough_stock_message filter.
We hold coupons when payment is failed if the setting "hold stock for checkout" is enabled for some minutes. This is to allow the customers to try again if they want, and to give time to complete payment for gateways where it could take some time.
Unfortunately this cause for some bad UX user retries by starting the order from scratch again, and then if they apply the coupon, usage limit gets hit because the earlier coupon is still held and is counted towards the usage. This commit improves the error message in these cases when usage is applied per customer and is hit, by stating to go to my account to complete/cancel payment (in case of logged in user) or to wait for some time in case of guest users.
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 doing state and postcode even for countries where its not required, but unfortunately as an unintended effect we were ending up not checking shipping requirements if this was not met.
`wc_round_tax_total` is for when prices are inclusive of taxes, however, shipping taxes can never include taxes so they should always use `round( $price, wc_price_get_decimals() )` instead.
When rounding at subtotal is enabled, line items are already rounded where they need to, so we only should do any further rounding when displaying values and no where else.
This is part of our larger attempt to remove individual rounding as much as possible.
In a previous commit, a regression was introduced where we were no
longer checking for usage limit of guest user in an install. This
commit adds back that check.