Commit 35f5b24d authored by bojanz's avatar bojanz

Merge pull request #217 from dwkitchen/price_views

Add hook_field_views_data() to Commerce Price so amount and currency_…
parents f11cb9ea d813c926
<?php
/**
* @file
* Provide Views data for the Commerce Price module.
*
* @ingroup views_module_handlers
*/
use Drupal\field\FieldStorageConfigInterface;
/**
* Implements hook_field_views_data().
*
* Views integration for price fields.
*/
function commerce_price_field_views_data(FieldStorageConfigInterface $field_storage) {
$data = views_field_default_views_data($field_storage);
$field_name = $field_storage->getName();
foreach ($data as $table_name => $table_data) {
$data[$table_name][$field_name . '_amount']['field'] = [
'id' => 'numeric',
'field_name' => $table_data[$field_name]['field']['field_name'],
'entity_type' => $table_data[$field_name]['field']['entity_type'],
'label' => t('amount from !field_name', array('!field_name' => $field_name)),
];
$data[$table_name][$field_name . '_currency_code']['field'] = [
'id' => 'standard',
'field_name' => $table_data[$field_name]['field']['field_name'],
'entity_type' => $table_data[$field_name]['field']['entity_type'],
'label' => t('currency from !field_name', array('!field_name' => $field_name)),
];
}
return $data;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment