You are here

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

@inheritdoc

Overrides OrderHandlerInterface::buildProduct

File

src/OrderHandler.php, line 131

Class

OrderHandler
Order handler.

Namespace

Drupal\mailchimp_ecommerce

Code

public function buildProduct(OrderItem $order_item) {
  $product = [
    'id' => $order_item
      ->id(),
    'product_id' => $order_item
      ->getPurchasedEntity()
      ->getProductId(),
    // TODO: Figure out how to differentiate between product and variant ID here.
    'product_variant_id' => $order_item
      ->getPurchasedEntityId(),
    'quantity' => (int) $order_item
      ->getQuantity(),
    'price' => $order_item
      ->getUnitPrice()
      ->getNumber(),
  ];
  return $product;
}