[checkout] How to auto-mark an item as purchased after being bought through Checkout?

wduffee

Joined: 2006-03-07
Posts: 3
Posted: Wed, 2010-08-11 13:25

Hello all,

I would like to sell individual pieces of artwork through Gallery with the Checkout module, and it is going well. However, I am wondering if there is a way to change the status/name/something of the item to "sold" automatically when a payment is made for an item - is there an implementation for this somehow?

Thank you all very much!

Best,Wesley

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Wed, 2010-08-11 19:21

That's an interesting question, and the answer is probably more complex than you want.

Firstly, no, there's no current implementation of anything like that.

Secondly, assuming you can determine *when* an item is sold, you could have a small module that uses the existing "event" hooks in gallery/checkout to run some code. There's no existing way to mark an item as "sold" but you could revoke the guest user's permission to add that item to their basket, for instance, which would prevent a second person from buying it.

The difficulty is that it's very hard to determine exactly when an item is bought, depending on your methods of payment. So there might be a gap of some minutes (or days!) between someone considering that they've bought an item and checkout receiving notification that an order is paid. And what if two people put it in their basket at the same time and later both go on to buy it, it would then be too late. Having said that though, I recognise that if two people sneak in and buy the same artwork within a few minutes then a) that's pretty rare and b) you just have to email one and tell them someone snuck in and bought it just a little earlier. So it's not that it's not worth doing, you just can't make it entirely foolproof.

To reiterate, however, unless you (or someone you can find) wants to dig deep into the insides of checkout and gallery2 and write the code to do this, then no, at present it's not a feature you can just install.

 
wduffee

Joined: 2006-03-07
Posts: 3
Posted: Wed, 2010-08-11 19:37

Hello Alec!

Thank you for your response! But I am confused - when someone checks out (or even just goes to PayPal with an order), it updates that status through the "Checkout Orders" (Checkout::Order Administration) module. Perhaps it involves the user clicking the "Return to ****" link after completing the purchase with PayPal that it can update that order status? Either way, it definitely knows what was bought and the order details.

So it seems that there is some implementation of Checkout knowing the status of the actual order. Perhaps it is only a feature with PayPal orders but it definitely works...now just to remove the guest permission to purchase automatically. Hmmm....anyone?

Thank you - Wesley

 
Dayo

Joined: 2005-11-04
Posts: 1642
Posted: Wed, 2010-08-11 20:19

The checkout module is a great module that meets most of the e-commerce needs of G2 users.

For unusual or specific stuff however, you can try the zencart bridge. In zencart, set the default quantity of each item to 1 and and it will mark it as out of stock once it is sold (you can change the out of stock message to just say "Sold" or perhaps add a "Sold" graphic).

You will be better off if you do this before installing the module. Look in the GalleryZenCart.class file of the module and around line 948, change $data = array('products_quantity' => '9999.0', to $data = array('products_quantity' => '1.0',

The downside with the zencart bridge is that you will be running, and will have to manage, two separate full applications and the integration is not as tight as with checkout.

--
dakanji.com

 
wduffee

Joined: 2006-03-07
Posts: 3
Posted: Wed, 2010-08-11 20:23

Hello Dayo!

Thank you for the tip and clear instructions - that reads like it could very well be the solution I've been looking to find.

Thanks again!
Wesley

 
Dayo

Joined: 2005-11-04
Posts: 1642
Posted: Wed, 2010-08-11 20:33

Your are welcome.

As zencart is a full featured commercial grade cart, it has virtually every feature a merchant might need (which might be OTT for most G2 users though).
In your case, if the buyer falls through and you cancel their order, the item will be returned back to stock.

--
dakanji.com

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Wed, 2010-08-11 20:40
Quote:
when someone checks out (or even just goes to PayPal with an order), it updates that status through the "Checkout Orders" (Checkout::Order Administration) module.

The difficult is that there is no way for checkout/Gallery to tell the difference between;

a) a user creates an order, goes to the "confirm" page but decides not to proceed, and doesn't choose a method of payment

and

b) a user chooses paypal, doesn't return from the paypal website after making payment (goes to a different website or closes their browser) and the paypal IPN notification is delayed or lost. Google in particular has very late payment notifications, it can take up to 30 minutes.

Situation a) is very common; if you look you will see that only a small number of the order records in the database become actual orders, but they're recorded as a new order every time that the "confirm" page is visited.

It works out fine most of the time, but there are paths through the module that can leave an order in an indeterminate state for some period, and that make it impossible to determine with certainty when an order is placed. They are rare and you may never have encountered one in practice, but that doesn't mean they don't exist. If you don't follow the above you will just have to trust me, as author/maintainer of the checkout system.

There is exactly the same problem with single-use discount coupons, which I would have liked to implement. There's no reliable way to know when exactly a coupon has been used and should be invalidated. It would be possible to write a system that was 99% reliable but I didn't consider that good enough.

Overall I would try Dayo's solution: checkout is specifically not designed from products with limited stock, it's really for selling prints where you can make as many as you like.