Currently, payment methods in checkout pages aren't sorted in any particular way, I think we should respect the rules weight settings for payment rules.
I'm doing a pull request for this.

Comments

pcambra’s picture

Status: Active » Needs review

Here is the pull request
https://github.com/pcambra/drupalcommerce/commit/1ae0361993b73e2bb85c188...

If you commit this after the payment_methods to array one (#1044132: Convert commerce_payment_method_info to array), code in commerce_payment.checkout_pane.inc should be this one:

  $payment_methods = $order->payment_methods;
  // Sort the payment methods by their weight value.
  uasort($payment_methods, 'drupal_sort_weight');

  foreach ($payment_methods as $instance_id => $method_info) {
rszrama’s picture

Status: Needs review » Needs work

I don't understand why you copied the array to the $payment_methods variable instead of just using uasort() on $order->payment_methods directly. Also, if we're going to do a uasort(), we'll want to make sure the payment methods array is actually an array prior to passing it to the sort function (i.e. we can ditch the array casting that exists in the current pull request).

rszrama’s picture

Also, you won't need a separate pull request. If there's some rationale I'm missing, I can pull and tweak the array as is... otherwise I'll pull and revert the variable to sort the $order->payment_methods directly. Just want to make sure I'm not missing something with your variable assignment.

rszrama’s picture

Status: Needs work » Fixed

Alrighty, based on pcambra's feedback in IRC and my tests, I've simplified the patch to two minor changes:

https://github.com/rszrama/drupalcommerce/commit/220d2a00a35db0f19d1618e...

Status: Fixed » Closed (fixed)

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