function commerce_license_form_commerce_cart_add_to_cart_form_alter in Commerce License 7
Implements hook_form_FORM_ID_alter().
Prevents the combining of license line items on the Add to Cart form. Prevents the changing of the quantity.
File
- ./
commerce_license.module, line 752 - Provides a framework for selling access to local or remote resources.
Code
function commerce_license_form_commerce_cart_add_to_cart_form_alter(&$form, &$form_state) {
$licensable_line_item_type = in_array($form_state['line_item']->type, commerce_license_line_item_types());
$has_enabled_products = isset($form_state['default_product']);
if ($licensable_line_item_type && $has_enabled_products) {
// Check whether the product is licensable, since the line item might be
// able to hold both licensable and non-licensable products.
if (in_array($form_state['default_product']->type, commerce_license_product_types())) {
$form_state['line_item']->data['context']['add_to_cart_combine'] = FALSE;
$form['quantity']['#access'] = FALSE;
}
}
}