Fatal error: Uncaught Error: Call to undefined function is_product()
First check if woocommerce activated then call function:
add_action('wp_head', 'wc_variable_simple_conditions');function wc_variable_simple_conditions(){ if (!class_exists('WooCommerce')) return; // add this line if (is_product()) { global $post; $post_id = $post->ID; $product = wc_get_product($post_id); $type = $product->get_type(); if ($type == 'variable') { add_filter('woocommerce_available_variation', 'load_variation_settings_fields'); } elseif ($type == 'simple') { add_action('woocommerce_single_product_summary', 'custom_data_above_add_to_cart_button', 41); } }}
Make sure that you include
source of this function includes/wc-conditional-functions.php
Try replacing your function with this:
function wc_variable_simple_conditions(){ if ( !function_exists( 'is_product' ) ) { return; } if (is_product()) { global $post; $post_id = $post->ID; $product = wc_get_product($post_id); $type = $product->get_type(); if ($type == 'variable') { add_filter('woocommerce_available_variation', 'load_variation_settings_fields'); } elseif ($type == 'simple') { add_action('woocommerce_single_product_summary', 'custom_data_above_add_to_cart_button', 41); } }}