You are here

function commerce_shipping_methods in Commerce Shipping 7.2

Returns an array of shipping methods defined by enabled modules.

Return value

array An associative array of shipping method arrays keyed by the method_id.

6 calls to commerce_shipping_methods()
commerce_shipping_default_rules_configuration in ./commerce_shipping.rules_defaults.inc
Implements hook_default_rules_configuration().
commerce_shipping_method_get_title in ./commerce_shipping.module
Returns the human readable title of any or all shipping methods.
commerce_shipping_method_load in ./commerce_shipping.module
Returns a shipping method array.
commerce_shipping_rules_action_info in ./commerce_shipping.rules.inc
Implements hook_rules_action_info().
commerce_shipping_ui_menu in ./commerce_shipping_ui.module
Implements hook_menu().

... See full list

1 string reference to 'commerce_shipping_methods'
commerce_shipping_methods_reset in ./commerce_shipping.module
Resets the cached list of shipping methods.

File

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

Code

function commerce_shipping_methods() {
  $shipping_methods =& drupal_static(__FUNCTION__);

  // If the shipping methods haven't been defined yet, do so now.
  if (!isset($shipping_methods)) {
    $shipping_methods = array();

    // Build the shipping methods array, including module names for the purpose
    // of including files if necessary.
    foreach (module_implements('commerce_shipping_method_info') as $module) {
      foreach (module_invoke($module, 'commerce_shipping_method_info') as $name => $shipping_method) {
        $shipping_method['name'] = $name;
        $shipping_method['module'] = $module;
        $shipping_methods[$name] = $shipping_method;
      }
    }
    drupal_alter('commerce_shipping_method_info', $shipping_methods);
    foreach ($shipping_methods as $name => &$shipping_method) {
      $defaults = array(
        'name' => $name,
        'display_title' => $shipping_method['title'],
        'description' => '',
        'active' => TRUE,
      );
      $shipping_method += $defaults;
    }
  }
  return $shipping_methods;
}