You are here

function _commerce_shipping_default_rules_reset in Commerce Shipping 7.2

Resets default Rules if necessary when modules are enabled or disabled.

Parameters

array $modules: An array of module names that have been enabled or disabled.

1 call to _commerce_shipping_default_rules_reset()
commerce_shipping_modules_enabled in ./commerce_shipping.module
Implements hook_modules_enabled().

File

./commerce_shipping.module, line 161
Defines a system for calculating shipping costs associated with an order.

Code

function _commerce_shipping_default_rules_reset($modules) {
  $reset_default_rules = FALSE;

  // Look for any module defining a new shipping method or service.
  foreach ($modules as $module) {
    if (function_exists($module . '_commerce_shipping_method_info') || function_exists($module . '_commerce_shipping_service_info')) {
      $reset_default_rules = TRUE;
    }
  }

  // If we found a module defining a new shipping method or service, we need to
  // rebuild the default Rules especially for this module so the default rules
  // and components will appear properly for this module.
  if ($reset_default_rules) {
    entity_defaults_rebuild();
    rules_clear_cache(TRUE);
    variable_set('menu_rebuild_needed', TRUE);
  }
}