Some times, this error gonna eat your brain for a long time. I recently got an error on my OpenCart website that, My Add to Cart function is not working on Home Pages that the website loads first time. Once I go inside to a product then I come back to home page, yeah, Add to Cart Function is working. First time, I thought it would be JS issue but no, I wasted much time on that assumption.
The real villain is your Domain Name. In my case, http://mywebsite.com does not work with the Add to Cart Function on homage on Initial website loading. But it works with http://www.website.com. So I set my server redirection such as any kind of URL request should redirect to http://www.mywebsite.com