Drupal Commerce - "Select a product" element: How to change the select list to radio buttons
Here is the code that changes the default select list of "Select a product" element of Drupal Commerce to radio buttons, for a standalone product list.
The following goes in a custom module (tested in Drupal 7).
Check this for code for the product select list shown in conjunction with product attributes.
-- UPDATED!! --
Further to Ryan's comment below, here is the updated code where options are sanitized.
( Sanitize = convert to plain text -> remove html / js. Without this, html / js included in product titles will render in product options, posing a security threat.)
$value) {
$form['product_id']['#options'][$key] = check_plain($value);
}
// Change element to #type radios.
$form['product_id']['#type'] = "radios";
}
}
?>
Further discussion takes place here.