You are here

function uc_store_install in Ubercart 8.4

Same name and namespace in other branches
  1. 5 uc_store/uc_store.install \uc_store_install()
  2. 6.2 uc_store/uc_store.install \uc_store_install()
  3. 7.3 uc_store/uc_store.install \uc_store_install()

Implements hook_install().

File

uc_store/uc_store.install, line 40
Install, update, and uninstall functions for the uc_store module.

Code

function uc_store_install() {

  // If store country isn't set in the the store configuration,
  // use the site default country as the store default.
  $store_config = \Drupal::configFactory()
    ->getEditable('uc_store.settings');
  $store_country = $store_config
    ->get('address.country');
  if (!$store_country) {
    $site_country = \Drupal::config('system.date')
      ->get('country.default');
    $store_config
      ->set('address.country', $site_country)
      ->save();

    // Site country was already enabled in uc_country_install(), which was
    // invoked before uc_store_install().
  }
  else {

    // Ensure store country is enabled.
    Country::load($store_country)
      ->enable()
      ->save();
  }

  // Set mail handler for all Ubercart modules.
  $mail_config = \Drupal::configFactory()
    ->getEditable('system.mail');
  $mail_config
    ->set('interface.uc_cart', 'ubercart_mail')
    ->set('interface.uc_order', 'ubercart_mail')
    ->set('interface.uc_file', 'ubercart_mail')
    ->set('interface.uc_role', 'ubercart_mail')
    ->set('interface.uc_stock', 'ubercart_mail')
    ->set('interface.uc_store', 'ubercart_mail')
    ->save();
}