When a coupon 100% discount is applied - it would be nice if payment/billing is not needed.
Has any one done this? Or ideas where to begin?

(I know there is a 'free order' module for 5.x. With a minor port to 6 - it still does not address the issue. It requires billing and attempts to validate payment)


#23 420980-free-payment-method-23.patch5.3 KBlongwave
PASSED: [[SimpleTest]]: [MySQL] 2,508 pass(es). View
#21 420980-free-payment-method-21.patch5.31 KBlongwave
FAILED: [[SimpleTest]]: [MySQL] Invalid PHP syntax in sites/default/modules/ubercart/payment/uc_payment/tests/uc_payment.test. View
#9 420980-free-payment-method.patch2.39 KBlongwave
PASSED: [[SimpleTest]]: [MySQL] 2,455 pass(es). View
#8 ubercart-free-order-1016690-50.patch3.91 KBlongwave
PASSED: [[SimpleTest]]: [MySQL] 2,455 pass(es). View


longwave’s picture

Title: 100% discount » No payment/billing should be required when order total is $0
Project: Ubercart Discount Coupons » Ubercart
Version: 6.x-1.x-dev » 6.x-2.x-dev
Component: Miscellaneous » Code

Moving this to a core Ubercart issue as this isn't specific to uc_coupon - even though a 100% discount may be applied there could be a shipping charge or other line item that still needs to be paid for, and uc_coupon is not responsible for these.

This probably needs co-operation from the payment module that is in use at the time - some kind of check would need to be added to skip any payment entry screen when the order total is $0.

rszrama’s picture

Status: Active » Postponed

Postponing until later. I'd love for the free payment method to come into core as well, but I'm just not sure how feasible that is. Esp. since an order can drop down to $0 on the checkout screen itself... magically erasing fieldsets isn't necessarily straightforward.

Dr Jay’s picture

+1 on this ...

davipilot’s picture

+1 on this as well.

webservant316’s picture

yes I need this also.

TR’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev
Status: Postponed » Active

This will have to go in 7.x-3.x first, if it's implemented.

longwave’s picture

@coolestdude1 worked on a patch for this in #1016690-50: Drupal 7 Support

longwave’s picture

Component: Code » Payment
Status: Active » Needs review
3.91 KB
PASSED: [[SimpleTest]]: [MySQL] 2,455 pass(es). View

Patch attached from that issue for review. Should this be a separate module, or should it just be included as a default payment method directly in uc_payment?

It would also be good to get some tests in to ensure this works as expected.

longwave’s picture

2.39 KB
PASSED: [[SimpleTest]]: [MySQL] 2,455 pass(es). View

This integrates the free order payment method directly into uc_payment, based on #8. It adds a new op to the payment method callbacks, so users don't have to configure Rules for the free order payment method, they are simply applied automatically.

Not sure what we should do about the other payment methods, I guess if free_order is available we should just make it the only available choice? Perhaps there should be an alter hook for payment methods instead where we can do this?

coolestdude1’s picture

I can confirm this is working as you say with the simpler workflows in UC (aka no shipping just plain products).

There might need to be a check in place of the payments section that will reload when requested. The module in #8 did this with hook_form_FORM_ID_alter on the form uc_cart_checkout_form (line 13 of uc_free_order.module). This means that when the form is reloaded the hook will get called from the coupon form.
At least that is how I think it works because technically forms on the checkout page is all one unified form with your pane objects added in.

One way you can get around this is to have an ajax trigger reload the checkout payments pane. You need to then perform the same actions where you check to make sure the free order is valid then you eliminate the other methods of payment and also set as the selected value and then lock it until they make changes or checkout.


Use uc_free_order.module and have it function as before for when the form is ajaxed from the coupon form it will be setting $form_state['rebuild'] = TRUE; and reloading the pane. (also just to add in here roughly line 1182 of uc_coupon.module)

Do you mind relying on the hook_alter? Or would you want to lock it down and have your own mechanism in there to perform the changes? Either one is fine by me but they both entail different workflows.

