You would not have got the flu if you ate more fruit
You would not have got the flu if you had eaten more fruit
What is the difference between these two sentences?
Your second sentence is a correct third conditional form as these forms are taught to English language learners.
Your first sentence has a difference in nuance that is not necessarily grammatically incorrect but doesn't conform to how the forms are taught. While the result (having gotten the flu) is in the past and can't be changed, there's an implication that you could still change your habits and start eating more fruit, and that if you do, you could possibly avoid repeating the result and getting the flu again.
This is a matter of verb tense. The first sentence is constructed using simple past form, while the second one is using past participle. This site has some good usage cases to understand the difference between these two. https://www.ecenglish.com/learnenglish/lessons/past-simple-or-past-participle