10 replies [Last post]
leenwebb's picture
Offline
Joined: 06/01/2008
Juice: 248
Was this information Helpful?

Hey all,
I have userpoints installed, and ran into a case last week where a customer tried to checkout and pay for the entire order with userpoints. Theoretically that's A-OK, but the cart required credit card information, then balked and got an error when trying to process a payment for $0.

I've also got coupons installed, and have installed Ryan's excellent free_order module, so that when a coupon renders the final price $0, the cart no longer asks for Payment info. Sweet!

Is there any way to hook in the userpoints field to the free_order functionality, so that if someone has enough userpoints to pay for a whole order, they don't have to enter CC info (and therefore don't get an error for their $0 order)?

Or is there a better/different way to approach this?

Thanks!
Eileen

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: free_order and userpoints -- how to make them play together?

You might look into my new module http://drupal.org/project/uc_store_credit.

leenwebb's picture
Offline
Joined: 06/01/2008
Juice: 248
Re: Re: free_order and userpoints -- how to make them play toget

Oooooh, spiffy! That looks like it replaces the older uc_userpoints_discount, at least for my use cases. So I can keep my current userpoints setup (which has a bunch of weirdo custom hooks I built for it) but then use your module to handle the use of userpoints during checkout?

Thanks Ryan!

leenwebb's picture
Offline
Joined: 06/01/2008
Juice: 248
Re: Re: Re: free_order and userpoints -- how to make them play t

Hmmm, so Store Credit is cool BUT it does not seem to allow one to purchase a $25 product with (say) $10 of store credit and $15 charged to a CC.

Am I A) correct in this assertion, or B) missing a setting that allows the user to use credits as a discount if they don't have the whole amount?

If A, then is it a case of C) it's really not possible at all within the Ubercart 1.x world to use both types of payment at once, or D) it just hasn't been written yet?

If D, what might that entail? Is it in the works, or do I try to hack it myself?

(Honestly, I did not mean for this to be a Choose Your Own Adventure of a question. But sometimes it just happens.)

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Re: Re: Re: free_order and userpoints -- how to make them pl

You're correct. I had this functionality worked out for a client a while back but have no clue what happened to that code. Sticking out tongue I wouldn't mind working it into the Store Credit module in the future, but any further development I do on that module will be for D6.

leenwebb's picture
Offline
Joined: 06/01/2008
Juice: 248
Re: Re: Re: Re: Re: free_order and userpoints -- how to make the

Bummer. Then I am back to my original problem, that if a user pays for a whole order with userpoints, the CC tries to charge an order of $0 and the system gets upset.

Can I add a check into the CC code that, if the amount is $0, automatically moves to the next step (as if the card had been approved) without actually sending the info in to Authorize.net? Where should I insert a check like that? I am very wary about mucking with anything in the realm of payment, but...

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Re: Re: Re: Re: Re: free_order and userpoints -- how to make

The CC should only charge if CC is chosen as a payment method.. I'm not sure how that came into play for you. Puzzled

leenwebb's picture
Offline
Joined: 06/01/2008
Juice: 248
Re: Re: Re: Re: Re: Re: Re: free_order and userpoints -- how to

The userpoints_discount module allows the user to fill in a field saying how many points they want to use a discount; they might use a $4 discount on a $20 order and so the CC gets charged $16. But when the discount is the whole amount of the order the payment method is still CC because I don't think that userpoints_discount has any sort of tie-in to override payment method (only to change the amount).

(Unless I have it installed/configured completely weirdly and/or wrong?? That is not beyond the realm of possibility.)

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Re: Re: Re: Re: Re: Re: Re: free_order and userpoints -- how

Ok, I think I missed that you were using that module. I haven't touched it in a long time (Shocked), but it seems to me like using that plus free order should actually remove the credit card method if the order total drops to $0.

leenwebb's picture
Offline
Joined: 06/01/2008
Juice: 248
Re: Re: Re: Re: Re: Re: Re: Re: Re: free_order and userpoints --

Is it the free_order.js that sets the payment method to "Free Order"?

Because if I have a total of $24, and I tell the checkout screen, "I want to use $24 of userpoints to discount this order" then on the next screen (Order Review) it shows an order total of $0 (good) but still a payment method of CC (bad).

But if I use the little test-button "add free order discount" at the top of the page the next screen says the payment method is Free Order. Maybe I need to add in a snippet of code that gets called at the Order Review screen, saying, "if order_total is less than $.01, payment method should be free_order".

Does that sound like a reasonable thing to do? Would it work to just change the payment method like that? If so, how do I hook into the order review screen?

tcindie@drupal.org's picture
Offline
Getting busy with the Ubercode.
Joined: 05/15/2008
Juice: 440
Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: free_order and userpoint

It sounds like the order total isn't being recalculated when the userpoints are applied so that the free order module knows the total is now $0...

So, the solution has got to be one of two things, either A) when userpoints are applied to the order, the value of the order total field has to be recalculated, or B) the uc_free_order.js has to subtract the value of the userpoints field from the order_total field.

Either method will require a bit of javascript to work, but in my mind it seems that option A is the better solution because if you were only paying for a portion of an order with userpoints it would be good to see the order total update when points are applied or removed.

I'm not terribly familiar with the userpoints module, so perhaps this behavior is already there, in which case it's probably just a matter of ensuring the function from uc_free_order.js is fired again when the total updates.

Follow me on twitter.