diff --git a/uc_product/src/Plugin/views/field/DisplayPrice.php b/uc_product/src/Plugin/views/field/DisplayPrice.php index bd4cf17..6bf12a9 100644 --- a/uc_product/src/Plugin/views/field/DisplayPrice.php +++ b/uc_product/src/Plugin/views/field/DisplayPrice.php @@ -30,16 +30,20 @@ class DisplayPrice extends Price { * {@inheritdoc} */ public function getValue(ResultRow $values, $field = NULL) { + $tax_amount = 0; + $taxes = uc_tax_rate_load(); $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']; + $price = (float) $node->get('price')->first()->getString(); + foreach ($taxes as $tax) { + if ($tax->isIncludedInPrice()) { + $item_tax = $tax->getPlugin()->calculateProductTax($node, NULL); + $tax_amount += (float) $item_tax; + } + } + // Show the price with taxes included. + return $price + $tax_amount; } }