<p>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.</p>

<p>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.</p>

CC BY-SA 3.0
2016-11-05T05:35:57.133Z
2016-11-05T05:35:57.133Z
Jeremy Daalder
<p>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 <code>response.cart</code>)</p>

<p>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 <code>purchasable</code> key in the cart object, just a <code>purchasableId</code>. I've looked in the <code>snapshot</code> object within <code>lineItems</code>, and in the <code>product</code> object within that <code>snapshot</code> object. There doesn't seem to be any asset field (or any field) attached to this information at all.</p>

<p>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.</p>

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

<plugin-craftcommerce><ajax><ecommerce>
Displaying assets from Craft's cart AJAX response
# Displaying assets from Craft's cart AJAX response

(Asked by: username_0 on 2016-11-04)

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.

**Tags:** plugin-craftcommerce, ajax, ecommerce

---

## 1 answers

### Answer by username_1 on 2016-11-05. Score: 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.


---

