You are here

function commerce_free_shipping_menu in Commerce Free Shipping 7

Implements hook_menu().

File

./commerce_free_shipping.module, line 12
Implements hook_commerce_shipping_service_info_alter() to change the price of the shipping service, when it's needed.

Code

function commerce_free_shipping_menu() {
  $items['admin/commerce/config/free-shipping'] = array(
    'title' => 'Free Shipping',
    'description' => 'Manage free shipping.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'commerce_free_shipping_admin_form',
    ),
    'access arguments' => array(
      'administer shipping',
    ),
    'file' => 'commerce_free_shipping.admin.inc',
  );

  // Loop over every shipping method and define a rule to collect rates for
  // shipping services assigned to that method.
  $shipping_services = commerce_shipping_services();
  foreach ($shipping_services as $service) {
    $base = $service['base'];

    // Check if free shipping is enabled for this services.
    if (variable_get($base . '_free_shipping_additionnal_rules', FALSE)) {
      $items['admin/commerce/config/free-shipping/' . $base] = array(
        'title' => 'Free Shipping rules conditions for ' . $service['display_title'],
        'description' => 'Manage free shipping rules conditions.',
        'page callback' => 'drupal_get_form',
        'page arguments' => array(
          'commerce_free_shipping_rules_admin_form',
        ),
        'access arguments' => array(
          'administer shipping',
        ),
        'file' => 'commerce_free_shipping.admin.inc',
      );

      // Add the menu items for the various Rules forms.
      $controller = new RulesUIController();
      $items += $controller
        ->config_menu('admin/commerce/config/free-shipping/' . $base);
    }
  }
  return $items;
}