Search code examples
javascriptjqueryimageshopping-cartsimplecart

Adding a thumb to simplecart js image source undefined


I'm using the simplecart js. I'm having trouble getting a image source of the product image to appear with the product info in the cart.

the image source is undefined, see demo http://jsfiddle.net/z7xW4/15/

I use the following code to create columns

<div class="simpleCart_shelfItem">

<img alt="image" src="http://placehold.it/100x100" class="item-image"/>
<a href="javascript:;" class="item_add">Add to Cart</a>

Cart

  simpleCart({
checkout: {
  type: "PayPal",
  email: "you@yours.com"
},
cartColumns: [
    
    {view:'image' , attr:'thumb', label: false},
    { attr: "price" , label: "Price", view: 'currency' } ,
    
    { attr: "quantity" , label: "Qty" } ,
    
    { attr: "total" , label: "SubTotal", view: 'currency' } ,
    { view: "remove" , text: "Remove" , label: false }
],
cartStyle: "table"
});

Solution

  • Solved by using this code

    { view: function(item, column){
          return"<img src='"+item.get('image')+"'>";
       },
      attr: 'image' },
    

    see demo http://jsfiddle.net/z7xW4/23/