function commerce_tax_ui_menu in Commerce Core 7
Implements hook_menu().
File
- modules/
tax/ commerce_tax_ui.module, line 12 - Provides a UI for creating simple tax types and rates.
Code
function commerce_tax_ui_menu() {
$items = array();
$items['admin/commerce/config/taxes'] = array(
'title' => 'Taxes',
'description' => 'Manage tax rates and types.',
'page callback' => 'commerce_tax_ui_overview',
'page arguments' => array(
'rates',
),
'access arguments' => array(
'administer taxes',
),
'file' => 'includes/commerce_tax_ui.admin.inc',
);
$items['admin/commerce/config/taxes/rates'] = array(
'title' => 'Tax rates',
'description' => 'Manage tax rates.',
'weight' => 0,
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['admin/commerce/config/taxes/rates/add'] = array(
'title' => 'Add a tax rate',
'description' => 'Create a new tax rate.',
'page callback' => 'commerce_tax_ui_tax_rate_add_form_wrapper',
'page arguments' => array(
commerce_tax_ui_tax_rate_new(),
),
'access arguments' => array(
'administer taxes',
),
'type' => MENU_LOCAL_ACTION,
'file' => 'includes/commerce_tax_ui.admin.inc',
);
foreach (commerce_tax_rates() as $name => $tax_rate) {
// Convert underscores to hyphens for the menu item argument.
$name_arg = strtr($name, '_', '-');
if ($tax_rate['module'] == 'commerce_tax_ui') {
$items['admin/commerce/config/taxes/rates/' . $name_arg] = array(
'title callback' => 'commerce_tax_ui_tax_rate_title',
'title arguments' => array(
$name,
),
'description' => 'Edit a tax rate.',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'commerce_tax_ui_tax_rate_form',
$tax_rate,
),
'access arguments' => array(
'administer taxes',
),
'file' => 'includes/commerce_tax_ui.admin.inc',
);
$items['admin/commerce/config/taxes/rates/' . $name_arg . '/edit'] = array(
'title' => 'Edit',
'type' => MENU_DEFAULT_LOCAL_TASK,
'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
'weight' => 0,
);
$items['admin/commerce/config/taxes/rates/' . $name_arg . '/delete'] = array(
'title' => 'Delete',
'page arguments' => array(
'commerce_tax_ui_tax_rate_delete_form',
$tax_rate,
),
'access arguments' => array(
'administer taxes',
),
'file' => 'includes/commerce_tax_ui.admin.inc',
'type' => MENU_LOCAL_TASK,
'context' => MENU_CONTEXT_INLINE,
'weight' => 10,
);
}
else {
$items['admin/commerce/config/taxes/rates/' . $name_arg] = array(
'title callback' => 'commerce_tax_ui_tax_rate_title',
'title arguments' => array(
$name,
),
'description' => 'Redirect to the tax rate list.',
'page callback' => 'drupal_goto',
'page arguments' => array(
'admin/commerce/config/taxes/rates',
),
'access arguments' => array(
'administer taxes',
),
);
}
if (rules_config_load($tax_rate['rules_component'])) {
$items['admin/commerce/config/taxes/rates/' . $name_arg . '/component'] = array(
'title' => 'Configure component',
'description' => 'Add conditions to the Rules component used to apply this tax to products.',
'page callback' => 'drupal_goto',
'page arguments' => array(
'admin/config/workflow/rules/components/manage/' . $tax_rate['rules_component'],
),
'access arguments' => array(
'administer rules',
),
'type' => MENU_LOCAL_TASK,
'context' => MENU_CONTEXT_INLINE,
'weight' => 5,
);
}
}
$items['admin/commerce/config/taxes/types'] = array(
'title' => 'Tax types',
'description' => 'Manage tax types.',
'page callback' => 'commerce_tax_ui_overview',
'page arguments' => array(
'types',
),
'access arguments' => array(
'administer taxes',
),
'weight' => 5,
'type' => MENU_LOCAL_TASK,
'file' => 'includes/commerce_tax_ui.admin.inc',
);
$items['admin/commerce/config/taxes/types/add'] = array(
'title' => 'Add a tax type',
'description' => 'Create a new tax type.',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'commerce_tax_ui_tax_type_form',
commerce_tax_ui_tax_type_new(),
),
'access arguments' => array(
'administer taxes',
),
'type' => MENU_LOCAL_ACTION,
'file' => 'includes/commerce_tax_ui.admin.inc',
);
foreach (commerce_tax_types() as $name => $tax_type) {
// Convert underscores to hyphens for the menu item argument.
$name_arg = strtr($name, '_', '-');
if ($tax_type['module'] == 'commerce_tax_ui') {
$items['admin/commerce/config/taxes/types/' . $name_arg] = array(
'title callback' => 'commerce_tax_ui_tax_type_title',
'title arguments' => array(
$name,
),
'description' => 'Edit a tax type.',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'commerce_tax_ui_tax_type_form',
$tax_type,
),
'access arguments' => array(
'administer taxes',
),
'file' => 'includes/commerce_tax_ui.admin.inc',
);
$items['admin/commerce/config/taxes/types/' . $name_arg . '/edit'] = array(
'title' => 'Edit',
'type' => MENU_DEFAULT_LOCAL_TASK,
'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
'weight' => 0,
);
$items['admin/commerce/config/taxes/types/' . $name_arg . '/delete'] = array(
'title' => 'Delete',
'page callback' => 'commerce_tax_ui_tax_type_delete_form_wrapper',
'page arguments' => array(
$tax_type,
),
'access arguments' => array(
'administer taxes',
),
'file' => 'includes/commerce_tax_ui.admin.inc',
'type' => MENU_LOCAL_TASK,
'context' => MENU_CONTEXT_INLINE,
'weight' => 10,
);
}
else {
$items['admin/commerce/config/taxes/types/' . $name_arg] = array(
'title callback' => 'commerce_tax_ui_tax_type_title',
'title arguments' => array(
$name,
),
'description' => 'Redirect to the tax type list.',
'page callback' => 'drupal_goto',
'page arguments' => array(
'admin/commerce/config/taxes/types',
),
'access arguments' => array(
'administer taxes',
),
);
}
if (rules_config_load($tax_type['rule'])) {
$items['admin/commerce/config/taxes/types/' . $name_arg . '/rule'] = array(
'title' => 'Configure rule',
'description' => 'Add conditions to the rule used to apply taxes of this type to products.',
'page callback' => 'drupal_goto',
'page arguments' => array(
'admin/config/workflow/rules/reaction/manage/' . $tax_type['rule'],
),
'access arguments' => array(
'administer rules',
),
'type' => MENU_LOCAL_TASK,
'context' => MENU_CONTEXT_INLINE,
'weight' => 5,
);
}
}
return $items;
}