You are here

public function StoreHandler::addStore in Mailchimp E-Commerce 8

@inheritdoc

Overrides StoreHandlerInterface::addStore

File

src/StoreHandler.php, line 36

Class

StoreHandler
Store handler.

Namespace

Drupal\mailchimp_ecommerce

Code

public function addStore($store_id, $store, $platform) {
  try {

    /* @var \Mailchimp\MailchimpEcommerce $mc_ecommerce */
    $mc_ecommerce = mailchimp_get_api_object('MailchimpEcommerce');
    $parameters = [
      'platform' => $platform,
    ];
    $mc_store = $mc_ecommerce
      ->addStore($store_id, $store, $parameters);
    \Drupal::moduleHandler()
      ->invokeAll('mailchimp_ecommerce_add_store', [
      $mc_store,
    ]);
  } catch (\Exception $e) {
    mailchimp_ecommerce_log_error_message('Unable to add a new store: ' . $e
      ->getMessage());
    drupal_set_message($e
      ->getMessage(), 'error');
  }
}