Missing operand type conversion on PHP 8.3
-
I had to fix two errors on a site with PHP 8.3 where a plugin that added a shipping method was causing Flexible shipping to go into a fatal error. Although the error is caused by the two plugins in conjunction, it can be fixed easily by casting the values into the float type. I hope the developers can implement this to fix any other shipping method plugins returning values in the wrong type.
PHP Fatal error: Uncaught TypeError: Unsupported operand types: string + float in /wp-content/plugins/flexible-shipping/src/WPDesk/FS/TableRate/Rule/CostsCalculator.php:180
PHP Fatal error: Uncaught TypeError: Unsupported operand types: float – string in /wp-content/plugins/flexible-shipping/src/WPDesk/FS/TableRate/ShippingMethodsIntegration/ShippingRate.php:86
Full stack trace (first error):
Stack trace: 0 /wp-content/plugins/flexible-shipping/src/WPDesk/FS/TableRate/Rule/CostsCalculator.php(212): WPDesk\FS\TableRate\Rule\CostsCalculator->sum_calculation(”, 0.0) 1 /wp-content/plugins/flexible-shipping/src/WPDesk/FS/TableRate/Rule/CostsCalculator.php(135): WPDesk\FS\TableRate\Rule\CostsCalculator->calculate_cost(”) 2 /wp-content/plugins/flexible-shipping/src/WPDesk/FS/TableRate/ShippingMethodsIntegration/ShippingRate.php(85): WPDesk\FS\TableRate\Rule\CostsCalculator->process_rules(”) 3 /wp-includes/class-wp-hook.php(324): WPDesk\FS\TableRate\ShippingMethodsIntegration\ShippingRate->add_table_rate_shipping_rate(Array, Object(MakeCommerce\Shipping\Method\ParcelMachine\DPD)) 4 /wp-includes/plugin.php(205): WP_Hook->apply_filters(Array, Array) 5 /wp-content/plugins/woocommerce/includes/abstracts/abstract-wc-shipping-method.php(290): apply_filters(‘woocommerce_shi…’, Array, Object(MakeCommerce\Shipping\Method\ParcelMachine\DPD)) 6 /wp-content/plugins/makecommerce/shipping/method/method.php(428): WC_Shipping_Method->add_rate(Array) 7 /wp-content/plugins/woocommerce/includes/abstracts/abstract-wc-shipping-method.php(257): MakeCommerce\Shipping\Method->calculate_shipping(Array) 8 /wp-content/plugins/woocommerce/includes/class-wc-shipping.php(348): WC_Shipping_Method->get_rates_for_package(Array) 9 /wp-content/plugins/woocommerce/includes/class-wc-shipping.php(260): WC_Shipping->calculate_shipping_for_package(Array, 0) 10 /wp-content/plugins/woocommerce/includes/class-wc-cart.php(1431): WC_Shipping->calculate_shipping(Array) 11 /wp-content/plugins/woocommerce/includes/class-wc-cart-totals.php(346): WC_Cart->calculate_shipping() 12 /wp-content/plugins/woocommerce/includes/class-wc-cart-totals.php(857): WC_Cart_Totals->get_shipping_from_cart() 13 /wp-content/plugins/woocommerce/includes/class-wc-cart-totals.php(151): WC_Cart_Totals->calculate_shipping_totals() 14 /wp-content/plugins/woocommerce/includes/class-wc-cart-totals.php(141): WC_Cart_Totals->calculate() 15 /wp-content/plugins/woocommerce/includes/class-wc-cart.php(1409): WC_Cart_Totals->__construct(Object(WC_Cart)) 16 /wp-content/plugins/woocommerce/includes/shortcodes/class-wc-shortcode-cart.php(96): WC_Cart->calculate_totals() 17 /wp-content/plugins/woocommerce/includes/class-wc-shortcodes.php(72): WC_Shortcode_Cart::output(Array) 18 /wp-content/plugins/woocommerce/includes/class-wc-shortcodes.php(85): WC_Shortcodes::shortcode_wrapper(Array) 19 /wp-includes/shortcodes.php(434): WC_Shortcodes::cart(Array, ”, ‘woocommerce_car…’) 20 [internal function]: do_shortcode_tag(Array) 21 /wp-includes/shortcodes.php(273): preg_replace_callback(‘/\[(\[?)(woocom…’, ‘do_shortcode_ta…’, ‘[woocommerce_ca…’) 22 /wp-includes/class-wp-hook.php(324): do_shortcode(‘[woocommerce_ca…’) 23 /wp-includes/plugin.php(205): WP_Hook->apply_filters(‘[woocommerce_ca…’, Array) 24 /wp-includes/post-template.php(256): apply_filters(‘the_content’, ‘[woocommerce_ca…’) 25 /wp-content/themes/nordfix/loops/content.php(12): the_content() 26 /wp-includes/template.php(812): require(‘/data01/virt393…’) 27 /wp-includes/template.php(745): load_template(‘/data01/virt393…’, false, Array) 28 /wp-includes/general-template.php(206): locate_template(Array, true, false, Array) 29 /wp-content/themes/nordfix/index.php(27): get_template_part(‘loops/content’, ”) 30 /wp-includes/template-loader.php(106): include(‘/data01/virt393…’) 31 /wp-blog-header.php(19): require_once(‘/data01/virt393…’) 32 /index.php(17): require(‘/data01/virt393…’) 33 {main}
thrown in /wp-content/plugins/flexible-shipping/src/WPDesk/FS/TableRate/Rule/CostsCalculator.php on line 180
- You must be logged in to reply to this topic.