public function OrderItem::getUnitPrice in Commerce Core 8.2
Gets the order item unit price.
Return value
\Drupal\commerce_price\Price|null The order item unit price, or NULL.
Overrides OrderItemInterface::getUnitPrice
2 calls to OrderItem::getUnitPrice()
- OrderItem::getAdjustedUnitPrice in modules/
order/ src/ Entity/ OrderItem.php - Gets the adjusted order item unit price.
- OrderItem::recalculateTotalPrice in modules/
order/ src/ Entity/ OrderItem.php - Recalculates the order item total price.
File
- modules/
order/ src/ Entity/ OrderItem.php, line 122
Class
- OrderItem
- Defines the order item entity class.
Namespace
Drupal\commerce_order\EntityCode
public function getUnitPrice() {
if (!$this
->get('unit_price')
->isEmpty()) {
return $this
->get('unit_price')
->first()
->toPrice();
}
}