function commerce_price_table_entity_view_alter in Commerce Price Table 7
Implements hook_entity_view_alter().
File
- ./
commerce_price_table.module, line 557
Code
function commerce_price_table_entity_view_alter(&$build, $type) {
// Check if there is a product reference field in the node.
$found_product_reference = FALSE;
$fields = commerce_info_fields('commerce_product_reference', $type);
foreach ($fields as $field) {
if (isset($build[$field['field_name']])) {
$found_product_reference = TRUE;
}
}
// If there is one, we check if the setting for hiding the default price is
// enabled.
if ($found_product_reference || !empty($build['product:commerce_price'])) {
$access = TRUE;
foreach (commerce_price_table_get_field_instance_settings($type, $build['#bundle']) as $setting) {
if (isset($setting['settings']['commerce_price_table']['hide_default_price']) && $setting['settings']['commerce_price_table']['hide_default_price'] == TRUE) {
$access = FALSE;
}
}
$build['product:commerce_price']['#access'] = $access;
}
}