Controlling inventory in cart

richtestanirichtestani Member
in Bugs & Feature Requests edited March 2008
How would I make sure a user cannot buy more than an items inventory?
I am selling unique items and only have a few per item available.

So how I make sure if I only have 2 available the user can buy no more than 2?
Thanks
Rich
Comments
  • brettbrett FoxyCart Team
    The solution is likely a few different pieces.

    To set a max quantity, check the wiki: http://wiki.foxycart.com/docs:parameters#standard_attributes

    That's _not_ inventory, however. That just limits the number of items per cart/user/session. What you'd want to do is use that in conjunction with the XML feed to decrease inventory in your own system once an order goes through.

    If the volume of your transactions is such that you'd need to ensure that two people don't buy the same 2 remaining items at the same time (like, they both add them to their carts prior to one of them checking out and flipping the inventory control on your end, thus disabling the "add to cart" button for other users), you'll want to roll a solution like steeeeephen did: http://www.foxycart.com/featured-site-narwhal-company.html

    What are you using to build your site? If you're on MODx there's already an inventory snippet that you could use. I think CoolCommerce for ExpressionEngine has something as well but I'm not positive.
  • I am building the store with modx - I looked at the inventory solution, but it was based on using TV's which I am not storing my data in.
    I am pulling that from my own database, which I would manage that with the XML datafeed.

    I'm not so concerned about users purchasing the same item at the same time at this point, but making sure they don't buy more than the alloted stock. It may be that I could use the max quantity - can this number be different per item?

    On a secondary note - how to I access the datafeed? I know how I would parse it, but how does my script access the XML data?
    Thanks again.
  • brettbrett FoxyCart Team
    You set up the URL to send the XML (and the keyphrase to encode it with) to in your admin.

    You could probably modify the inventory snippet pretty easily, or build your own. You can definitely set the quantity_max per product, so you'd just query your database for the inventory, set that as the quantity_max, and set the XML to subtract inventory on orders.

    Let me know if I'm not making sense, or if you need help.
Sign In or Register to comment.