Solution:1
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);
}
}
}