If I bought that book, it would be so I had something to give to you on your birthday.
Now, as far as i know, in hypothetical sentences, you have to backshift all tenses one step to the past. So:
buy = bought
will = would
have = had
Feel free to correct me if you think i'm wrong.
Now, going by so far as my knowledge about backshifting all the tenses to the past one step goes when constructing hypothetical sentences, is the above sentence grammatically correct?