wp-e-commerce / WP-e-Commerce

WP eCommerce - The most popular independent eCommerce platform for WordPress
https://wpecommerce.org
GNU General Public License v2.0
213 stars 216 forks source link

Stock claims / heartbeat API #612

Open leewillis77 opened 11 years ago

leewillis77 commented 11 years ago

I'm just reading an article on the new Heartbeat API in WP 3.6 (http://wp.tutsplus.com/tutorials/creative-coding/the-heartbeat-api-getting-started/) and just throwing an idea out there to see how we could / should use this in WPEC.

The main area I think it could be useful is for stock claims - ie do we drop stock claims if there's no heartbeat?

Thoughts?

benhuson commented 10 years ago

I started building out a WPEC_Claimed_Stock class for other reasons, but it could be extended to support Heartbeat API and refactored into WPEC if we think this to be a good idea.

I can see how Heartbeat API could work for stock claims, but in conjunction with cron or regular purging?

While a user is browsing the site the Heartbeat keeps their claimed stock claimed. When Heartbeat is not longer present (ie user has left site) their claimed stock could be scheduled to be dropped.

The benefit I could see here is you could have a shorter period of time for which to keep claimed stock as you'd be able to tell when a person left the site, rather that maybe just being inactive for a while.

Think it might be a bit of an overkill but that's the only way I think it could be relevant to claimed stock.

Had a thought that's more plugin territory though...

Display a live stock count to the user when viewing a product. Heartbeat could query and display remaining stock.

JeffPyeBrook commented 10 years ago

I'm not sure the heartbeat would work well for claimed stock. I have observed many users will put something into a cart and come back to it later in the day, or even on the next day. If we used the heartbeat the stock would be released in those cases.

I might also depend on the behavior of customers of a specific store. We see completed sales in 80% of the carts that get items. I know that's very high and other stores have less than a 50% complete rate. For lower complete rates and low stock levels it might be exactly the solution.

benhuson commented 10 years ago

So, this probably feeds back into the possibility of having multiple Stock APIs. So if you had an integration that required having short/no claimed stock, then that Stock API could implement Heartbeat.

garyc40 commented 10 years ago

Using heartbeat API is cool but we would still need to implement our own function to detect if there's no heartbeat from a certain cart after a while. This reminds me of the work we're doing on customer meta ( #621 ). We're also purging customer data after they have not been active within 48 hours (based on a user meta called wpsc_last_active). Maybe we don't need to use heartbeat API but rely on the customer purging routine instead (i.e. decrease claim stock when a customer is purged).

We sorely need an option to turn off claimed stock as many people have requested that over the year. And as @JeffPyeBrook and @benhuson mentioned, we need to allow people to switch out the default stock behavior if they so desire (implement it as a component perhaps?).

As a customer, I have many times failed to purchase an item because it ran out of stock before I was able to click "Checkout". Perhaps some sort of live notification when stock is becoming low via heartbeat API would also work ("Currently 9 customers have this items in their cart, but only 6 are in stock. Act fast!").

benhuson commented 10 years ago

@garyc40 I think that's exactly it.

It's annoying as a user if you have something in your cart and when you checkout it has gone out of stock.

Similarly, as a seller, it's annoying if you have low stock items like original art prints if people keep adding to their cart, then not purchasing.

Just need the flexibility in place so the store owner can decide.

instinct commented 10 years ago

Aye. I too agree with @garyc40. When I book a hotel I usually do it via agoda.com and I love being able to see how many "deals" are left or how many other people are looking at that room. Gary nailed it ("Currently 9 customers have this items in their cart, but only 6 are in stock. Act fast!").

JustinSainton commented 10 years ago

@1bigidea can speak directly to how useful something like this might be. Heck, he might even have code to contribute to it. Love the idea of some kind of Hearbeat usage (now that the API is getting shored up a bit).

JustinSainton commented 10 years ago

Moving to 3.8.14 for further discussion.

1bigidea commented 10 years ago

No code yet - but I am working on a prototype project to solve a related client problem where I trying to show inventory in real-time and have 5000 hits purchase just 100 items in a 15 minute period.

On Dec 21, 2013, at 3:00 AM, JustinSainton notifications@github.com wrote:

@1bigidea can speak directly to how useful something like this might be. Heck, he might even have code to contribute to it. Love the idea of some kind of Hearbeat usage (now that the API is getting shored up a bit).

— Reply to this email directly or view it on GitHub.

JustinSainton commented 10 years ago

Ha, thought you might still be working on that, assuming it's the same project?

1bigidea commented 10 years ago

Same project. At the moment, it is just about surviving our Monday mornings during the holidays!

But I am very interested in tying into the heartbeat api for updating inventory.

On Dec 24, 2013, at 3:56 PM, JustinSainton notifications@github.com wrote:

Ha, thought you might still be working on that, assuming it's the same project?

— Reply to this email directly or view it on GitHub.

JeffPyeBrook commented 10 years ago

Moving to 3.9.0 for discussion

JustinSainton commented 10 years ago

Would love to see this make it into 3.9.0 now that WP 3.9 has the Heartbeat API no longer marked as "experimental". Time to play!