• I am getting this error when I click on a specific car from a search:

    Fatal error: Cannot redeclare car_demon_display_similar_cars() (previously declared in /webroot/l/o/local015/demo2.carsalesspecialist.com/www/wp-content/plugins/car-demon/includes/car-demon-template.php:284) in /webroot/l/o/local015/demo2.carsalesspecialist.com/www/wp-content/themes/car-demon-mobile/single-cars_for_sale.php on line 434"
    
    I could not even find the car-demon-template.php.  And line 434 of the single-cars_for_sale.php is the closing bracket for this function:
    
    "function car_demon_display_similar_cars($body_style, $current_id) {
    	global $wpdb;
    	$car_demon_mobile_themepath = str_replace(str_replace('\\', '/', ABSPATH), get_option('siteurl').'/', str_replace('\\', '/', dirname(__FILE__))).'/';
    	$car_demon_mobile_themepath = str_replace('widgets','',$car_demon_mobile_themepath);
    	$car_demon_themepath = str_replace('car-demon-mobile', 'car-demon-theme', $car_demon_mobile_themepath);
    	$my_tag_id = get_term_by('slug', $body_style, 'vehicle_body_style');
    	$my_search .= " AND $wpdb->term_taxonomy.taxonomy = 'vehicle_body_style' AND $wpdb->term_taxonomy.term_id IN(".$my_tag_id->term_id.")";
    	$str_sql = "SELECT wposts.ID
    		FROM $wpdb->posts wposts
    			LEFT JOIN $wpdb->postmeta wpostmeta ON wposts.ID = wpostmeta.post_id
    			LEFT JOIN $wpdb->term_relationships ON (wposts.ID = $wpdb->term_relationships.object_id)
    			LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
    		WHERE wposts.post_type='cars_for_sale'
    			AND wpostmeta.meta_key = 'sold'
    			AND wpostmeta.meta_value = 'no'".$my_search.'
    			ORDER BY ID LIMIT 4';
    	$the_lists = $wpdb->get_results($str_sql);
    	$car = '';
    	$cnt = 0;
    	if (!empty($the_lists)) {
    		$car .= '<h3>'.__('Other Great Deals').'</h3>';
    		$car .= '<div style="width:650px;height:225px;margin-top:10px;">';
    		foreach ($the_lists as $the_list) {
    			$post_id = $the_list->ID;
    			if ($post_id != $current_id) {
    				$cnt = $cnt + 1;
    				if ($cnt < 4) {
    					$show_it = 1;
    					$stock_value = get_post_meta($post_id, "_stock_value", true);
    					$vehicle_year = strip_tags(get_the_term_list( $post_id, 'vehicle_year', '','', '', '' ));
    					$vehicle_make = strip_tags(get_the_term_list( $post_id, 'vehicle_make', '','', '', '' ));
    					$vehicle_model = strip_tags(get_the_term_list( $post_id, 'vehicle_model', '','', '', '' ));
    					$vehicle_condition = strip_tags(get_the_term_list( $post_id, 'vehicle_condition', '','', '', '' ));
    					$title = $vehicle_year . ' ' . $vehicle_make . ' '. $vehicle_model;
    					$title = substr($title, 0, 24);
    					$mileage_value = get_post_meta($post_id, "_mileage_value", true);
    					$detail_output = '<span class="random_title">'.$title.'</span>';
    					$detail_output .= '<span class="random_text">';
    						$detail_output .= 'Condition: '.$vehicle_condition.'';
    					$detail_output .= '</span>';
    					$detail_output .= '<span class="random_text">';
    						$detail_output .= 'Mileage: '.$mileage_value.'';
    					$detail_output .= '</span>';
    					$detail_output .= '<span class="random_text">';
    						$detail_output .= 'Stock#: '.$stock_value;
    					$detail_output .= '</span>';
    					$link = get_permalink($post_id);
    					$img_output = "<img onclick='window.location=\"".$link."\";' title='Click for price on this ".$title."' onerror='ImgError(this, \"no_photo.gif\");' class='random_widget_image' width='180px' height='135px' src='";
    					$img_output .= wp_get_attachment_thumb_url( get_post_thumbnail_id( $post_id ) );
    					$img_output .= "' />";
    					$ribbon = 'ribbon-just-added';
    					$ribbon = 'ribbon-great-deal';
    					if ($vehicle_condition == 'New') {
    						$ribbon = 'ribbon-new';
    					}
    					else {
    						if ($mileage_value < 60000) { $ribbon = 'ribbon-low-miles';	}
    						$tmp_price = get_post_meta($post_id, "_price_value", true);
    						if ($tmp_price < 12000) { $ribbon = 'ribbon-low-price';	}
    					}
    					$car .= '
    						<div class="random_mobile" style="float:left;width:105px;height:185px;">
    							<div class="random_img">
    								<img onclick="window.location=\''.$link.'\';" style="margin-left:15px;" src="'. $car_demon_themepath .'images/'.$ribbon.'.png" width="146" height="146" alt="New Ribbon" id="ribbon">
    								'.$img_output.'
    							</div>
    							<div class="random_description">
    								'.$detail_output.'
    							</div>
    						</div>';
    				}
    			}
    		}
    		$car .= '</div>';
    	}
    	if ($show_it != 1) {
    		$car = '';
    	}
    	return $car;
    }


    [Please use backticks, NOT quotation marks, for posting code]

    Does anyone see where the error might be. I am not much of a coder myself so I cannot tell.

    Tnx,
    Lydia

    https://www.ads-software.com/plugins/car-demon/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter lydwolf1

    (@lydwolf1)

    Hi Jay, Is there any chance you have had a chance to look at this Fetal Error?

    Plugin Author theverylastperson

    (@theverylastperson)

    Hey Lydia,

    You can change the function name in that file to something different.

    So take;
    "function car_demon_display_similar_cars($body_style, $current_id) {
    and make it;
    "function car_demon_display_similar_cars2($body_style, $current_id) {

    I’ll try to send you a new version in the near future.

    Thread Starter lydwolf1

    (@lydwolf1)

    Hi Jay,

    That did the trick. Thank you very much. With that I have a full demo site working – desktop and mobile.

    Much thanks and appreciation.

    Regards,
    Lydia and Dave

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Fatal Error on Mobile Car Details Page’ is closed to new replies.