Will having a mediocre undergrad GPA ruin my chance getting into a PhD program
Mediocre grades don't help, of course, but a doctoral admissions committee will look at much more than your GPA. Many things are considered, especially the things people say about you in your letters of recommendation. Your statement of purpose, which is often required, can also be a big factor. You need to show that you are both highly qualified and a good candidate for success in the program. 

So, yes, you have a chance, but the competition will also be fierce. If you want to continue in organic chemistry, or something that depends heavily on it, then you need to explain those grades, but, depending on the field you choose it might be a relatively small factor. But your record will be judged by humans, not an automaton, so many things can affect what happens.