You are here

public function MailchimpEcommerce::addOrder in Mailchimp 8

Same name in this branch
  1. 8 lib/mailchimp-api-php/src/MailchimpEcommerce.php \Mailchimp\MailchimpEcommerce::addOrder()
  2. 8 lib/mailchimp-api-php/tests/src/MailchimpEcommerce.php \Mailchimp\Tests\MailchimpEcommerce::addOrder()

@inheritdoc

Overrides MailchimpEcommerce::addOrder

File

lib/mailchimp-api-php/tests/src/MailchimpEcommerce.php, line 115

Class

MailchimpEcommerce
Mailchimp Ecommerce library test cases.

Namespace

Mailchimp\Tests

Code

public function addOrder($store_id, $id, array $customer, array $order, $batch = FALSE) {
  parent::addOrder($store_id, $id, $customer, $order, $batch);
  if (empty($store_id)) {
    throw new MailchimpAPIException('Store ID cannot be empty.');
  }
  if (empty($id)) {
    throw new MailchimpAPIException('Order ID cannot be empty.');
  }
  if (empty($customer)) {
    throw new MailchimpAPIException('Customer cannot be empty.');
  }
  if (empty($order)) {
    throw new MailchimpAPIException('Order cannot be empty.');
  }
  if (!isset($order['lines']) || empty($order['lines'])) {
    throw new MailchimpAPIException('Order must contain at least one line item.');
  }
  if (!isset($this->orders[$store_id])) {
    $this->orders[$store_id] = [];
  }
  $parameters = [
    'id' => $id,
    'customer' => (object) $customer,
  ];
  $parameters += $order;
  $this->orders[$store_id][$id] = (object) $parameters;
}