You are here

protected function BundleItemOrderItem::recalculateTotalPrice in Commerce Product Bundle 8

Recalculates the bundle item order item total price.

2 calls to BundleItemOrderItem::recalculateTotalPrice()
BundleItemOrderItem::preSave in src/Entity/BundleItemOrderItem.php
Acts on an entity before the presave hook is invoked.
BundleItemOrderItem::setUnitPrice in src/Entity/BundleItemOrderItem.php
Sets the order item unit price.

File

src/Entity/BundleItemOrderItem.php, line 109

Class

BundleItemOrderItem
Defines the Bundle Item Order Item entity.

Namespace

Drupal\commerce_product_bundle\Entity

Code

protected function recalculateTotalPrice() {
  if ($unit_price = $this
    ->getUnitPrice()) {
    $rounder = \Drupal::service('commerce_price.rounder');
    $total_price = $unit_price
      ->multiply($this
      ->getQuantity());
    $this->total_price = $rounder
      ->round($total_price);
  }
}