26 replies [Last post]
Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15459
Was this information Helpful?

Well, the request to accommodate checkout for orders with a $0 total (due to discounts and such) has been around for quite some time. Unfortunately, the core JS just wasn't designed to accommodate something like this very easily, primarily due to the nature of single page checkout and the order total preview. Recently, some work sponsored by Warner Bros. Records had the benefit of seeing improvements made in the core payment Javascript that made this module possible. Be sure to give them a pat on the back next time you see them at Drupalcon. Eye-wink

The module is simply called Free Order and should be painless to setup. Read through the page there and put it to use if you intend to use discounts or coupons on a site.

I haven't tested this in a setting where the products themselves cost $0, so I'd be interested in any feedback from those who have real world situations like that.

The only caveat is at the bottom of that page... it requires the latest code to work. I ended up fixing a minor issue with the order total JS which is post RC 1. I'll spend a few minutes tomorrow packing up RC 2 which will also include Lyle's fix to the product module's hook_access(). You can always just grab the latest Bazaar code to test it out in the meantime.

BlindWolf8's picture
Offline
Joined: 01/30/2008
Juice: 73
Ryan,

Ryan,
This module came just in time for us, as we are launching our website today. We do get one error upon applying a coupon, and then selecting Free order and doing Review Order: "We cannot process your order without payment." The page reloads with that message.

Thank you WBR and Ubercart! Laughing out loud

Edit: We're using:

  • Drupal 5.7
  • Ubercart 1.0-rc2
  • Tables API 5.x-1.5
  • Checkall 5.x-1.0
  • Token 5.x-1.10
  • uBrowser 5.x-1.3
  • Ubercart Mod: Custom Price
  • Ubercart Mod: Free Order
  • Ubercart Mod: Linkpoint API 5.x-1.0-beta4
  • Ubercart Mod: Store Coupons 5.x-1.5 (aka Improved coupon discount 1.5)
    • Info about coupon applied during the order:
      • Coupon gives 100.00% discount
      • Expiration: Apr. 14th, 2010
      • Weight: 0 (also tried -10 and 10)
      • Minimum Order Amount: 0.00
      • Maximum Number of Redemptions: 0
      • Maximum Number of Redemptions for one single user: 0
      • Restricted to one product

Our on-site programmer looked at it, and he said it seems as though the coupon isn't being applied properly, and thus the error message is thrown by Free Orders. Any help would be appreciated. Thanks!

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15459
Re: Ryan,

Hmm... could it be it's failing to attach the line item to the order when you submit the checkout form? This is the reason it would fail.

BlindWolf8's picture
Offline
Joined: 01/30/2008
Juice: 73
Ryan, The prices and the

Ryan,
The prices and the items themselves are being passed properly. It seems as though the coupon just isn't being applied, even though it shows $0.00 after it is applied, and I'm able to select Free Order as a payment method.

Also, just as a clarification, we were supposed to put the Free Order module in the payments folder, correct?

I can always setup a sandbox to test.

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15459
Re: Ryan, The prices and the

I'm not sure here... I don't have time to debug that module, but you might try getting in touch with the coupon module's author. You can always disable the $0 order total module and try completing a checkout.

BlindWolf8's picture
Offline
Joined: 01/30/2008
Juice: 73
Ryan, If it helps any,

Ryan,
If it helps any, orders do go through if the products are $0.00 in price, so I think it is a bug in the coupon module. My sandbox is almost up, so anyone can test if needed. Should I post the sandbox info here?

z3b
z3b's picture
Offline
Joined: 08/15/2007
Juice: 52
Re: New Module for $0 Orders

Got the same problem here.
-Drupal 5.7
-Ubercart 1.0 RC2

It doesn't seem to be a "uc_coupon" bug to me.

There is a test option in "free_order" called "add discount", when I use it to bring the total below zero I always get "We cannot process your order without payment." (same thing with uc_coupon 1.5 zmove version)

I did a bit of debug, "order_total" seems to be updated but too late, or something like that.
As its stay over Zero, "free_order" deny the checkout.

I tried a couple of fixes without luck...
Hope someone can find a proper fix!
Thanks.

PS: Also tried with today bazaar code with no luck.

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15459
Re: Re: New Module for $0 Orders

fwiw, the test discount doesn't actually get applied to the order, so it will always fail by design. Perhaps I should make that clear, eh? It basically lets you test the payment checkout pane and then see what happens if someone tries to game the system by somehow faking a discount.

