You are here

protected function OnsiteBase::getLineItems in Commerce Authorize.Net 8

Gets the line items from order.

Parameters

\Drupal\commerce_order\Entity\OrderInterface $order: The order.

Return value

\CommerceGuys\AuthNet\DataTypes\LineItem[] An array of line items.

1 call to OnsiteBase::getLineItems()
Echeck::createPayment in src/Plugin/Commerce/PaymentGateway/Echeck.php
Creates a payment.
1 method overrides OnsiteBase::getLineItems()
AcceptJs::getLineItems in src/Plugin/Commerce/PaymentGateway/AcceptJs.php
Gets the line items from order.

File

src/Plugin/Commerce/PaymentGateway/OnsiteBase.php, line 372

Class

OnsiteBase
Provides the Authorize.net payment gateway base class.

Namespace

Drupal\commerce_authnet\Plugin\Commerce\PaymentGateway

Code

protected function getLineItems(OrderInterface $order) {
  $line_items = [];
  foreach ($order
    ->getItems() as $order_item) {
    $name = $order_item
      ->label();
    $name = strlen($name) > 31 ? substr($name, 0, 28) . '...' : $name;
    $line_items[] = new LineItem([
      'itemId' => $order_item
        ->id(),
      'name' => $name,
      'quantity' => $order_item
        ->getQuantity(),
      'unitPrice' => $order_item
        ->getUnitPrice()
        ->getNumber(),
    ]);
  }
  return $line_items;
}