simpleCart(js)

items
Items:
Total:

simpleCart.each( [array ,] callback )

arguments:

  • array (optional): array or object to iterate through. If it is not provided, simpleCart will iterate through the objects in the cart
  • callback: function to call with each iteration

Iterating through the simpleCart objects:

simpleCart.add({name: "Sticker",price: 1});
simpleCart.add({name: "Button",price: 1});

var items = [];

simpleCart.each(function( item , x ){
    items.push( item.name );
});

console.log( items );   // [ "Sticker" , "Button" ]

Comments

  1. Jun 28, 2012

    Maciej  said:

    Instead of
      item.name
    use
      item.get(‘name’)

  2. Jun 28, 2012

    Maciej  said:

    parameter x takes values: 0, 1, 2, ...

    you can use the third parameter of the function which takes values of IDs: SCI-1, SCI-2, ...

Commenting is not available in this channel entry.