API error: "cart has no properties"

Highlighted
New Member
17 0 0
I am getting a strange javascript error when I first add an item to the cart using addItemFromForm() that says: ====================================== API Error: TypeError: $("cart") has no properties {items: [{handle: "fourth-of-july-reservation", line_price: 10500, price: 10500, title: (etc. etc. etc.)} ====================================== If I then refresh the page, lo and behold the item shows up in the cart, and the cart shows without any problems. After that, I can add items to my hearts content. However, if I refresh the page again, the problem resets. This occurs with IE6, IE7, and Firefox. Also, just navigating to another page within the shop seems to make everything OK too. Strange. Any ideas? This has to be something minor that I'm missing! I've attached an image of the error to this posting. --Balazs--
--Balazs--
0 Likes
Highlighted
Shopify Staff
Shopify Staff
2002 0 46

Looks like there is no html element on your pages with the id=”cart”

Tobias Lütke - Shopify CEO // http://twitter.com/tobi
0 Likes
Highlighted
New Member
17 0 0

OK. So, I seem to have nailed it down. I had liquid code something like this:

{% if cart is not empty %}
div cart
{% endif %}

Instead, I needed to change it to just not display the cart when it is empty instead of completely stripping out that div.

Sorry for the bother, the answer was trivial.

—Balazs—

--Balazs--
0 Likes