If you don't want to manually edit cart.liquid, you could write some javascript that looks for the presence of the cart object within the HTML and then insert a new hidden element within the form.
Something along the lines of...
(function(){
var cart = document.getElementById("cartform");
if ((cart !== null) ...
})();