Add to cart formatter settings form incorrectly sets "line_item_type" to 0 when only 1 line item type.
In the code below from commerce_cart_field_formatter_settings_form() line 2327:
The commerce_product_line_item_types() returns an array of line items type names numerically keyed. If there is only 1 line item type, the setting value is set to 0.
$types = commerce_product_line_item_types();
if (count($types) > 1) {
$element['line_item_type'] = array(
'#type' => 'select',
'#title' => t('Add to Cart line item type'),
'#options' => array_intersect_key(commerce_line_item_type_get_name(), drupal_map_assoc($types)),
'#default_value' => $settings['line_item_type'],
);
}
else {
$element['line_item_type'] = array(
'#type' => 'hidden',
'#value' => key($types),
);
}
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | commerce-cart-formatter-default-line-type-2156205-1.patch | 473 bytes | recrit |
Comments
Comment #1
recrit commentedThe attached patch changes it to use
resetinstead ofkey.Comment #2
rszrama commentedGood catch! Looks like it's only worked thanks to a fluke re: empty() an an affordance to ensure the new setting worked when added to existing sites. : P
Committed.
Comment #5
rszrama commented