function commerce_flat_rate_menu in Commerce Flat Rate 7
Implements hook_menu().
File
- ./
commerce_flat_rate.module, line 13 - Allows you to define any number of flat rate shipping services for customers to choose during checkout.
Code
function commerce_flat_rate_menu() {
$items = array();
$items['admin/commerce/config/shipping/methods/flat-rate/add'] = array(
'title' => 'Add a flat rate service',
'description' => 'Create a new flat rate shipping service, including a title and base shipping rate.',
'page callback' => 'drupal_goto',
'page arguments' => array(
'admin/commerce/config/shipping/services/flat-rate/add',
),
'access callback' => 'commerce_flat_rate_service_access',
'access arguments' => array(
'create',
),
'type' => MENU_LOCAL_TASK,
'context' => MENU_CONTEXT_INLINE,
'weight' => 8,
);
$items['admin/commerce/config/shipping/services/flat-rate/add'] = array(
'title' => 'Add a flat rate service',
'description' => 'Create a new flat rate shipping service, including a title and base shipping rate.',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'commerce_flat_rate_service_form',
commerce_flat_rate_service_new(),
),
'access callback' => 'commerce_flat_rate_service_access',
'access arguments' => array(
'create',
),
'type' => MENU_LOCAL_ACTION,
'context' => MENU_CONTEXT_PAGE,
'file' => 'includes/commerce_flat_rate.admin.inc',
);
// Get the default flat rate service.
$default_service_name = commerce_flat_rate_get_default_service();
foreach (commerce_shipping_services('flat_rate') as $name => $shipping_service) {
// Convert underscores to hyphens for the menu item argument.
$service_name_arg = 'flat-rate-' . strtr($name, '_', '-');
$items['admin/commerce/config/shipping/services/' . $service_name_arg . '/edit'] = array(
'title' => 'Edit',
'description' => 'Edit the flat rate service.',
'page callback' => 'commerce_flat_rate_service_edit_page',
'page arguments' => array(
$name,
),
'access callback' => 'commerce_flat_rate_service_access',
'access arguments' => array(
'update',
),
'type' => MENU_LOCAL_TASK,
'context' => MENU_CONTEXT_INLINE,
'weight' => 0,
'file' => 'includes/commerce_flat_rate.admin.inc',
);
$items['admin/commerce/config/shipping/services/' . $service_name_arg . '/delete'] = array(
'title' => 'Delete',
'description' => 'Delete the flat rate service.',
'page callback' => 'commerce_flat_rate_service_delete_page',
'page arguments' => array(
$name,
),
'access callback' => 'commerce_flat_rate_service_access',
'access arguments' => array(
'delete',
),
'type' => MENU_LOCAL_TASK,
'context' => MENU_CONTEXT_INLINE,
'weight' => 10,
'file' => 'includes/commerce_flat_rate.admin.inc',
);
// If this is not the default service, define a form menu item to set it.
if ($name != $default_service_name) {
$items['admin/commerce/config/shipping/services/' . $service_name_arg . '/make-default'] = array(
'title' => 'Make default',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'commerce_flat_rate_service_make_default_form',
$name,
),
'access callback' => 'commerce_flat_rate_service_access',
'access arguments' => array(
'update',
),
'type' => MENU_LOCAL_TASK,
'context' => MENU_CONTEXT_INLINE,
'weight' => 20,
'file' => 'includes/commerce_flat_rate.admin.inc',
);
}
else {
$items['admin/commerce/config/shipping/services/' . $service_name_arg . '/unset-default'] = array(
'title' => 'Unset default',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'commerce_flat_rate_service_unset_default_form',
),
'access callback' => 'commerce_flat_rate_service_access',
'access arguments' => array(
'update',
),
'type' => MENU_LOCAL_TASK,
'context' => MENU_CONTEXT_INLINE,
'weight' => 20,
'file' => 'includes/commerce_flat_rate.admin.inc',
);
}
}
return $items;
}