You are here

protected function CartBlockBase::getTotalText in Commerce Cart Blocks 8

Gets the total price as a formatted string.

Return value

mixed|null

2 calls to CartBlockBase::getTotalText()
CartBlock::buildHeading in src/Plugin/Block/CartBlock.php
CartButtonBlock::getButtonLabel in src/Plugin/Block/CartButtonBlock.php
Gets the text representation of the count of items.

File

src/Plugin/Block/CartBlockBase.php, line 264

Class

CartBlockBase
CartBlockBase class.

Namespace

Drupal\commerce_cart_blocks\Plugin\Block

Code

protected function getTotalText() {
  $element = [];
  $element['price'] = [
    '#type' => 'inline_template',
    '#template' => '{{ price|commerce_price_format }}',
    '#context' => [
      'price' => $this
        ->getTotal(),
    ],
  ];
  return \Drupal::service('renderer')
    ->renderPlain($element);
}