You are here

function mailchimp_ecommerce_get_customer in Mailchimp E-Commerce 7

Read a customer from Mailchimp.

Parameters

string $customer_id: Unique id of customer.

Return value

object Mailchimp customer object.

8 calls to mailchimp_ecommerce_get_customer()
mailchimp_ecommerce_add_order in ./mailchimp_ecommerce.module
Adds a new order to the current Mailchimp store.
mailchimp_ecommerce_commerce_batch_add_orders in modules/mailchimp_ecommerce_commerce/mailchimp_ecommerce_commerce.module
Batch callback used to add orders to MailChimp.
mailchimp_ecommerce_commerce_commerce_customer_profile_insert in modules/mailchimp_ecommerce_commerce/mailchimp_ecommerce_commerce.module
Implements hook_commerce_customer_profile_insert().
mailchimp_ecommerce_commerce_commerce_customer_profile_update in modules/mailchimp_ecommerce_commerce/mailchimp_ecommerce_commerce.module
Implements hook_commerce_customer_profile_update().
mailchimp_ecommerce_delete_order in ./mailchimp_ecommerce.module
Deletes an Order from the current Mailchimp store.

... See full list

File

./mailchimp_ecommerce.module, line 322
Mailchimp eCommerce core functionality.

Code

function mailchimp_ecommerce_get_customer($customer_id) {
  $customer = NULL;
  try {
    $store_id = mailchimp_ecommerce_get_store_id();
    if (empty($store_id)) {
      throw new Exception('Cannot get a customer without a store ID.');
    }

    /* @var \Mailchimp\MailchimpEcommerce $mc_ecommerce */
    $mc_ecommerce = mailchimp_get_api_object('MailchimpEcommerce');
    $customer = $mc_ecommerce
      ->getCustomer($store_id, $customer_id);
  } catch (Exception $e) {
    if ($e
      ->getCode() == 404) {

      // Customer doesn't exist in the store; no need to log an error.
    }
    else {
      mailchimp_ecommerce_log_error_message('Unable to get a customer: ' . $e
        ->getMessage());
      mailchimp_ecommerce_show_error($e
        ->getMessage());
    }
  }
  return $customer;
}