Fatal error for variable products with custom function
-
Hi, I have a simple custom function for showing some addition information after the product description. You can find the code below. Now I have found that for variable products, the function below combined with your WPSSO core plugin is causing a fatal error. How to fix this?
<?php add_filter('woocommerce_short_description','tw_add_text_short_descr'); function tw_add_text_short_descr($description){ if (! is_product()) { return; } global $product; if ( $product->is_type( 'simple' )) { $description = 'hi'; } return $description; } ?>
The error is:
Fatal error: Uncaught Error: Call to a member function is_type() on string in /xxxxxx/wp-content/child-theme/functions.php:24 Stack trace: #0 /xxxxxx/wp-includes/class-wp-hook.php(310): tw_add_text_short_descr('') #1 /xxxxxx/wp-includes/plugin.php(205): WP_Hook->apply_filters('', Array) #2 /xxxxxx/wp-content/plugins/woocommerce/includes/wc-formatting-functions.php(1121): apply_filters('woocommerce_sho...', '') #3 /xxxxxx/wp-content/plugins/woocommerce/includes/class-wc-product-variable.php(398): wc_format_content('') #4 /xxxxxx/wp-content/plugins/wpsso/lib/util-woocommerce.php(231): WC_Product_Variable->get_available_variation(Object(WC_Product_Variation)) #5 /xxxxxx/wp-content/plugins/wpsso/lib/integ/ecom/wooco in /xxxxxx/wp-content/child-theme/functions.php on line 24
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Fatal error for variable products with custom function’ is closed to new replies.