You are here

public function Shipment::getTotalDeclaredValue in Commerce Shipping 8.2

Gets the total declared value.

Represents the sum of the declared values of all shipment items.

Return value

\Drupal\commerce_price\Price The total declared value.

Overrides ShipmentInterface::getTotalDeclaredValue

File

src/Entity/Shipment.php, line 288

Class

Shipment
Defines the shipment entity class.

Namespace

Drupal\commerce_shipping\Entity

Code

public function getTotalDeclaredValue() {
  $total_declared_value = NULL;
  foreach ($this
    ->getItems() as $item) {
    $declared_value = $item
      ->getDeclaredValue();
    $total_declared_value = $total_declared_value ? $total_declared_value
      ->add($declared_value) : $declared_value;
  }
  return $total_declared_value;
}