I'm implementing a store now where adding to a cart means reserving an
item for some time (2 hours). I am not worried about someone adding
everything to the cart to block other people for a few hours. Even if
some jerk does do that, I can easily add a hook requiring log in for
adding more than X items to the cart... but I'm not going to waste my
time implementing that until that happens.
This is what I am doing:
- add some reservation settings to global config (reservations enabled
and reservation time)
- reservations start as soon as anything is added to the cart (I use
the cart's created_at time)
- add 'items_reserved()' to my custom product model
- items_reserved() goes through all carts looking for the
product_id and totals the reserved product count
- add 'net_items_in_stock()' to my custom product model, subtracts
items_in_stock by items_reserved()
- add my own listener (veto_reserved) and disconnect satchmo's
veto_out_of_stock
- use net_items_in_stock() from my custom product instead of
items_in_stock (in the new listener)
- add a cron job with a script called 'clear_expired_carts', expire
all carts by deleting them from Carts (I will also add an ExpiredCarts
model for analysis later)
- I don't want to customize the satchmo code (the Cart model) so I
have to work around it by adding the ExpiredCarts model..... any ideas
on how to do this better?
- I will add caching to this too (with invalidation when something is
added/removed from carts).
I understand this may not be what you want but this may give you an
idea on how to implement it your way.
- David
On Jun 5, 2:17 pm, Michal <[email protected]> wrote:
> I hear you, but that doesn't solve my problem. I need to be able to
> allow many people add item to cart (as satchmo allows by default) but
> with the "Track inventory"=true and "Allow checkout with 0
> inventory"=false make sure that satchmo _does not_ allow checking out
> while product.items_in_stock=0. That is the behavior I expected after
> setting those configuration options.
>
> Similar problem resulting with the same bug is reported
> here:http://bitbucket.org/chris1610/satchmo/issue/1163/purchase-of-inactiv...
>
> So I was asking for ideas on how to workaround this as I was not able
> to find out how to hook to the moment in satchmo execution that
> happens when user presses the "Checkout" button and submits the cart
> for checkout.
>
> Also a potential problem with your solution would be that someone
> could potentially create a script that would add all of your products
> to cart and no one else would be able to put anything from your store
> to cart for an hour or however long until the cart cleanup script
> would kick-in. And since you are not notified on cart creation (as
> opposed to when someone submits an order) you wouldn't even know about
> it.
>
> -Michal
> On Jun 4, 11:50 pm, Alex Robbins <[email protected]>
> wrote:
>
>
>
> > Seems like the problem is that you want lots of people to put it in
> > their cart, even if you don't have that many left. That violates the
> > shopping cart mental model. In the real world, if a store is out of a
> > certain item, I can't put it in my cart. If you followed that same
> > principle here, then Chris' idea works. You would need to drop old
> > carts after a reasonable amount of time (maybe an hour?) with some
> > kind of cleanup script, but that seems doable.
>
> > I haven't coded any of this, but it makes sense in my head :)
> > Alex
>
> > On Fri, Jun 4, 2010 at 3:53 PM, Michal <[email protected]> wrote:
> > > Any ideas... anyone?
>
> > > -M
>
> > > On Jun 1, 9:23 am, Michal <[email protected]> wrote:
> > >> That would not help, because all I can check at that point is how many
> > >> other people have that item in their carts, but I cannot make
> > >> decisions on whether to allow add or not based on this.
>
> > >> In the given use case at this point product.items_in_stock would still
> > >> be 2. So I will allow any number of users to add it to their carts.
> > >> And lets say none of them changes anything again before checkout - I
> > >> will still be left with -3 in the items_in_stock. ...and 3 very
> > >> unhappy customers.
>
> > >> Do you see a way to verify the cart once user clicks "Checkout"?
>
> > >> -Michal
>
> > >> On Jun 1, 3:40 am, Chris Moffitt <[email protected]> wrote:
>
> > >> > You could used cart_add_verify to do an additional inventory check
> > >> > before
> > >> > adding to the cart.
>
> > >> >http://www.satchmoproject.com/docs/dev/signals.html
>
> > >> > -Chris
>
> > >> > On Sun, May 30, 2010 at 5:43 PM, Michal <[email protected]> wrote:
> > >> > > The use case is - the stock for a given product is 2 items and 5
> > >> > > shoppers put the same product in their carts and proceed with
> > >> > > checkout
> > >> > > process and place an order. The outcome will be -3 in the
> > >> > > product.items_in_stock. Looks like the whole inventory tracking
> > >> > > mechanism is encapsulated in an signal listener attached to
> > >> > > order_success and there is no validation done anywhere before or even
> > >> > > here.
>
> > >> > > So - my question is - what is the best signal to connect to do cart
> > >> > > verification before it is passed to payment for checkout handling? Or
> > >> > > maybe there is another way to solve it without modifications to
> > >> > > satchmo core?
>
> > >> > > Regards,
> > >> > > Michal
>
> > >> > > --
> > >> > > You received this message because you are subscribed to the Google
> > >> > > Groups
> > >> > > "Satchmo users" group.
> > >> > > To post to this group, send email to [email protected].
> > >> > > To unsubscribe from this group, send email to
> > >> > > [email protected]<satchmo-users%2bunsubscr...@goog
> > >> > > legroups.com>
> > >> > > .
> > >> > > For more options, visit this group at
> > >> > >http://groups.google.com/group/satchmo-users?hl=en.
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "Satchmo users" group.
> > > To post to this group, send email to [email protected].
> > > To unsubscribe from this group, send email to
> > > [email protected].
> > > For more options, visit this group
> > > athttp://groups.google.com/group/satchmo-users?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Satchmo users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/satchmo-users?hl=en.