The error message “Uncaught TypeError: Unsupported operand types: string + float” typically occurs in WordPress or WooCommerce when there is a compatibility issue between your code or plugins and the PHP version you are using, particularly when using PHP 8 or higher. This error message indicates that you are trying to perform an unsupported operation, in this case, attempting to add a string and a float.

Here are some common reasons for encountering this error and steps to resolve it:

  • Plugin or Theme Compatibility: Outdated or poorly coded plugins or themes might not be compatible with the latest PHP versions. Check if any of your plugins or themes need updates to be compatible with PHP 8 or higher. You can do this by visiting the plugin or theme’s official website or repository.
  • Deprecated Functions: PHP 8 introduced many changes, including the removal of several deprecated functions and features. Review your code, plugins, or themes to ensure that you are not using any deprecated functions or features that are no longer supported.

If the error occured in Woocommerce Cart or Checkout probable fix can be:

add_filter('woocommerce_cart_get_subtotal', function( $subtotal ) {
    return (float) $subtotal;
}, PHP_INT_MAX);

add_filter('woocommerce_cart_get_subtotal_tax', function( $subtotal_tax ) {
    return (float) $subtotal_tax;
}, PHP_INT_MAX);

Keep in mind that PHP 8 introduced significant changes, so it’s important to ensure that all components of your WordPress site are up to date and compatible to avoid such errors.