You are here

public function ShippingMethod::getConditions in Commerce Shipping 8.2

Gets the shipping method conditions.

Return value

\Drupal\commerce\Plugin\Commerce\Condition\ConditionInterface[] The shipping method conditions.

Overrides ShippingMethodInterface::getConditions

1 call to ShippingMethod::getConditions()
ShippingMethod::applies in src/Entity/ShippingMethod.php
Checks whether the shipping method applies to the given shipment.

File

src/Entity/ShippingMethod.php, line 147

Class

ShippingMethod
Defines the shipping method entity class.

Namespace

Drupal\commerce_shipping\Entity

Code

public function getConditions() {
  $conditions = [];
  foreach ($this
    ->get('conditions') as $field_item) {

    /** @var \Drupal\commerce\Plugin\Field\FieldType\PluginItemInterface $field_item */
    $condition = $field_item
      ->getTargetInstance();
    if ($condition instanceof ParentEntityAwareInterface) {
      $condition
        ->setParentEntity($this);
    }
    $conditions[] = $condition;
  }
  return $conditions;
}