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'.
Previously 'dirname( __FILE__ )' was used to import files, however, the directory separator was missing.
This commit replaces 'dirname( __FILE__ )' that was introduced in 5370d02484 with __DIR__ and added DIRECTORY_SEPARATOR
Relative include paths in PHP can break whenever the server is running opcache. As such, WordPress.com deploy system refuses to include WooCommerce because of that issue.
This commit changes the relative include paths to absolute include paths.
Relates to #27269
Methods `wc_maybe_increase_stock_levels` and `wc_maybe_reduce_stock_levels` already reduce/increase stock levels when statuses are changed, so no need to do this here.
Added a new hook for validations in the add_order_item() called in
WC->Orders->Add/Edit Orders.
Allow plugins to perform validations/changes to the order before a
product is added the order.
* Add functionality to wp-admin order to check for coupon usage based on email addresses, similar to how WC_Cart handles this seperately, included unit tests.
* Only do the coupon by email usage check if order is from a guest. Fix issue with unit test.
Commit
be05eea5da (diff-133db5662c51f5686d87611121a05a3bL88)
changed how ajax events are stored and now an associative array is not used anymore for both private and non private events. Instead two different arrays are now used one for each type of event.
Commit be05eea5da (diff-133db5662c51f5686d87611121a05a3bR1420) fixed all the PHPCS violations in includes/class-wc-ajax.php, but it unintentionally changed that the logic of WC_Ajax::json_search_products(). This commit reverts the changes to the old logic while keeping the PHPCS fixes.
Before the modification mentioned above, `$_GET['term']` would be used only if `$term` was empty. After this modification, `$_GET['term']` is used whenever it is set and `$term` (the parameter passed to the method) stopped being used. This commit restores the original logic in that what is passed in the first parameter as `$term` is used by default, and `$_GET['term']` is only used if `$term` is empty.