You are here

public function DisplayPrice::getValue in Ubercart 8.4

Gets the value that's supposed to be rendered.

This api exists so that other modules can easy set the values of the field without having the need to change the render method as well.

Parameters

\Drupal\views\ResultRow $values: An object containing all retrieved values.

string $field: Optional name of the field where the value is stored.

Overrides FieldPluginBase::getValue

File

uc_product/src/Plugin/views/field/DisplayPrice.php, line 32

Class

DisplayPrice
Field handler to provide formatted display prices.

Namespace

Drupal\uc_product\Plugin\views\field

Code

public function getValue(ResultRow $values, $field = NULL) {
  $nid = parent::getValue($values, $field);
  if (!is_null($nid)) {

    // @todo Refactor to allow display price to be calculated.
    $node = Node::load($nid);
    return $node->price->value;

    // @todo Refactor so that all variants are loaded at once
    // in the pre_render hook.
    $node = node_view(Node::load($nid), 'teaser');
    return $node['display_price']['#value'];
  }
}