You are here

commerce_price.install in Commerce Core 8.2

Same filename and directory in other branches
  1. 7 modules/price/commerce_price.install

Contains install and update functions for Price.

File

modules/price/commerce_price.install
View source
<?php

/**
 * @file
 * Contains install and update functions for Price.
 */

/**
 * Implements hook_requirements().
 */
function commerce_price_requirements($phase) {
  $requirements = [];
  if ($phase == 'install' || $phase == 'runtime') {
    if (!class_exists('\\CommerceGuys\\Intl\\Currency\\CurrencyRepository')) {
      $requirements['commerce_price_intl'] = [
        'title' => t('Intl library'),
        'description' => t("Commerce Price requires the commerceguys/intl library."),
        'severity' => REQUIREMENT_ERROR,
      ];
    }
  }
  return $requirements;
}

/**
 * Implements hook_install().
 */
function commerce_price_install() {
  if (!\Drupal::isConfigSyncing()) {

    // Import a currency to speed up initial store setup.
    // If no default country is set, import the US Dollar, since it's common.
    $default_country = \Drupal::config('system.date')
      ->get('country.default');
    $default_country = $default_country ?: 'US';
    $currency_importer = \Drupal::service('commerce_price.currency_importer');
    $currency_importer
      ->importByCountry($default_country);
  }
}

Functions