sese2000
Forum Replies Created
-
🔧 Fix for the PHP 8.2 “Unsupported operand types: string + int” error in Booster for WooCommerce PDF Invoices (TCPDF)
If you are encountering an error like this when generating PDF invoices in WooCommerce with the Booster plugin:
Fatal error: Uncaught TypeError: Unsupported operand types: string + int in /wp-content/plugins/booster-plus-for-woocommerce/includes/lib/tcpdf/tcpdf.php on line 5192…here is the fix that worked for me. 🎯 The Problem
In PHP 8.2, adding a string and an integer (or float) is no longer allowed, and will throw a fatal error.
In the TCPDF library used by Booster, there is a line like this:$y = $this->y + $this->cell_margin['T'];If
$this->yis a string (like an empty string""), this addition causes the fatal error. ✅ The Solution (Minimal Patch)Open the file:
/wp-content/plugins/booster-plus-for-woocommerce/includes/lib/tcpdf/tcpdf.phpGo to line 5192 (or search for this line):
$y = $this->y + $this->cell_margin['T'];Change it to:
$y = (float)$this->y + (float)$this->cell_margin['T'];This will force both variables to be treated as numbers, avoiding the error. 📌 Why this fix works
$this->yis sometimes initialized as an empty string in TCPDF, and adding it to a number (like$this->cell_margin['T']) is invalid in PHP 8.2.- The patch safely converts both variables to floats, ensuring the calculation works as intended.
🛡️ Important
This is a targeted fix for the specific error in TCPDF when using Booster for WooCommerce on PHP 8.2.
It is a minimal change and works reliably without needing to patch the entire TCPDF library.