function commerce_gc_line_item_configuration in Commerce GC 7
File
- ./
commerce_gc.module, line 471 - Provides Giftcard coupon bundle, Giftcard Transaction entity and basic user interface elements.
Code
function commerce_gc_line_item_configuration() {
field_info_cache_clear();
$fields = field_info_fields();
$instances = field_info_instances();
/*
* Line item: giftcard reference
*/
if (empty($fields['commerce_giftcard'])) {
// Create giftcard reference field
$field = array(
'settings' => array(
'target_type' => 'commerce_coupon',
'handler' => 'base',
'handler_settings' => array(
'target_bundles' => array(
'product_display' => 'giftcard_coupon',
),
),
),
'field_name' => 'commerce_giftcard',
'type' => 'entityreference',
'locked' => TRUE,
'cardinality' => '1',
);
field_create_field($field);
}
if (empty($instances['commerce_line_item']['giftcard_use']['commerce_giftcard'])) {
$instance = array(
'label' => t('Giftcard'),
'widget' => array(
'type' => 'entityreference_autocomplete',
'weight' => '9',
'settings' => array(
'match_operator' => 'CONTAINS',
'size' => 60,
'path' => '',
),
),
'field_name' => 'commerce_giftcard',
'entity_type' => 'commerce_line_item',
'bundle' => 'giftcard_use',
'default_value' => NULL,
);
field_create_instance($instance);
}
}