Workflow wise we have right now
1. User adds product to cart (from store section or custom add to cart links)
2. User clicks 'check out' (from cart form)
3. User enters coupon for discount (from checkout form)
4. Checkout form updates with the free order method once a check was made for the price below threshold: 0.01
5. User is happy with order as is and no more input is necessary, user clicks 'review order' (from checkout form)
6. User reviews order and clicks 'complete order' (from order review page)
7. Order complete and message shown to user for checkout completion details.

Alternatively users can arrive to the checkout page with products that are already free and do not need coupons so maybe the ajax reload might not be enough on its own. The form alter would not have an issue with this as the alter is still run on initial loads of the form.

longwave’s picture

Thanks for testing this and helping work through the possible use cases.

Reloading the payment pane in a clean and compatible way should be possible with the patch in #1373236: Allow multiple modules to react on checkout Ajax events, but I have not yet tested this.

granticusiv’s picture

Yay! I'm really glad to see some movement on this. I've been delaying implementing parts of a client's site because I couldn't find any solution. If we can get these patches/updates working, that would be fantastic. Can I donate anything to help things move along?

longwave’s picture

Test the patch, with or without the patch in #1373236: Allow multiple modules to react on checkout Ajax events, and let us know whether or not it works for your use case.

granticusiv’s picture

Okay... so I've tried to read as much as possible to work out how to get to the testing stage, but I've run into some issues. It looks like I'm supposed to download 6.x-1.x-dev from http://drupal.org/project/uc_free_order and then apply the patch ubercart-free-order-1016690-50.patch to bring it in to D7, but when I tried patching that module, it was giving me the following in terminal

patch < ubercart-free-order-1016690-50_0.patch
The next patch would create the file uc_free_order.info,
which already exists! Assume -R? [n] y
patching file uc_free_order.info
Hunk #1 FAILED at 1.
File uc_free_order.info is not empty after patch, as expected
1 out of 1 hunk FAILED -- saving rejects to file uc_free_order.info.rej
The next patch would create the file uc_free_order.module,
which already exists! Assume -R? [n] y
patching file uc_free_order.module
Hunk #1 FAILED at 1.
File uc_free_order.module is not empty after patch, as expected
1 out of 1 hunk FAILED -- saving rejects to file uc_free_order.module.rej

Has the dev version of ubercart-free-order already been updated or something?

While I'm here, can I confirm the rest of the steps? I'm guessing I then patch payment/uc_payment/uc_payment.module with 420980-free-payment-method.patch? I have 7.x-3.x-dev of Ubercart installed.

longwave’s picture

@granticusiv: Sorry I didn't explain fully; you don't need to start with uc_free_order at all. You only need Ubercart 7.x-3.2 or 7.x-3.x-dev and the patch from #9 - http://drupal.org/files/420980-free-payment-method.patch - this is all you need to add the basic free order payment method.

If you have shipping rules or other conditions set up that mean the free order method might become (un)available due to changes the user makes on the checkout page, the latest patch at #1373236: Allow multiple modules to react on checkout Ajax events will help with this.

granticusiv’s picture

So, what's supposed to happen after you place an order?

  1. Go to Checkout page
  2. Enter shipping/customer information
  3. Choose 'No payment required'
  4. Click 'Review Order'
  5. On next page, I can see "Paying by: Free order" which is all good
  6. Click "Submit Order"
  7. Now I'm back at the Checkout page...

When I place an order with a figure above $0 through Paypal, I'm redirected to cart/checkout/complete, where it displays an 'Order Complete' message. Is there a setting to change the order confirmation page for the free order?

When I look in the backend, I can see that the orders were placed successfully. I haven't looked at confirmation emails yet. They don't appear to be setup for free orders, or paid orders.

granticusiv’s picture

I was just doing some more testing with Rules, and noticed that placing an order with this free order method doesn't trigger the event "Customer completes checkout". Is there any other event I can test against to create a Rule?

granticusiv’s picture

Okay, and after some more testing, I can't work out what prompts an order to switch to Completed. I have a number of orders that have moved to Completed, but I wasn't watching my actions closely, so I'm not sure what triggered it to change. On the other hand, I have a lot of orders that I've placed that won't move past the In checkout status.

I've tried Reviewing the order, then Submitting the order (which takes me back to Checkout), and cycling through those steps 3-4 times, but that doesn't change the order's status. I've tried adding a paid product to the cart, and then removing it before Submitting the order. I've tried placing a free order, and then placing a paid order, but it just ignores the attempts to submit the free order, and then simply adds the paid products to the free order. When checking out with paid products, it updates the status to Completed.

