You are here

public function PriceTableCommerceProductInlineEntityFormController::defaultFields in Commerce Price Table 7

File

commerce_price_table_ief/includes/commerce_price_table_ief_commerce_product.inline_entity_form.inc, line 11
Customized inline entity form controller, as suggested in the IEF issue http://drupal.org/node/1521274.

Class

PriceTableCommerceProductInlineEntityFormController
@file Customized inline entity form controller, as suggested in the IEF issue http://drupal.org/node/1521274.

Code

public function defaultFields($bundles) {
  $fields = parent::defaultFields($bundles);
  $weight = 0;
  if (isset($fields['commerce_price'])) {
    $weight = isset($fields['commerce_price']['weight']) ? $fields['commerce_price']['weight'] + 1 : 1;
    foreach ($bundles as $bundle) {
      foreach (commerce_price_table_get_field_instance_settings('commerce_product', $bundle) as $setting) {
        if (isset($setting['settings']['commerce_price_table']['hide_default_price']) && $setting['settings']['commerce_price_table']['hide_default_price']) {
          $fields['commerce_price']['visible'] = FALSE;
        }
      }
    }
  }

  // Add a column for the price table
  $fields['field_price_table'] = array(
    'type' => 'field',
    'label' => 'Price Table',
    'formatter' => 'commerce_multiprice_list_ief',
    'settings' => array(),
    'visible' => TRUE,
    'weight' => $weight,
  );
  return $fields;
}