You are here

public function OrderItem::setUnitPrice in Commerce Core 8.2

Sets the order item unit price.

Parameters

\Drupal\commerce_price\Price $unit_price: The order item unit price.

bool $override: Whether the unit price should be overridden.

Return value

$this

Overrides OrderItemInterface::setUnitPrice

File

modules/order/src/Entity/OrderItem.php, line 131

Class

OrderItem
Defines the order item entity class.

Namespace

Drupal\commerce_order\Entity

Code

public function setUnitPrice(Price $unit_price, $override = FALSE) {
  $this
    ->set('unit_price', $unit_price);
  $this
    ->set('overridden_unit_price', $override);
  $this
    ->recalculateTotalPrice();
  return $this;
}