*sigh Hopefully this helps someone?

btw, this has all been tested without the #1373236: Allow multiple modules to react on checkout Ajax events patch

granticusiv’s picture

Okay, sorted the looping issue with thanks to this page - http://drupal.org/node/1785746

Actually, that might have fixed the other things mentioned above as well. Will double check it all tomorrow.

rickmanelius’s picture

Status: Needs review » Needs work

Hi longwave,

First, thanks for this! While I've used uc_free_order in the past, I like that this functionality is moving into ubercart core so that it's maintained, etc.

I'll comment on a few pieces: ajax and UX. And before that, I'm using the patch #85 in #1373236: Allow multiple modules to react on checkout Ajax events.


The ajax works as expected in the sense that on cart/checkout, adding a 100% discount coupon loads the "no payment required" option while removing the coupon reverts it back to a Credit Card payment (or whatever else is allowed).


I do have a few UX concerns/questions because I know customers can do things contrary to their best interests! For example, adding a 100% discount coupon does enable the free payment option, but it doesn't fully disable the credit card option. If I try to proceed to checkout with credit card selected, it reloads the page with all the credit card fields now available. I know we had some issues in the past with people actually putting in credit cards for a $0 order an authorize.net rejecting them because they can't capture/approve $0 orders... leading many customers to be confused. After all, maybe they thought that putting their card in the system is a good thing in case they want to use it for a future order, etc.

I haven't looked at the patch closely, but I know the uc_free_order module removes the other payment methods for a $0 order (see patch here #1016690: Drupal 7 Support). This makes sense to me because one wouldn't use a check, COD, credit card, etc when it's $0.

I can potentially help here as my need for this module has returned. Hopefully it's as simple as taking some elements from #1016690: Drupal 7 Support.

I would set this as RBTC because it does work (when used in conjunction with #1373236: Allow multiple modules to react on checkout Ajax events), but I think the UX concerns warrant some additional work on this.

longwave’s picture

Status: Needs work » Needs review
5.31 KB
FAILED: [[SimpleTest]]: [MySQL] Invalid PHP syntax in sites/default/modules/ubercart/payment/uc_payment/tests/uc_payment.test. View

This patch takes into account the UX considerations from #21 by removing all other payment methods when the order is free. It also includes SimpleTests, though I have not yet tested it in conjunction with the checkout Ajax patch.

Status: Needs review » Needs work

The last submitted patch, 420980-free-payment-method-21.patch, failed testing.

longwave’s picture

Status: Needs work » Needs review
5.3 KB
PASSED: [[SimpleTest]]: [MySQL] 2,508 pass(es). View

Oops, let's try that again.

Status: Needs review » Needs work

The last submitted patch, 420980-free-payment-method-23.patch, failed testing.

longwave’s picture

Status: Needs work » Needs review
rickmanelius’s picture

Status: Needs review » Reviewed & tested by the community

#23 worked like a charm... and removed the payment options/added it back and everything. Thanks @longwave!

js’s picture

Thank you for this functionality!!!

TR’s picture

@js: Does that mean you've tested the patch? If so, what are your experiences? Does it apply, does it work, does it conflict with other modules you're using, etc. ?

longwave’s picture

Status: Reviewed & tested by the community » Fixed

Committed #23. @rickmanelius's testing and the automated tests are enough for me, this is an optional payment method and any further issues can be resolved in new issues now it's in -dev.

Status: Fixed » Closed (fixed)

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

zincdesign’s picture

Hello, I can't get this patch to work on Ubercart 7.x-3.x-dev

I get the following error:

can't find file to patch at input line 5
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
|diff --git a/payment/uc_payment/tests/uc_payment.test b/payment/uc_payment/tests/uc_payment.test
|index 65e538a..ec30fb2 100644
|--- a/payment/uc_payment/tests/uc_payment.test
|+++ b/payment/uc_payment/tests/uc_payment.test

Cheers Simon

longwave’s picture

You don't need this patch in 7.x-3.x-dev, it's already included.

zincdesign’s picture

ah ha! Thanks Longwave!