when there is only one payment method available, the radio for selection shouldn't appear. functionally it's fine, but doesn't make a lot of sense.

CommentFileSizeAuthor
Screen Shot 2012-11-28 at 7.00.12 PM.png75.86 KBdjdevin

Comments

rszrama’s picture

Category: bug » feature
Status: Active » Postponed (maintainer needs more info)

The problem is not every payment method has "payment details" (such as the credit card form for such payment methods). Without that radio button, there would be no indication at all. I'm open to ideas for what exactly this could look like, but my hunch is this should most likely be solved on a one-off basis when you're doing your theming.

djdevin’s picture

Priority: Normal » Minor

Thanks - that makes sense. Maybe payment modules can flag their methods as such (requiring user input), and then that allows some sort of option in the admin UI to show/hide the label. If I think of something I'll post a patch, for now this is pretty minor.

rszrama’s picture

Ok, great. If you're interested in seeing how I've done this before, I actually do hide the "Credit card" option in some circumstances if configured via the Card on File module.

JulienD’s picture

This can easily be done by attaching a css rules inline or in a dedicated file with a hook_form_alter() to the payment form.

Just below the code to include into a custom module to catch the payment form and to attache it a css rule inline.

/**
 * Implements hook_form_alter().
 *
 * This implementation alters any checkout form looking for the payment pane in
 * order to attache on it css rules if only one payment method is enable.
 */
function custom_module_form_alter(&$form, &$form_state, $form_id) {
  // If the current form ID is for a checkout form...
  if (strpos($form_id, 'commerce_checkout_form_') === 0) {
    // And it specifies a valid checkout page...
    if (commerce_checkout_page_load(substr($form_id, 23))) {
      // And the current page's form includes the payment checkout pane...
      if (!empty($form['commerce_payment'])) {
        // Add css to hide the credit card input if only one payment
        // method is enable.
        if (count($form['commerce_payment']['payment_method']['#options']) == 1) {
          $form['payment_method']['attributes']['#attached']['css'][] = array(
            'type' => 'inline',
            'data' => '#edit-commerce-payment-payment-method input {display: none;}',
          );
        }
      }
    }
  }
}

@rszrama: Do you think that feature need to be ported as a patch for commerce_payment or this should be done by end user during theming ?

shushu’s picture

What about just grab the code and make a minor module out of it ?

rosell.dk’s picture

Here is a much more clean way:

function yourmodulename_form_commerce_checkout_form_review_alter(&$form, &$form_state, $form_id) {
$form['commerce_payment']['#access'] = FALSE;
}

I suppose one could make a module out of this. Perhaps with the option to only hide the selector when there is only one payment method.

I'm not confident if the payment selector might be put into another form in checkout settings. Then it might be part of the commerce_checkout_form_checkout_alter instead. Then do this:

function yourmodulename_form_commerce_checkout_form_checkout_alter(&$form, &$form_state, $form_id) {
$form['commerce_payment']['#access'] = FALSE;
}

rszrama’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Closed (outdated)

Closing this out as I wouldn't make such a change in the 1.x branch now but we did fix this in 2.x. : )

thursday_bw’s picture

Closing this out as I wouldn't make such a change in the 1.x branch now but we did fix this in 2.x. : )

Huh?

This clearly is not fixed, I've come to this issue after hours of detective work for an issue on commerce_paypal module: Paypal smart buttons showing on cart page not review or payment page

Expecting a sitebuilder to add CSS to their theme to get a module to work with a single payment gateway out of the box is just not the correct solution here, in my humble opinion, the fact that I spent days pulling my hair out to wind up here on this issue is a testament to that.

"when there is only one payment method available, the radio for selection shouldn't appear." 100% when there is only one payment method available the selection for it should not appear, that's just, is that debatable? how so?

Perhaps in the case of commerce_paypal it is the responsibility of commerce_paypal to take care of this issue? I'm not sure.

What do we do to resolve this issue? should the commerce module hide the payment information panel if only one payment option is available? that's confusing too because it makes the 'payment inforamation' pane being enabled in the checkout flow confusing as heck if it doesnt' actually appear in this context, it would be enabled but not visible.

I think it does make sense that the sitebuilder could hide the payment information panel from the checkout flow via config, doing so causes breakage in the commerce_paypal module, so having said that I am thinking it is commerce_paypal's responsibility to deal with this scenario
but It's worth communicating it.

thursday_bw’s picture