You are here

protected function Donation::getOrderItem in Commerce Donate 8

Gets the donation order item.

If one isn't found, it will be created.

Return value

\Drupal\commerce_order\Entity\OrderItemInterface The donation order item.

4 calls to Donation::getOrderItem()
Donation::buildPaneForm in src/Plugin/Commerce/CheckoutPane/Donation.php
Builds the pane form.
Donation::buildPaneSummary in src/Plugin/Commerce/CheckoutPane/Donation.php
Builds a summary of the pane values.
Donation::isVisible in src/Plugin/Commerce/CheckoutPane/Donation.php
Determines whether the pane is visible.
Donation::submitPaneForm in src/Plugin/Commerce/CheckoutPane/Donation.php
Handles the submission of an pane form.

File

src/Plugin/Commerce/CheckoutPane/Donation.php, line 177

Class

Donation
Provides the donation pane.

Namespace

Drupal\commerce_donate\Plugin\Commerce\CheckoutPane

Code

protected function getOrderItem() {
  $donation_order_item = NULL;

  // Try to find an existing order item.
  foreach ($this->order
    ->getItems() as $order_item) {
    if ($order_item
      ->bundle() == 'donation') {
      $donation_order_item = $order_item;
      break;
    }
  }
  return $donation_order_item;
}