How to fix WooCommerce PHP Fatal error:  Uncaught TypeError: Unsupported operand types: string – int

If you’re getting the following error:

PHP  Fatal error:  Uncaught TypeError: Unsupported operand types: string - int in ../wp-content/plugins/woocommerce/src/Internal/Admin/WCPayPromotion/Init.php:88

This error can cause your WordPress admin not functioning properly. For example if you go to WordPress block editor (Gutenberg), it will not save your changes. Etc.

Issue is with poor WooCommerce compatibility with PHP 8. Fortunately, there’s a fairly easy fix. Just do the following few steps to fix the issue:

  1. Comment out code on line number 88 in file wp-content/plugins/woocommerce/src/Internal/Admin/WCPayPromotion/Init.php
  2. It will like as follows: # $ordering[ $id ] = $is_empty ? 0 : ( min( $ordering ) – 1 );
  3. Go to your WordPress admin and go to WooCommerce – Settings – Payments
  4. Reorder payment methods
  5. Congratulations, you have fixed the fatal error for good, you can now also update the WooCommerce to the newer version if there’s any available.
  6. You can go back to the file wp-content/plugins/woocommerce/src/Internal/Admin/WCPayPromotion/Init.php and now you can uncomment the like 99 or just leave it as it is…

I’m sure this tutorial helped you resolve your WooCommerce issues. Once you’re here, feel free to try our Citadela theme for free.

Download Citadela WordPress Theme & Plugins

Get started now with a risk-free trial. No credit card required.