View source
<?php
function commerce_price_table_ief_entity_info_alter(&$entity_info) {
if (isset($entity_info['commerce_product'])) {
$entity_info['commerce_product']['inline entity form'] = array(
'controller' => 'PriceTableCommerceProductInlineEntityFormController',
);
$entity_info['commerce_product']['view modes']['inline_entity_form'] = array(
'label' => t('Inline Entity Form'),
'custom settings' => TRUE,
);
}
}
function commerce_price_table_ief_field_formatter_info() {
return array(
'commerce_multiprice_list_ief' => array(
'label' => t('Price list (for inline entity form)'),
'field types' => array(
'commerce_price_table',
),
'settings' => array(
'calculation' => FALSE,
),
),
);
}
function commerce_price_table_ief_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$element = array();
if ($display['type'] == 'commerce_multiprice_list_ief' && !empty($items)) {
uasort($items, 'commerce_price_table_sort_by_qty');
$list_items = array();
foreach ($items as $delta => $item) {
if (isset($item['min_qty']) && $item['amount']) {
$header = commerce_price_table_display_quantity_headers($item);
$price = commerce_currency_format($item['amount'], $item['currency_code'], $entity);
$list_items[] = "{$price} ({$header})";
}
}
$element[] = array(
'#markup' => theme('item_list', array(
'items' => $list_items,
)),
);
}
return $element;
}
function commerce_price_table_ief_inline_entity_form_entity_form_alter(&$entity_form, $form_state) {
commerce_price_table_form_commerce_product_ui_product_form_alter($entity_form, $form_state, 'commerce_product_ui_product_form');
}