You are here

public function ShippingInformation::isVisible in Commerce Shipping 8.2

Determines whether the pane is visible.

Return value

bool TRUE if the pane is visible, FALSE otherwise.

Overrides CheckoutPaneBase::isVisible

1 call to ShippingInformation::isVisible()
ShippingInformation::buildPaneSummary in src/Plugin/Commerce/CheckoutPane/ShippingInformation.php
Builds a summary of the pane values.

File

src/Plugin/Commerce/CheckoutPane/ShippingInformation.php, line 184

Class

ShippingInformation
Provides the shipping information pane.

Namespace

Drupal\commerce_shipping\Plugin\Commerce\CheckoutPane

Code

public function isVisible() {
  if (!$this->order
    ->hasField('shipments')) {
    return FALSE;
  }

  // The order must contain at least one shippable purchasable entity.
  foreach ($this->order
    ->getItems() as $order_item) {
    $purchased_entity = $order_item
      ->getPurchasedEntity();
    if ($purchased_entity && $purchased_entity
      ->hasField('weight')) {
      return TRUE;
    }
  }
  return FALSE;
}