protected function OrderItem::recalculateTotalPrice in Commerce Core 8.2
Recalculates the order item total price.
3 calls to OrderItem::recalculateTotalPrice()
- OrderItem::preSave in modules/
order/ src/ Entity/ OrderItem.php - Acts on an entity before the presave hook is invoked.
- OrderItem::setQuantity in modules/
order/ src/ Entity/ OrderItem.php - Sets the order item quantity.
- OrderItem::setUnitPrice in modules/
order/ src/ Entity/ OrderItem.php - Sets the order item unit price.
File
- modules/
order/ src/ Entity/ OrderItem.php, line 358
Class
- OrderItem
- Defines the order item entity class.
Namespace
Drupal\commerce_order\EntityCode
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);
}
}