commerce_pricing_attributes_ui.module in Commerce Pricing Attributes 7.2
File
commerce_pricing_attributes_ui.module
View source
<?php
function commerce_pricing_attributes_ui_entity_info_alter(&$info) {
foreach (commerce_pricing_attributes_enabled_product_types() as $type => $product_type) {
$info['commerce_pricing_attibutes']['bundles'][$product_type['type']] = array(
'label' => $product_type['name'],
'admin' => array(
'path' => 'admin/commerce/products/types/' . strtr($type, '_', '-') . '/pricing_attributes',
'access arguments' => array(
'administer content',
),
),
);
}
}
function commerce_pricing_attributes_ui_menu_alter(&$items) {
foreach (commerce_pricing_attributes_enabled_product_types() as $type => $product_type) {
$bundle = strtr($type, '_', '-');
$items['admin/commerce/products/types/' . $bundle . '/pricing_attributes/fields']['title'] = t('Manage attributes Fields');
$items['admin/commerce/products/types/' . $bundle . '/pricing_attributes/fields']['weight'] = 20;
$items['admin/commerce/products/types/' . $bundle . '/pricing_attributes/display']['title'] = t('Manage attributes display');
$items['admin/commerce/products/types/' . $bundle . '/pricing_attributes/display']['weight'] = 21;
}
}
function commerce_pricing_attributes_ui_form_commerce_product_ui_product_type_form_alter(&$form, &$form_state) {
$product_type = !empty($form_state['product_type']) ? $form_state['product_type']['type'] : '';
$form['product_type']['commerce_pricing_attributes'] = array(
'#type' => 'fieldset',
'#title' => 'Pricing Attibutes',
'#weight' => 10,
);
$form['product_type']['commerce_pricing_attributes']['enabled'] = array(
'#type' => 'checkbox',
'#title' => t('Enabled'),
'#default_value' => variable_get('commerce_pricing_atrributes_' . $product_type . '_enabled', 0),
);
$form['actions']['submit']['#submit'][] = 'commerce_pricing_attributes_commerce_product_ui_product_type_form_submit';
}
function commerce_pricing_attributes_ui_commerce_product_ui_product_type_form_submit($form, &$form_state) {
$product_type = !empty($form_state['product_type']['type']) ? $form_state['product_type']['type'] : $form_state['values']['product_type']['type'];
if (!empty($form_state['values']['product_type']['commerce_pricing_attributes'])) {
foreach ($form_state['values']['product_type']['commerce_pricing_attributes'] as $key => $value) {
variable_set('commerce_pricing_atrributes_' . $product_type . '_' . $key, $value);
}
}
}
function commerce_pricing_attributes_ui_menu_contextual_links_alter(&$links, $router_item, $root_path) {
foreach (commerce_pricing_attributes_enabled_product_types() as $type => $product_type) {
$bundle = strtr($type, '_', '-');
if ($root_path == 'admin/commerce/products/types/' . $bundle) {
$links['commerce-product-type-pricing-attributes-fields'] = menu_get_item($root_path . '/pricing_attributes/fields');
$links['commerce-product-type-pricing-attributes-display'] = menu_get_item($root_path . '/pricing_attributes/display');
}
}
}