Scenario - someone selects an active product and it is placed in cart. They then hold off clicking checkout. Then for whatever reason product is then made inactive. Customer re-enters cart and completes purchase (product is inactive remember). Purchase should fail - maybe we ran out of product, maybe it expired (like coupon) maybe there was a recall. Anyway I am trying to get at this with rules but can't figure it out yet. Any suggestions how to handle always welcome.

Comments

rszrama’s picture

Will have to think about how to most gracefully handle this problem. I'm not sure if we can depend on a blanket "remove from cart if disabled" logic, though that would certainly be possible at the same point where we recalculate product prices for items in the cart. In the short term, though, you can solve this by implementing hook_commerce_cart_order_refresh() and remove line items to disabled products yourself. You don't need to save the order in your hook implementation, as that is handled by the Cart module.

Road Runner’s picture

I'll have to go learn how to implement a hook.

What about including basic logic in check out function that checks to make sure status is active for all product IDs in each line item of shopping cart. What product ID isn't active is dropped with message to user. Yea, I know I make it sound simple and it probably is a nightmare.

liupascal’s picture

What about having a rule that checks the cart everytime someone is entering the checkout tunnel ?
I guess you can test each line item product and check if one of them is inactive (data comparison?), if yes, display them to your client through a nice message ?

I was on Zara website last time, added a few product to my cart then closed my browser doing other stuff. The day after, i reconnected on zara to complete my checkout - When i click on my cart to review it, i had a nice message letting me know that one of my product was sold out. I think it was pretty nicely handled, not obtrusive and explicit.

rszrama’s picture

Status: Active » Fixed

Alrighty, I thanks to fixes in RC2 pertaining to priceless products, we can now support this behavior with a default Rule. I've added it in in the commit below, and what it does is set the price amount to NULL if a product in the cart has been disabled. This will cause it to be deleted from the cart on refresh. Because this is a default Rule, it can be easily disabled if a site doesn't desire this behavior. Voila!

Commit: http://drupalcode.org/project/commerce.git/commitdiff/091606b

Road Runner’s picture

Very nice and thank you.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.