You are here

public function OrderReport::generateReports in Commerce Reporting 8

Generates order reports for an order.

Parameters

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

Overrides ReportTypeInterface::generateReports

File

src/Plugin/Commerce/ReportType/OrderReport.php, line 57

Class

OrderReport
Provides the basic Order Report.

Namespace

Drupal\commerce_reports\Plugin\Commerce\ReportType

Code

public function generateReports(OrderInterface $order) {
  $billing_profile = $order
    ->getBillingProfile();

  /** @var \Drupal\address\Plugin\Field\FieldType\AddressItem $address */
  $address = $billing_profile
    ->get('address')
    ->first();
  $values = [
    'order_type_id' => $order
      ->bundle(),
    'amount' => $order
      ->getTotalPrice(),
    'mail' => $order
      ->getEmail(),
    'billing_address' => $address
      ->toArray(),
  ];
  $this
    ->createFromOrder($order, $values);
}