Site logo

Archived topic

Critical Error due to PHP version change

5 replies · Started by Luke on March 15, 2023

Viewing posts 1–6 of 6

Hi There,

We upgraded our PHP level and now the Cart and Checkout are broken on the site. Although we need to keep the PHP Level to the latest one
Our server guys have told us to contact you guys in regard to the issue

Can you help us resolve this issue

We can provide the error logs if needed

Thanks

Tom

Hi Tom,

now the Cart and Checkout are broken on the site.

What do you mean they are broken? Like the functionality of cart and checkout?
If so this is very unlikely a theme issue as the functionality of cart and checkout is completely handled by WooCommerce itself - did your server guys mention why they think it's an issue with the theme?

Can you please activate a Twenty series WP theme to see if the issue exists there as well?

We have not had any other reports on this so further debugging will likely be needed.

Let me know :)

Hi Leo,

Thanks for your Response,

So basically when you add a product to the cart the cart gets a critical error.

We are currently using the most up to date GeneratePress Theme

Here are the Logs that they mentioned to then talk to you guys

[15-Mar-2023 14:55:27 UTC] PHP Fatal error: Uncaught TypeError: Unsupported operand types: string * int in /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-content/themes/generatepress-child/functions.php:218
Stack trace:
#0 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-includes/class-wp-hook.php(308): calculateWeight()
#1 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()
#2 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-includes/plugin.php(517): WP_Hook->do_action()
#3 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-content/themes/generatepress-child/woocommerce/cart/cart.php(20): do_action()
#4 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-content/plugins/woocommerce/includes/wc-core-functions.php(345): include('...')
#5 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-content/plugins/woocommerce/includes/shortcodes/class-wc-shortcode-cart.php(99): wc_get_template()
#6 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-content/plugins/woocommerce/includes/class-wc-shortcodes.php(72): WC_Shortcode_Cart::output()
#7 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-content/plugins/woocommerce/includes/class-wc-shortcodes.php(85): WC_Shortcodes::shortcode_wrapper()
#8 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-includes/shortcodes.php(355): WC_Shortcodes::cart()
#9 [internal function]: do_shortcode_tag()
#10 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-includes/shortcodes.php(227): preg_replace_callback()
#11 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-content/plugins/js_composer/include/helpers/helpers.php(246): do_shortcode()
#12 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-content/plugins/js_composer/include/templates/shortcodes/vc_column.php(94): wpb_js_remove_wpautop()
#13 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-content/plugins/js_composer/include/classes/shortcodes/core/class-wpbakeryshortcode.php(451): require('...')
#14 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-content/plugins/js_composer/include/classes/shortcodes/core/class-wpbakeryshortcode.php(424): WPBakeryShortCode->loadTemplate()
#15 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-content/plugins/js_composer/include/classes/shortcodes/core/class-wpbakeryshortcode.php(546): WPBakeryShortCode->content()
#16 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-content/plugins/js_composer/include/helpers/helpers.php(1323): WPBakeryShortCode->output()
#17 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-includes/shortcodes.php(355): vc_do_shortcode()
#18 [internal function]: do_shortcode_tag()
#19 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-includes/shortcodes.php(227): preg_replace_callback()
#20 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-content/plugins/js_composer/include/helpers/helpers.php(246): do_shortcode()
#21 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-content/plugins/js_composer/include/templates/shortcodes/vc_row.php(156): wpb_js_remove_wpautop()
#22 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-content/plugins/js_composer/include/classes/shortcodes/core/class-wpbakeryshortcode.php(451): require('...')
#23 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-content/plugins/js_composer/include/classes/shortcodes/vc-row.php(40): WPBakeryShortCode->loadTemplate()
#24 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-content/plugins/js_composer/include/classes/shortcodes/core/class-wpbakeryshortcode.php(546): WPBakeryShortCode_Vc_Row->content()
#25 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-content/plugins/js_composer/include/helpers/helpers.php(1323): WPBakeryShortCode->output()
#26 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-includes/shortcodes.php(355): vc_do_shortcode()
#27 [internal function]: do_shortcode_tag()
#28 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-includes/shortcodes.php(227): preg_replace_callback()
#29 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-includes/class-wp-hook.php(308): do_shortcode()
#30 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-includes/plugin.php(205): WP_Hook->apply_filters()
#31 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-includes/post-template.php(255): apply_filters()
#32 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-content/themes/generatepress/content-page.php(73): the_content()
#33 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-includes/template.php(785): require('...')
#34 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-includes/template.php(718): load_template()
#35 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-includes/general-template.php(204): locate_template()
#36 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-content/themes/generatepress/inc/theme-functions.php(568): get_template_part()
#37 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-content/themes/generatepress/page.php(34): generate_do_template_part()
#38 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-includes/template-loader.php(106): include('...')
#39 /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-blog-header.php(19): require_once('...')
#40 /home/nginx/domains/valentteie.bigscoots-staging.com/public/index.php(17): require('...')
#41 {main}
thrown in /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-content/themes/generatepress-child/functions.php on line 218

I Hope that helps understand?

Thanks

Tom

Hi there,

if we look at this part of the stack trace:

[15-Mar-2023 14:55:27 UTC] PHP Fatal error: Uncaught TypeError: Unsupported operand types: string * int in /home/nginx/domains/valentteie.bigscoots-staging.com/public/wp-content/themes/generatepress-child/functions.php:218

it points to Line 218 of the functions.php in the generatepress-child aka your Child Theme.

What function / snippet do you have there ?

Hi David,

Thanks for getting back to me

Here is the section that includes line 218

function calculateWeight(){
global $woocommerce;
    $items = $woocommerce->cart->get_cart();
	$totalWeight  =0;
        foreach($items as $item => $values) { 
           
	
		//	$meta =  get_post_meta($values['product_id']);
		  $weight = get_post_meta($values['product_id'] , '_weight', true);
			$quantity =$values['quantity']; 
			$totalWeight += $weight*$quantity;     (This is line 218)
		
        } 
	if($totalWeight >= 1.35){
			//	echo "<div class='wrap_1'><i class='fas fa-info-circle'></i><h2 id='dis_cn'><strong>You Qualify:</strong><a href='".  wc_get_checkout_url() ."'> for 50% off next day delivery</a></h2></div>";
			}?>
	<script>
	totalWeight = <?php echo $totalWeight;?>
</script>
	<?php
}

Thanks for your assistance so far

Thanks

Tom

OK so:

$totalWeight += $weight*$quantity;

relates to this:

PHP Fatal error: Uncaught TypeError: Unsupported operand types: string * int

which means the $weight = get_post_meta($values['product_id'] , '_weight', true); is returning a string and it needs to be a numeric value.

What value are you saving in the product weight field ?

This archived topic is closed to new replies.