OpenCart ‘Shipping Method Required’ bug

I’ve been working a lot in OpenCart again and running into some frustrating errors while I’m at it. I’m using the latest version 3.0.2 just in case you were wondering 😉

One of them was that quite often I’d be getting a ‘Shipping method required!’ error when trying to checkout even after I’d picked a shipping method. Sometimes the cart would just clear and I’d get that error, sometimes it’d remember the session and then the error would come up.

This bug is a real pain and stops customers from completing their purchase so I tried a few different methods to stop it from happening and the fix below seems to be working for me.

Unfortunately, this fix means changing OpenCart’s own code so hopefully they’ll fix this in future releases so I won’t have to update it every time OpenCart updates.

Open up system/framework.php file and find the following line (around row 74):

74
$response->addHeader('Content-Type: text/html; charset=utf-8');

After it add the following lines:

75
76
$response->addHeader('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
$response->addHeader('Pragma: no-cache');

This should stop the browser from caching ajax requests which are causing problems on the cart. I will have to keep an eye on it and make sure it keeps working.