usually, when the cart clears on checkout, it happens because of switching the domain.
thew cart items are stored in a session. The session is tied to the domain and a cookie.
if a user comes to your site at:
this will start a different session than coming to the site at:
a good strategy, and it looks like this what your doing now, is to redirect all traffic to the secure url: