For a while we've recommended http://drupal.org/project/commerce_no_payment as the solution for showing a user friendly message on the checkout form in place of payment method selection for free orders. However, somewhere along the way that module added two completely unnecessary dependencies on Xano's Payment framework, when in fact the whole point of the module was to provide a lightweight message and triggering of the When an order is first paid in full event when orders were free.

Let's cover these two basic features in core so folks aren't forced into a completely different payment framework if they want to improve the customer experience around free orders.

CommentFileSizeAuthor
#1 2223171.free_orderno_payment.patch5.29 KBrszrama

Comments

rszrama’s picture

Status: Active » Needs review
StatusFileSize
new5.29 KB

The attached patch adds a new radios element to the payment checkout pane settings form. If the box to require payment to proceed past the payment pane is left unchecked, administrators can choose from one of four behaviors:

  1. Leave the checkout pane empty.
  2. Leave the checkout pane empty and trigger the event for free orders.
  3. Show a message indicating payment isn't required.
  4. Show that message and trigger the event for free orders.

This covers the majority use cases as I see them. While it doesn't add a setting to make the text customizable, it could always be altered via string translation or a simple form alter. I didn't make triggering the event automatic, because it is possible to have no payment method for an order with a balance > $0 and it is possible that a site may still want to differentiate between free orders and non-free orders with respect to that event.

In other words, this isn't the most comprehensive solution it could be, but it catches the majority use cases and acknowledges existing points of alteration for sites requiring more customized behavior. At no time will this functionality create a payment transaction entity for the order, as payment transactions were intended to represent actual financial transactions.

rszrama’s picture

A word on testing: because of the way the checkout form handles drupal_set_message() calls, you cannot set messages via Rules to test the function. You'd have to log your test message to the database via a PHP action + watchdog() or something similar. There's a separate issue in this queue for recovering messages that are lost in the automatic redirect from the off-site payment redirect page to the checkout completion page.

Additionally, this patch does nothing to remove payment options for free orders. It is up to the site builder to add the appropriate conditions (i.e. an order balance comparison) to the payment method rules that should be removed when the balance is $0. A flat assumption would hurt us since you have scenarios like test periods for subscriptions where the first month would be $0 but you still need to collect payment details to process recurring payments.

Anonymous’s picture

Anonymous’s picture

Perfect, thank you for this easy solution. I agree with your comment about the dependencies for other modules of the http://drupal.org/project/commerce_no_payment. This is really too much just to offer a free product. Your solution fits perfect an I hope this will go into the core

torgospizza’s picture

So happy I found this thread, you have no idea. I will report back with my testing.

Christopher Riley’s picture

Any plans on getting this committed and part of the module?

rszrama’s picture

Man, I totally forgot about this patch. Erik, any feedback you have would be great. : )

torgospizza’s picture

Status: Needs review » Reviewed & tested by the community

It seems to work swimmingly for us. Which is perfect because we have tons of plans for Commerce_GC and otherwise accommodating free "Try before you buy" orders as well as rewards for our Kickstarter backers.

I feel like this is a necessary and crucial fix for stores that use coupons and/or Gift Cards, and who don't want to use the Payment suite of modules - so for me this is RTBC. :)

I tested it with no message as well as with a "no payment required" message. I love the flexibility and for us I think our users would rather have the reassurance that their order is covered, so for me that is the sensible default. (Especially since a store owner may not know to change those settings in the pane, and having an empty Payment methods pane isn't exactly useful feedback :)

My only concern might be that it is required to go through the checkout pane/form submit to process this, and due to this requirement, it is not possible to test free orders in the Edit Order area with the "Simulate checkout" feature. But that is possibly just a nitpick that can be fixed later on - this is a perfect start.

Thanks for this!

rszrama’s picture

Ok, great. I'm planning a 1.10 release ASAP, so I'll give this one final read and get it in tomorrow. : )

rszrama’s picture

Status: Reviewed & tested by the community » Fixed

Alrighty, just committed this, and based on your feedback I made the default behavior to be to use the "payment not required" message.

  • rszrama committed a900041 on 7.x-1.x
    Issue #2223171 by rszrama: include an option to display a message for...
torgospizza’s picture

So cool. Thanks, Ryan!

Status: Fixed » Closed (fixed)

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

markbannister’s picture

Looks great, found the settings, but never seen the message. Do I need to make a rule change?
Create order. Used a coupon to reduce to 0 (in checkout pane).
Tried all settings on "Checkout pane behavior when no payment methods are enabled for an order "

Edit:
OK found the note about modifying payment rule so I added the condition
for an "Order balance comparison" > 0, to my active payment rule, which disabled all payment methods -- the message showed up but then I get the errors:

Notice: Undefined index: payment_method in commerce_payment_fields_commerce_payment_pane_checkout_form() (line 26 of ...sites/all/modules/commerce_payment_fields/includes/commerce_payment_fields.checkout_pane.inc).
Notice: Undefined offset: 1 in commerce_payment_fields_commerce_payment_pane_checkout_form() (line 26 of ../sites/all/modules/commerce_payment_fields/includes/commerce_payment_fields.checkout_pane.inc).

torgospizza’s picture

@markbannister: That appears to be an issue with Commerce Payment Fields. I don't have any experience with that module so I can't help you there - you might open up an issue there for that module.

roball’s picture

Thank you for integrating this feature into Drupal Commerce 7.x-1.10. Can confirm it is working fine.

markbannister’s picture

roball
Yes, works great.
Message was from payment fields of course.