BlindWolf8's picture
Offline
Joined: 01/30/2008
Juice: 73
Ryan,

Ryan,
Just to clarify even more to differ from what z3b said, I tried it using a test user that had the right privileges to use that coupon, etc., so I think my bug is unrelated to z3b's "bug."

P.S.: My sandbox is up, so PM me if you want access. Thanks!

z3b
z3b's picture
Offline
Joined: 08/15/2007
Juice: 52
Re: New Module for $0 Orders

Thanks for the clarifications !

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15459
Re: Re: New Module for $0 Orders

I just uploaded a new version that I believe fixes the issue posted by BlindWolf above... if line items weren't getting added to an order early enough, the free order payment method would still be checking an order total over $0. To fix this, I've moved the check to ensure an order total of $0 to the review order form creation instead of the checkout form validation. It'll just kick you back to /cart/checkout if it thinks you got there inappropriately.

Let me know if this solves the problem and if it still works properly in other cases. Smiling

zcferres's picture
Offline
Joined: 04/06/2008
Juice: 55
problem

After an order is placed and it is 'free' it seems to be marking the order as Pending. I would like it to goto Completed immediately after they place the order. Any ideas?

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15459
Re: problem

You'll just need to create a custom workflow configuration... I'd recommend using the "order is updated" function... check the order's payment method for free order in a condition, and if that's found then perform an action to update the order to "Completed."

ambereyes's picture
Offline
Bug Finder
Joined: 05/19/2008
Juice: 98
Hi! The free order payment

Hi!

The free order payment option never displays for me on the cart/checkout form. I enter the coupon that should zero the order but the zero order payment option never displays. Plus when I review the order, the balance is zero but now it has PayPal set as the payment option ... which will cause problems if submitted.

The coupon works when the balance is not zero, and goes through to PayPal just fine.

I am using Bazaar code dated May 23 at 4:01 (Is there a place that gives the build number?)

thanks,
Katrina

www.ambereyes.net

ambereyes's picture
Offline
Bug Finder
Joined: 05/19/2008
Juice: 98
Re: Hi! The free order payment

I just inserted some alerts and discovered that the check for a zero total runs on page load and not as I imagined ... after the coupon is entered. I thought that the total was supposed to be checked right before the payment pane is displayed.

This is not right, right?

a confused Katrina

ambereyes's picture
Offline
Bug Finder
Joined: 05/19/2008
Juice: 98
Re: Re: Hi! The free order payment

Okay. I figured it out.

Free order works great when the order total coming into checkout is zero. What does not work for me is when the order gets zeroed by a coupon. I assumed initially that part of the problem was the ole' Safari Ajax bug, but then I also had problems in Firefox.

So what would work for me is a way to modify orders with a balance of zero so that the become free orders automatically no matter what payment method is selected, ie. checkout is completed immediately.

I initially tried to modify free order by adding a function to implement hook_order.

/**
* Implementation of hook_order().
*/
function uc_free_order_order($op, &$arg1, $arg2) {
switch ($op) {
    case 'load':
    if ($arg1->order_total <= .01 && $arg1->order_status == "In checkout") {
    db_query("UPDATE {uc_orders} SET payment_method = '%s' WHERE order_id = %d", 'free_order', $arg1->order_id);
    }
      break;
     }
}

But the testing got hosed due to the problems I was having with the uc_referer issue - so I never got to see if it worked or not. Can someone look this over and maybe figure a better way to address this issue?

Thanks,
Katrina

www.ambereyes.net

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15459
Re: Re: Re: Hi! The free order payment

Hey Katrine, thanks for testing out this module so much. I am curious, though, about why it wouldn't be working for a coupon zeroing an order. It has JS to accommodate that. It could be you're on an incompatible version of Ubercart... this module does require RC 2 or higher, and you'll need to refresh on the checkout page to make sure you aren't operating with old cached JS.

ambereyes's picture
Offline
Bug Finder
Joined: 05/19/2008
Juice: 98
Re: Re: Re: Re: Hi! The free order payment

I am using the bazaar code, rev 1152, testing from my Mac Powerbook Pro G4 running Tiger (10.4.11) via Safari 3.1.1 and Firefox 2.0.0.14.

At first I thought it was the safari/ajax bug but then I also had problems with Firefox too. Then I discovered the uc_referer bug and had to stop my testing to figure that out that problem first.

