You are here

function mailchimp_ecommerce_admin_settings_submit in Mailchimp E-Commerce 7

Submit handler for the Mailchimp eCommerce form.

1 string reference to 'mailchimp_ecommerce_admin_settings_submit'
mailchimp_ecommerce_admin_settings in includes/mailchimp_ecommerce.admin.inc
The Mailchimp eCommerce settings form.

File

includes/mailchimp_ecommerce.admin.inc, line 205
Administration forms for Mailchimp eCommerce.

Code

function mailchimp_ecommerce_admin_settings_submit($form, &$form_state) {
  $store_id = variable_get('mailchimp_ecommerce_store_id', NULL);
  if (variable_get('mailchimp_ecommerce_store_id', NULL) == NULL) {
    $store_id = mailchimp_ecommerce_generate_store_id();
    variable_set('mailchimp_ecommerce_store_id', $store_id);
  }
  if ($store_id != NULL) {
    $currency = $form_state['values']['mailchimp_ecommerce_currency'];

    // Determine if a store is being created or updated.
    $existing_store = mailchimp_ecommerce_get_store($store_id);
    $platform = !empty($form_state['values']['platform']) ? $form_state['values']['platform'] : '';
    if (empty($existing_store)) {
      $store = [
        'list_id' => isset($form_state['values']['mailchimp_ecommerce_list_id']) ? $form_state['values']['mailchimp_ecommerce_list_id'] : variable_get('mailchimp_ecommerce_list_id'),
        'name' => $form_state['values']['mailchimp_ecommerce_store_name'],
        'currency_code' => $currency,
        'domain' => check_plain($form_state['values']['mailchimp_ecommerce_store_domain']),
      ];
      mailchimp_ecommerce_add_store($store_id, $store, $platform);
    }
    else {
      mailchimp_ecommerce_update_store($store_id, $form_state['values']['mailchimp_ecommerce_store_name'], $currency, $platform);
    }
  }
}