Shopping Cart Application with good API

Hi , I am looking for an ecommerce shopping cart system which would allow me to do these 2 basic things:

  1. Call a function, that would add a product (using the product ID as a parameter) to the shopping cart of the current user.
  2. Call a function, giving the product ID as a paramater, to know whether this product currently exists in the shopping cart (and how many instances of it).

Im sure such a thing is out there, I’m trying to search … but any of you used (or heard) or something like that?

I appreicate your help!