Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8 Fatal Error #241

Open
pogla opened this issue Oct 17, 2022 · 3 comments
Open

PHP 8 Fatal Error #241

pogla opened this issue Oct 17, 2022 · 3 comments

Comments

@pogla
Copy link

pogla commented Oct 17, 2022

I'm getting a fatal error running this plugin in PHP 8. The problem seems to be in this function:
https://github.com/taxjar/taxjar-woocommerce-plugin/blob/master/includes/TaxCalculation/class-order-tax-applicator.php#L209-L215

This seems to fix the problem:

private function get_order_total() {
	$cart_total     = $this->get_cart_total_for_order();
	$tax_total      = $this->order->get_cart_tax() + (float) $this->order->get_shipping_tax();
	$fees_total     = $this->order->get_total_fees();
	$shipping_total = (float) $this->order->get_shipping_total();
	return $cart_total + $tax_total + $fees_total + $shipping_total;
}

$order->get_shipping_total and $order->get_shipping_tax both return a string or null.

Here is the error:

[17-Oct-2022 11:49:08 UTC] PHP Fatal error:  Uncaught TypeError: Unsupported operand types: float + string in /nas/content/live/site/wp-content/plugins/taxjar-simplified-taxes-for-woocommerce/includes/TaxCalculation/class-order-tax-applicator.php:214
Stack trace:
#0 /nas/content/live/site/wp-content/plugins/taxjar-simplified-taxes-for-woocommerce/includes/TaxCalculation/class-order-tax-applicator.php(175): TaxJar\Order_Tax_Applicator->get_order_total()
#1 /nas/content/live/site/wp-content/plugins/taxjar-simplified-taxes-for-woocommerce/includes/TaxCalculation/class-order-tax-applicator.php(61): TaxJar\Order_Tax_Applicator->update_totals()
#2 /nas/content/live/site/wp-content/plugins/taxjar-simplified-taxes-for-woocommerce/includes/TaxCalculation/class-tax-applicator.php(46): TaxJar\Order_Tax_Applicator->apply_new_tax()
#3 /nas/content/live/site/wp-content/plugins/taxjar-simplified-taxes-for-woocommerce/includes/TaxCalculation/class-tax-calculator.php(271): TaxJar\Tax_Applicator->apply_tax(Object(TaxJar\Tax_Details))
#4 /nas/content/live/site/wp-content/plugins/taxjar-simplified-taxes-for-woocommerce/includes/TaxCalculation/class-tax-calculator.php(188): TaxJar\Tax_Calculator->apply_tax()
#5 /nas/content/live/site/wp-content/plugins/taxjar-simplified-taxes-for-woocommerce/includes/class-taxjar-tax-calculation.php(60): TaxJar\Tax_Calculator->maybe_calculate_and_apply_tax()
#6 /nas/content/live/site/wp-content/mu-plugins/site/includes/Admin/BulkOrders/CreateSubscriptions.php(228): TaxJar_Tax_Calculation->maybe_calculate_order_taxes(true, Object(WC_Subscription))
#7 /nas/content/live/site/wp-includes/class-wp-hook.php(307): Site\Admin\BulkOrders\CreateSubscriptions->create_subscription('')
#8 /nas/content/live/site/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters('', Array)
#9 /nas/content/live/site/wp-includes/plugin.php(476): WP_Hook->do_action(Array)
#10 /nas/content/live/site/wp-admin/admin-ajax.php(187): do_action('wp_ajax_create_...')
#11 {main}

Next TypeError: TaxJar\Order_Tax_Calculation_Result_Data_Store::update(): Argument #1 ($calculation_result) must be of type TaxJar\Tax_Calculation_Result, null given, called in /nas/content/live/site/wp-content/plugins/taxjar-simplified-taxes-for-woocommerce/includes/TaxCalculation/class-tax-calculator.php on line 193 and defined in /nas/content/live/site/wp-content/plugins/taxjar-simplified-taxes-for-woocommerce/includes/TaxCalculation/class-order-tax-calculation-result-data-store.php:42
Stack trace:
#0 /nas/content/live/site/wp-content/plugins/taxjar-simplified-taxes-for-woocommerce/includes/TaxCalculation/class-tax-calculator.php(193): TaxJar\Order_Tax_Calculation_Result_Data_Store->update(NULL)
#1 /nas/content/live/site/wp-content/plugins/taxjar-simplified-taxes-for-woocommerce/includes/class-taxjar-tax-calculation.php(60): TaxJar\Tax_Calculator->maybe_calculate_and_apply_tax()
#2 /nas/content/live/site/wp-content/mu-plugins/site/includes/Admin/BulkOrders/CreateSubscriptions.php(228): TaxJar_Tax_Calculation->maybe_calculate_order_taxes(true, Object(WC_Subscription))
#3 /nas/content/live/site/wp-includes/class-wp-hook.php(307): Site\Admin\BulkOrders\CreateSubscriptions->create_subscription('')
#4 /nas/content/live/site/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters('', Array)
#5 /nas/content/live/site/wp-includes/plugin.php(476): WP_Hook->do_action(Array)
#6 /nas/content/live/site/wp-admin/admin-ajax.php(187): do_action('wp_ajax_create_...')
#7 {main}
  thrown in /nas/content/live/site/wp-content/plugins/taxjar-simplified-taxes-for-woocommerce/includes/TaxCalculation/class-order-tax-calculation-result-data-store.php on line 42
@slewisma
Copy link

Same issue happening on one of my client's sites. Now that PHP 7.x is fully deprecated, this is a high priority issue!

@pogla
Copy link
Author

pogla commented Jan 27, 2023

@dallendalton Is this repo still active?

@pogla
Copy link
Author

pogla commented Jan 27, 2023

@slewisma Did you try to update WooCommerce to the latest version? I did and it looks like this issue is gone.

I think this commit solved the issue of the function returning an empty string:
woocommerce/woocommerce@ad30c61#diff-8261b720d84fcccf0d768b1a4114051cd1d52a4661b320a28b5144abefaf41c8R668

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants