items
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" ]
Jun 28, 2012
Instead of
item.name
use
item.get(‘name’)
Jun 28, 2012
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, ...