function commerce_gc_product_line_item_add_form in Commerce GC 7
1 string reference to 'commerce_gc_product_line_item_add_form'
- commerce_gc_product_commerce_line_item_type_info_alter in modules/
commerce_gc_product/ commerce_gc_product.module
File
- modules/
commerce_gc_product/ commerce_gc_product.module, line 80 - Provides Giftcard product type and support.
Code
function commerce_gc_product_line_item_add_form($element, &$form_state) {
$form['sku'] = array(
'#type' => 'textfield',
'#title' => t('Giftcard product SKU'),
'#description' => t('Enter the SKU of the giftcard product to add to the order.'),
'#autocomplete_path' => 'commerce_gc_product/autocomplete/line_item_gc_product_selector',
'#size' => 60,
'#maxlength' => 255,
);
$form['line_item_fields'] = array(
'#type' => 'container',
'#parents' => array(
'commerce_line_items',
LANGUAGE_NONE,
'actions',
),
);
// Attach fields
$line_item_type = $element['actions']['line_item_type']['#value']['type'];
$line_item = commerce_line_item_new($line_item_type);
field_attach_form('commerce_line_item', $line_item, $form['line_item_fields'], $form_state);
// Hide certain fields
$hide = array(
'commerce_product',
'commerce_display_path',
'commerce_unit_price',
'commerce_giftcards',
);
foreach ($hide as $field) {
$form['line_item_fields'][$field]['#access'] = 0;
}
// Store the new line item in the form so it can be accessed easily.
$form_state['line_item'] = $line_item;
return $form;
}