You are here

public function OrderHandler::getOrder in Mailchimp E-Commerce 8

@inheritdoc

Overrides OrderHandlerInterface::getOrder

File

src/OrderHandler.php, line 16

Class

OrderHandler
Order handler.

Namespace

Drupal\mailchimp_ecommerce

Code

public function getOrder($order_id) {
  try {
    $store_id = mailchimp_ecommerce_get_store_id();
    if (empty($store_id)) {
      throw new \Exception('Cannot get an order without a store ID.');
    }

    /* @var \Mailchimp\MailchimpEcommerce $mc_ecommerce */
    $mc_ecommerce = mailchimp_get_api_object('MailchimpEcommerce');
    $order = $mc_ecommerce
      ->getOrder($store_id, $order_id);
    return $order;
  } catch (\Exception $e) {
    mailchimp_ecommerce_log_error_message('Unable to get order: ' . $e
      ->getMessage());
    drupal_set_message($e
      ->getMessage(), 'error');
  }
  return NULL;
}