Hi There -
Have installed userpoints_ubercart and would like userpoints to appear on the checkout pane before credit cards and to default to using userpoints for payment.
Have managed to default to userpoints using hook_form_alter() by using the following:
<?php
case 'uc_cart_checkout_form':
// reorder the payment choices and make dollhouse dollars default
$form['panes']['payment']['payment_method']['#default_value'] = 'points';
?>It works! Yay!
However, when I try to change the weight of the form items, I get an error.
Here's what I'm using:
<?php
$form['panes']['payment']['payment_method']['#default_value']['points']['#weight'] = -10;
$form['panes']['payment']['payment_method']['#default_value']['credit']['#weight'] = 0;
?>I'm using the form_inspect module and what it's telling me is that the payment_method $options is an array with 2 elements: credit and points. When I try to assign weight to these, I get the error -
Fatal error: Cannot use string offset as an array in /Applications/MAMP/htdocs/etc./our_forms_altered.module on line 41Have searched through the userpoints_ubercart module and its includes and think that the aggregation of payment methods is taking place somewhere in hook_payment_method() and that normal hook_form_alter() won't work in this case.
Something tells me I'm not in Kansas anymore with this. I'll take any suggestions.

I was curious why it should cause an error, and really it's because the options in that array don't have a weight. Drupal just renders them in the order they appear in the array. You can rearrange things in that array through various sorts, though I'm curious if you can't just use the payment methods settings form at /admin/store/settings/payment/edit/methods to accomplish what you're looking to do. 