The Foxy forums are on the move!

We're in the process of moving our forums over to a new system, and so these forums are now read-only.
If you have a question about your store in the meantime, please don't hesitate to reach out to us via email.

preventing adding an item after inventory is 0(in foxee)

allisonaallisona Member
in Bugs & Feature Requests edited June 2009
Hey guys so i'm asking this on the foxee forums also but i should probably ask here too.

I have an item in Foxee that has a value of Xtra-Small which is set to 0 at this moment.

In foxycart however, i'm still able to add that item to my cart and at least proceed with inputting my address n what not.

Would it actually go through and process the transaction even though there is zero inventory in my Foxee module?

And how could i prevent them from even adding the Xtra Small to the cart (if its at 0) in the first place?

here's the link to my item. the xtra small value is still set at 0 in foxee at this point.
http://www.dressforthenines.com/maternity-clothes.php/shop/itemtest/crocet-dress-by-maternal-america-black

thanks for your help=)
Comments
  • brettbrett FoxyCart Team
    Hi Allisona.
    Will FoxyCart accept an order even if there is 0 inventory? Yes, unless you do some magic (described below). The way to handle this would be to prevent the add to cart in the first place, which is certainly possible, but probably more a FoxEE issue (since that's where the code would live to remove the add to cart option).

    As far as how you could make FoxyCart _not_ accept an order if inventory was out: You could have some fun with our new Single Sign On (SSO), which basically allows your to check the cart prior to allowing the user through to checkout. It'd involve some more advanced coding (ability to pull JSON via PHP, parse it, interact with the EE/inventory database, and proceed accordingly), but it's definitely possible.

    FoxEE 110 will have SSO integration, but I'm not sure they'll be doing that. My hunch would be no, since very very few merchants are selling at such a pace that it'd be an issue. If a merchant is selling merchandise so quickly that in the span of a couple of minutes they could oversell themselves then that's "a good problem to have" (as some people say), in that you're selling a lot of stuff! So if that's the issue you could probably get somebody to fix this up for you in a few hours of work (if you couldn't do it yourself).

    If you _really_ wanted to get advanced (kind of like Ticketmaster does) you could actually "lock" inventory when it's added to the cart, so that until that customer checks out (or their "lock" expires), other customers couldn't even add the product to the cart. But again, that's probably not a problem most people are having, so it's not something I'd expect to see in an off-the-shelf solution.

    That's my thought, at least. We've had at least one or two users that have rolled this type of inventory control/locking themselves (way before v051's SSO, actually), so there are a few ways to tackle it, but SSO would make it the most bulletproof.
  • Will FoxyCart accept an order even if there is 0 inventory? Yes, unless you do some magic (described below). The way to handle this would be to prevent the add to cart in the first place, which is certainly possible, but probably more a FoxEE issue (since that's where the code would live to remove the add to cart option).
    FoxEE has addressed items without an inventory not appearing; therefore not getting added to the cart. However, I don't know how to limit quantities once an item is in the cart. If I have the last product on the shelf, I shouldn't be able to update my cart to a quantity more than what's available correct? And when we're at the cart view it seems like it's in your hands as we're on your domain ready to being the secure checkout so I don't know how to do a last minute inventory check. Any insight is appreciated.
  • brettbrett FoxyCart Team
    Yes, it's definitely a good question. There are a few ways to tackle this, but it starts getting kind of interesting depending on what you need. (And it's not just interesting because FoxyCart doesn't track inventory on your end. Very few cart systems actually handle situations like this perfectly.)

    So, first we have the question of limiting people modifying their quantities beyond available inventory. The easiest way to do this would be to set a quantity_max on the initial cart add, so if you only have 4 left, set the max quantity to 4 and FoxyCart won't allow more than 4 to be in the cart.

    Alternately, you could fire off a JSONP request to your own inventory service on the cart pageload that could verify inventory and prevent checkout if quantities exceed inventory.

    The more robust solution, however, would be to do the max quantity but also tie in a pre-checkout cart validation using SSO:
    http://wiki.foxycart.com/docs:single_sign_on
    So when the user attempts to checkout, you grab their cart (as JSON) and validate it. Then if it's ok you can pass them on to the checkout.

    All that said, the max quantity will likely suffice for 99% of users.

    The next issue, however, is: What if one person adds an qty 4 of an item (with inventory=4) to their cart, then prior to checking out another user adds a few of the same item to the cart? Now they both have carts with the same items. The SSO validation would help, but wouldn't prevent the situation where both customers make it to the checkout prior to either actually completing a checkout.

    Honestly, I'd suggest not worrying about that. If it happens it'd likely be easier to just refund the second customer's order. Things like that happen, even with large retailers.

    There's one exception, however, that has a super cool solution:
    If you're doing high-volume limited-availability sales (like TicketMaster does), you can do some fun stuff with the SSO, since it allows you to limit session times. You could set the checkout session to only be valid for 3 minutes or something, display a countdown like TicketMaster does, and lock the quantity of products that the customer has in their cart while their session is valid. I have a bit more notes on it if this applies to you, but again, setting a max quantity is probably going to do just fine for 99% of merchants.

    That's my 2¢, anyway. Helpful?
  • lukeluke FoxyCart Team
    Huh. That's funny, I just ordered some Nashville Preditors tickets from TicketMaster today and was noting their various countdowns. They have them through the entire checkout process. It does a good job of creating urgency for the sale, that's for sure.
  • brettbrett FoxyCart Team
    Yeah. And the cool thing is that SSO totally makes that possible ;)

    We didn't build it to do that, but it'd work. That's the kind of flexibility I like FoxyCart for.
  • Hi guys! I'm trying to do a pre-checkout cart validation using SSO as brett suggested, but I don't seem to figure out how to get the cart content (from foxycart) to be able to validate it against my system (db). I'm in the step where foxycart has called my "Shared Authentication URL" and I'm supposed to validate the cart and reply back with the

    $redirect_complete = 'https://yourdomain.foxycart.tld/checkout?fc_auth_token=' . $auth_token . '&fcsid=' . $fcsid . '&fc_customer_id=' . $customer_id . '×tamp=' . $timestamp . '&customer_name' . $customer_name;
    header('Location: ' . $redirect_complete);

    header.
    I have the fcsid that you send me, but I'm not receiving the cart with the call, nor seem to find a function in the API to let me retrieve a cart based on its fcsid.
    Thank you very much for your help!!
    Regards
    Withers
  • brettbrett FoxyCart Team
    I think what you want is this:
    http://wiki.foxycart.com/docs:jsonp
    Actually, probably just this:
    http://wiki.foxycart.com/docs:json

    You use &output=json&fcsid=BLAHBLAHBLAH and it'll give you back JSON. You can then read that into PHP (assuming you're on 5.2.x or something) and handle it just like an object/array.

    Is that what you're after?
  • Hi Brett,

    Could I get your notes on the SSO and ticketmaster-style timer? I need to do some inventory locking for a client where foxyshop inventory decrements while a product is in a customer's cart. The cart will have a 20 minute timer on it, after which time the inventory will unlock and the session will time out.

    It looks like all of the related forum threads are a couple of years old now. Is there any new documentation on how best to approach this? Will be my first foray into SSO.

    Thanks!

    -Jacob
  • fc_adamfc_adam FoxyCart Team
    @jacobdubail,

    I've asked Brett to chime in with the notes he mentioned - hopefully he still has them, it's been a while :)

    That said though, if you're working with FoxyShop, I'd highly recommend reaching out to @sparkweb too - I believe he has some stuff related to inventory locking that he might be able to share with you as well.
  • brettbrett FoxyCart Team
    I do have notes on this, which I shared with @sparkweb when he added this functionality to FoxyShop. Since you're using WP + FoxyShop already, I'd say just hit up David about that :)

    If you need them though, just let me know and I'll share the old notes.
  • sparkwebsparkweb Member, Integration Developer, FoxyShop, Order Desk
    @jacobdubail I'll send you some code via email.
  • Thanks guys!

    -J
Sign In or Register to comment.