The Shelf

You can make items be available to your users by simple using class names in your html. For any Item you want to be available to be added to the cart, you make a container with a class name of simpleCart_shelfItem. Then add classes to tags inside of that container that have the general form item_[name of field] and simpleCart will use the value or innerHTML of that tag for the cart. For example, if you wanted to sell a T-shirt with 3 different sizes, you can do this:

Awesome T-shirt

Add to Cart

Notice here that you can use a select to change options for the item when you add it to the cart. You can also use a text input to change the quantity (or any other field!). These classes will work with any tag, so feel free to use what works best for you. Finally, notice that a tag with the class item_add will have an event listener on its click. So when the contents of that tag are clicked, an item will be added to the cart with the values of each of the tags in the container with the item_something class.

Some notes:

  • You will want to always supply a quantity and price. Although the cart won’t break if you don’t, all the quantities and totals are created from it, so the cart will assign a price of $0 if there is none, and a quantity of 1 if no quantity is provided.
  • If you are planning on checking out to googleCheckout or paypal, it is a good idea to use a name field
  • If you use a link for the add to cart button, its a good idea to set the href to “javascript:;”



  1. Jun 07, 2012

    RCNeil  said:

    I noticed that PayPal automatically assigns an “Item Number” to each item if one is not supplied. 

    I’ve tried using an “item_number” class, and although SimpleCart collects this information, it does not register with PayPal as it does for Item Name and Item Price.  It places it under ‘Options’ like all of the other custom classes. 

    Is there a way to have the two properly correlate?

  2. Jun 30, 2012

    Ron  said:

    Is there a way to add different per atribute?
    For example:
    Drop down Attribute, name “Size”:
    Smal $2 off
    Medium $1 extra
    Large $3 extra.

    Or Extra Fetaure:
    Text field to enter the quantity for"Extra Chesse 1 x $1.50” and the total for the Attibute would be the quantity times the actual price of the attribute?

  3. Oct 27, 2012

    Arturo  said:

    hi… im wondering if is possible to saver for example an ID and quantity of items to some place like PHP to send it to another webpage that is mine
    for instance:
    sells.html to buy.php
    then… in buy.php remember (in and array or so)
    tha ID and quantity of a product to do a FAKE sell (this is for my school and i am wondering that… thanks)


Commenting is not available in this channel entry.