I'm setting up returns on my site, and I found that #return_value is not being set on the return creation form. The result is that Returns are not listing any items in them. Currently I am using the following form_alter as a workaround:

/**
 * Implements hook_form_FORM_ID_alter().
 */

function mymodule_form_commerce_rma_return_form_alter(&$form, &$form_state, $form_id) {
  $form_state['rebuild'] = TRUE;
  foreach($form['commerce_return_line_items'][LANGUAGE_NONE]['line_items'] as $id => $line_item) {
    $form['commerce_return_line_items'][LANGUAGE_NONE]['line_items'][$id]['selected']['#return_value'] = $id;

// Additionally, I was having trouble with default return reason values, but that's for another issue.
    $form['commerce_return_line_items'][LANGUAGE_NONE]['line_items'][$id]['commerce_return_reason']['#default_value'] = intval(variable_get_value('mymodule_default_return_reason'));
    $form['commerce_return_line_items'][LANGUAGE_NONE]['line_items'][$id]['commerce_return_method']['#default_value'] = intval(variable_get_value('mymodule_default_return_method'));
  }
}

I'll get around to making a patch tonight.

Comments

laboratory.mike created an issue. See original summary.

laboratory.mike’s picture

Component: Code » Documentation
Category: Bug report » Task
Priority: Major » Minor

OK, I've figured it out.

It turns out that the module works as designed, and is fine. It turns out that I was confused about how the "remove" check boxes work. They have the reverse function of what I expected: I thought you had to check to INCLUDE the line item, whereas the check boxes EXCLUDE items from being included in the return.

I'm going to change the direction of the patch I need to make - I think that if we have zero items because all were excluded, the module should show a message saying such, in case the person submitting the return is confused. Also, I will add a little documentation if needed.