Now on occasion the JS works but most of the time it doesn't for me. I know that Mac users are not the majority of users, but I think we need a fail safe just in case the ajax call fails for whatever reason. The JS error I get in Safari is "Refused to set unsafe header Connection." From what I could figure out, it has something to do with Safari detecting a malformed header being received back from the server. Safari is expecting a more standards based version of ajax while other browsers are more forgiving. There is a way of correcting it in the code but it is beyond my skills at this point.

I suspect that Apple may be more forgiving in Safari versions for Leopard and the iPhone, because my colleague running Leopard has fewer problems.

Think of it as another level of input validation, "if zero balance => complete order."

thanks for listening,
Katrina
www.ambereyes.net

ambereyes's picture
Offline
Bug Finder
Joined: 05/19/2008
Juice: 98
Good news! The roll back

Good news!

The roll back helped a lot. I am on bazaar rev 1159. And I can now at least see the free order payment method after inputting a coupon that results in a free order. The method is not pre-selected however and all the other payment methods are still available. So I had to add help text reminding the user to select the free order option if the order will be zero after the coupon - which is awkward at best.

I am waiting to hear back from my colleague if it works fine on Leopard.

This is definitely an improvement.

thanks,
Katrina
www.ambereyes.net

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15459
Re: Good news! The roll back

Again... not sure why the payment methods are getting hidden like normal. Since you've rolled back, have you refreshed your browser on the checkout page to make sure it isn't caching some stale JS?

ambereyes's picture
Offline
Bug Finder
Joined: 05/19/2008
Juice: 98
Re: Re: Good news! The roll back

Yes I refreshed the page.

Incidentally, I am getting the following javascript errors.

Check it out at wccs.ambereyes.net with coupon "freemonth08".

Katrina
www.ambereyes.net

ambereyes's picture
Offline
Bug Finder
Joined: 05/19/2008
Juice: 98
Eureka! I think I found the

Eureka!

I think I found the answer. It is a jquery/ajax issue.
http://docs.jquery.com/Frequently_Asked_Questions#Why_do_my_events_stop_...

I think the problem is that we need to use either re-binding or delegation so that event handlers continue working after a AJAX call. I think I understand what they are saying ... but I am not sure how to implement it exactly.

I found a way to insure zero orders are automatically set up with payment_method = free order no matter what happens with the ajax call ... but now the free order option shows up no matter what along with all the other payment methods.

I am hoping someone understands enough to fix this.

thanks,
Katrina
www.ambereyes.net

richygecko's picture
Offline
Joined: 02/22/2008
Juice: 32
WORKFLOW_NG "payment_entered" Event?

WORKFLOW_NG "payment_entered" Event?

Just noticed that orders that were free were not having their status updated with workflow_ng. That is the payment_entered event isn't being fired.

Any Suggestions?

UPDATE:

I think i figured this one out. Please correct me if I am wrong:

in uc_free_order.module i added the following to the end of the file

<?php
/**
* Implementation of hook_order().
*/
function uc_free_order_order($op, &$arg1) {
  switch (
$op) {
    case
'submit':
      if (
module_exists('workflow_ng')) {
       
workflow_ng_invoke_event('payment_entered', uc_order_load($arg1->order_id));
      }
      break;
  }
}
?>

It seems to work fine.

--Nathan

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15459
Hmm... well it works, but

Hmm... well it works, but it's a little off conceptually. No payment is really getting entered for the order, so you might instead consider adding a second workflow-ng configuration for "Customer completes checkout" and check the order balance on that.

richygecko's picture
Offline
Joined: 02/22/2008
Juice: 32
Sure

When it is obvious that the goals cannot be reached, don't adjust the goals, adjust the action(or in this case workflow_ng) steps.

-Confucius

holeepassion's picture
Offline
Joined: 05/06/2008
Juice: 18
Have digital file download with non shippable ?

Why does it still ask for shipping address ???? How fix this please ?

I may have shippable and non shippable combination in an order though ?

So, if it is free only, could they get straight to the download page ?

How to get to the download file page ????

Thanks

MickC's picture
Offline
Joined: 04/20/2011
Juice: 3
Re: New Module for $0 Orders

Great module - however free method shows up on all items - it won't let you checkout, but shouldn't the javascript hide it?
I'm also trying to use it for a $0 item - not discount.

Any advice?

Thanks,

Mick