So, I'm currently building out an eCommerce site for a client. I'm adding products to the cart via AJAX. I'm then sliding out a 'Cart' view panel with the current cart contents, which is being updated with Craft's JSON response for the cart. (Via response.cart)

My problem is this: I need to display the thumbnail image of a product, and there doesn't seem to be anywhere I can get the asset field (or any fields) associated with the product. There is no purchasable key in the cart object, just a purchasableId. I've looked in the snapshot object within lineItems, and in the product object within that snapshot object. There doesn't seem to be any asset field (or any field) attached to this information at all.

I know I can make an additional request to fetch that information, but I'd like to avoid that if at all possible; I'm hoping it's just buried somewhere in the response.

Any help is greatly appreciated! Let me know if I need to clarify something.

1 Answer 1


The cart response definitely does not include direct access to fields on the product. You will need to make an extra request for the information...of course you'd need to make an extra request for the image itself anyway.

One easy way of implement what you want is to simply update your cart view by ajax instead loading a template into it (rather than targeting values and using the response.cart object). In that template you would just get the cart as normal, and therefore have access to all the product fields via that as you loop through the lineitems.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.