You are here

uc_price_per_role.module in Ubercart Price Per Role 7

Same filename and directory in other branches
  1. 5 uc_price_per_role.module
  2. 6 uc_price_per_role.module

Price-per-role main module.

Allows customers with different roles to see different prices.

File

uc_price_per_role.module
View source
<?php

/**
 * @file
 * Price-per-role main module.
 *
 * Allows customers with different roles to see different prices.
 */

/**
 * Implements hook_permission().
 */
function uc_price_per_role_permission() {
  return array(
    'access price selection block' => array(
      'title' => t('Access price selection block'),
    ),
  );
}

/**
 * Implements hook_menu().
 */
function uc_price_per_role_menu() {
  $items = array();
  $items['admin/store/settings/price_per_role'] = array(
    'title' => 'Price per role',
    'description' => 'Configure price per role settings.',
    'access arguments' => array(
      'administer store',
    ),
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'uc_price_per_role_settings_form',
    ),
    'type' => MENU_NORMAL_ITEM,
  );
  if (module_exists('uc_attribute')) {
    $items['node/%node/edit/option_prices'] = array(
      'title' => 'Option prices',
      'page callback' => 'drupal_get_form',
      'page arguments' => array(
        'uc_price_per_role_option_prices_form',
        1,
      ),
      'access callback' => 'uc_attribute_product_option_access',
      'access arguments' => array(
        1,
      ),
      'type' => MENU_LOCAL_TASK,
      'weight' => 3,
    );
  }
  return $items;
}

/**
 * Implements hook_admin_paths().
 */
function uc_price_per_role_admin_paths() {
  return array(
    'node/*/edit/option_prices' => TRUE,
  );
}

/**
 * Implements hook_menu_alter().
 */
function uc_price_per_role_menu_alter(&$items) {

  // Make room in local menu for the 'Option prices' tab.
  if (module_exists('uc_attribute')) {
    $items['node/%node/edit/adjustments']['weight'] = $items['node/%node/edit/adjustments']['weight'] + 1;
  }
  if (isset($items['node/%node/edit/features'])) {
    $items['node/%node/edit/features']['weight'] = $items['node/%node/edit/features']['weight'] + 1;
  }
}

/**
 * Implements hook_theme().
 */
function uc_price_per_role_theme() {
  return array(
    'uc_price_per_role_settings_form' => array(
      'file' => 'uc_price_per_role.module',
      'render element' => 'form',
    ),
    'uc_price_per_role_product_prices' => array(
      'file' => 'uc_price_per_role.module',
      'render element' => 'prices',
    ),
    'uc_price_per_role_option_prices_form' => array(
      'file' => 'uc_price_per_role.module',
      'render element' => 'form',
    ),
  );
}

/**
 * Configuration settings form.
 *
 * @see theme_uc_price_per_role_settings_form()
 */
function uc_price_per_role_settings_form() {
  $enabled = variable_get('uc_price_per_role_enabled', array());
  $weights = variable_get('uc_price_per_role_weights', array());
  $roles = user_roles();
  foreach (array_keys($roles) as $rid) {
    if (!isset($weights[$rid])) {
      $weights[$rid] = 0;
    }
  }
  asort($weights);
  $form['fields']['#tree'] = TRUE;
  foreach ($weights as $rid => $weight) {
    $form['fields'][$rid]['role'] = array(
      '#markup' => $roles[$rid],
    );
    $form['fields'][$rid]['enabled'] = array(
      '#type' => 'checkbox',
      '#default_value' => !empty($enabled[$rid]),
    );
    $form['fields'][$rid]['weight'] = array(
      '#type' => 'weight',
      '#delta' => 5,
      '#default_value' => $weight,
      '#attributes' => array(
        'class' => array(
          'role-weight',
        ),
      ),
    );
  }
  $form['buttons']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save configuration'),
  );
  return $form;
}

/**
 * Theme the configuration settings form.
 *
 * @see uc_price_per_role_settings_form()
 */
function theme_uc_price_per_role_settings_form($variables) {
  $form = $variables['form'];
  $output = '<p>' . t('Enable roles that require separate pricing. For users with more than one matching role, the lightest weight role that has a price available will be used.') . '</p>';
  $header = array(
    t('Enable'),
    t('Role'),
    t('Weight'),
  );
  $rows = array();
  if (!empty($form['fields'])) {
    foreach (element_children($form['fields']) as $field) {
      $row = array();
      $row[] = drupal_render($form['fields'][$field]['enabled']);
      $row[] = drupal_render($form['fields'][$field]['role']);
      $row[] = drupal_render($form['fields'][$field]['weight']);
      $rows[] = array(
        'data' => $row,
        'class' => array(
          'draggable',
        ),
      );
    }
  }
  drupal_add_tabledrag('uc-price-per-roles', 'order', 'sibling', 'role-weight');
  $output .= theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'attributes' => array(
      'id' => 'uc-price-per-roles',
    ),
  ));
  $output .= drupal_render_children($form);
  return $output;
}

/**
 * Submit function for the setings form.
 *
 * @see uc_price_per_role_settings_form()
 */
function uc_price_per_role_settings_form_submit($form, &$form_state) {
  $enabled = array();
  $weights = array();
  foreach ($form_state['values']['fields'] as $rid => $field) {
    $enabled[$rid] = $field['enabled'];
    $weights[$rid] = $field['weight'];
  }
  variable_set('uc_price_per_role_enabled', $enabled);
  variable_set('uc_price_per_role_weights', $weights);
}

/**
 * Implements hook_form_alter().
 */
function uc_price_per_role_form_alter(&$form, $form_state, $form_id) {
  if (uc_product_is_product_form($form)) {
    $enabled = variable_get('uc_price_per_role_enabled', array());
    $enabled_roles = array_filter($enabled);

    // If there is an enabled role, change the label on the core Ubercart sell
    // price to indicate it is now the default price.
    if (!empty($enabled_roles)) {
      $form['base']['prices']['sell_price']['#title'] = t('Default sell price');
      $form['base']['prices']['sell_price']['#description'] = t('Default customer purchase price.');
    }
    $form['base']['role_prices'] = array(
      '#weight' => 6,
      '#theme' => 'uc_price_per_role_product_prices',
      '#tree' => TRUE,
    );
    $sign_flag = variable_get('uc_sign_after_amount', FALSE);
    $currency_sign = variable_get('uc_currency_sign', '$');
    if (isset($form['#node']->role_prices)) {
      $role_prices = $form['#node']->role_prices;
    }
    foreach (user_roles() as $rid => $role) {
      if (!empty($enabled[$rid])) {
        $form['base']['role_prices'][$rid] = array(
          '#type' => 'textfield',
          '#title' => t('%role price', array(
            '%role' => $role,
          )),
          '#required' => FALSE,
          '#default_value' => isset($role_prices[$rid]) ? uc_store_format_price_field_value($role_prices[$rid]) : '',
          '#description' => t('Purchase price for %role users.', array(
            '%role' => $role,
          )),
          '#size' => 15,
          '#maxlength' => 15,
          '#field_prefix' => $sign_flag ? '' : $currency_sign,
          '#field_suffix' => $sign_flag ? $currency_sign : '',
        );
      }
    }
  }
  elseif ($form_id === 'uc_object_options_form') {
    $form['uc_price_per_role_note'] = array(
      '#markup' => '<p>' . t('Note: "Price" column is the default option price. To set option prices per role use the <a href="@link">options prices form</a>.', array(
        '@link' => url('node/' . $form['id']['#value'] . '/edit/option_prices'),
      )) . '</p>',
    );
  }
  elseif (strpos($form_id, 'add_to_cart_form')) {

    // Modify product form attribute option prices.
    $format = variable_get('uc_attribute_option_price_format', 'adjustment');
    if (module_exists('uc_attribute') && $format != 'none') {
      $nid = intval($form['nid']['#value']);
      $product = node_load($nid);
      if (isset($form['qty']['#value'])) {
        $qty = intval($form['qty']['#value']);
      }
      else {
        $qty = 1;
      }
      $priced_attributes = uc_attribute_priced_attributes($nid);
      $role_prices = uc_price_per_role_load_option_prices($nid);
      if (!empty($form['attributes'])) {
        foreach (element_children($form['attributes']) as $aid) {
          if (isset($form['attributes'][$aid]['#options'])) {
            $attribute = uc_attribute_load($aid, $nid, 'product');
            foreach (array_keys($form['attributes'][$aid]['#options']) as $oid) {
              if (isset($role_prices[$oid])) {
                $price = uc_price_per_role_find_price($role_prices[$oid]);
              }
              else {
                $price = FALSE;
              }
              if ($price !== FALSE) {
                switch ($format) {
                  case 'total':
                    $display_price = in_array($aid, $priced_attributes) ? ', ' . uc_currency_format(($product->sell_price + $price) * $qty) : '';
                    if (count($priced_attributes) == 1) {
                      break;
                    }
                  case 'adjustment':
                    $display_price = $price != 0 ? ', ' . ($price > 0 ? '+' : '') . uc_currency_format($price * $qty) : '';
                    break;
                }
                $form['attributes'][$aid]['#options'][$oid] = $attribute->options[$oid]->name . $display_price;
              }
            }
          }
        }
      }
    }
  }
}

/**
 * Theme the role prices form area.
 */
function theme_uc_price_per_role_product_prices($variables) {
  $prices = $variables['prices'];
  $output = '';
  if (!empty($prices)) {
    $output .= '<table><tr>';
    foreach (element_children($prices) as $rid) {
      $output .= '<td>' . drupal_render($prices[$rid]) . '</td>';
    }
    $output .= "</table>\n";
  }
  return $output;
}

/**
 * Implements hook_node_validate().
 */
function uc_price_per_role_node_validate($node, $form, &$form_state) {
  if (isset($node->role_prices)) {
    foreach ($node->role_prices as $rid => $price) {
      if (!empty($price) && !is_numeric($price)) {
        form_set_error('role_prices][' . $rid, t('Price must be a number.'));
      }
    }
  }
}

/**
 * Implements hook_node_load().
 */
function uc_price_per_role_node_load($nodes, $types) {
  $node_array = array();
  foreach ($nodes as $node) {
    if (in_array($node->type, uc_product_types())) {
      $node->role_prices = array();
      $node_array[$node->vid] = $node;
    }
  }
  if (!empty($node_array)) {
    $result = db_query("SELECT vid, rid, price FROM {uc_price_per_role_prices} WHERE vid IN (:vids)", array(
      ':vids' => array_keys($node_array),
    ));
    foreach ($result as $key => $row) {
      $node_array[$row->vid]->role_prices[$row->rid] = $row->price;
    }
    foreach ($node_array as $node) {
      $original_price = $node->sell_price;
      $price = uc_price_per_role_find_price($node->role_prices);
      if ($price !== FALSE) {
        $node->price = $node->sell_price = $price;
      }
      $node->roleindependent_sell_price = $original_price;
    }
  }
}

/**
 * Implements hook_node_insert().
 */
function uc_price_per_role_node_insert($node) {
  db_query("DELETE FROM {uc_price_per_role_prices} WHERE vid = :vid", array(
    ':vid' => $node->vid,
  ));
  if (!empty($node->role_prices)) {
    foreach ($node->role_prices as $rid => $price) {
      if (is_numeric($price)) {
        db_query("INSERT INTO {uc_price_per_role_prices} (vid, nid, rid, price) VALUES (:vid, :nid, :rid, :price)", array(
          ':vid' => $node->vid,
          ':nid' => $node->nid,
          ':rid' => $rid,
          ':price' => $price,
        ));
      }
    }
  }
}

/**
 * Implements hook_node_update().
 */
function uc_price_per_role_node_update($node) {
  db_query("DELETE FROM {uc_price_per_role_prices} WHERE vid = :vid", array(
    ':vid' => $node->vid,
  ));
  if (!empty($node->role_prices)) {
    foreach ($node->role_prices as $rid => $price) {
      if (is_numeric($price)) {
        db_query("INSERT INTO {uc_price_per_role_prices} (vid, nid, rid, price) VALUES (:vid, :nid, :rid, :price)", array(
          ':vid' => $node->vid,
          ':nid' => $node->nid,
          ':rid' => $rid,
          ':price' => $price,
        ));
      }
    }
  }
}

/**
 * Implements hook_node_prepare().
 */
function uc_price_per_role_node_prepare($node) {
  if (isset($node->roleindependent_sell_price)) {

    // Reload original price for editing.
    $node->sell_price = $node->roleindependent_sell_price;
  }
}

/**
 * Implements hook_node_delete().
 */
function uc_price_per_role_node_delete($node) {
  db_query("DELETE FROM {uc_price_per_role_prices} WHERE nid = :nid", array(
    ':nid' => $node->nid,
  ));
}

/**
 * Implements hook_node_revision_delete().
 */
function uc_price_per_role_node_revision_delete($node) {
  db_query("DELETE FROM {uc_price_per_role_prices} WHERE vid = :vid", array(
    ':vid' => $node->vid,
  ));
}

/**
 * Implements hook_uc_product_alter().
 */
function uc_price_per_role_uc_product_alter(&$node) {
  if (module_exists('uc_attribute')) {
    $role_prices = uc_price_per_role_load_option_prices($node->nid);
    foreach (_uc_cart_product_get_options($node) as $option) {
      $oid = $option['oid'];
      if (isset($role_prices[$oid])) {
        $price = uc_price_per_role_find_price($role_prices[$oid]);
        if ($price !== FALSE) {
          $node->price += $price - $option['price'];
        }
      }
    }
  }
}

/**
 * Form definition to edit option prices.
 *
 * @see theme_uc_price_per_role_option_prices_form()
 */
function uc_price_per_role_option_prices_form($form, &$form_state, $product) {
  drupal_set_title($product->title);
  $role_prices = uc_price_per_role_load_option_prices($product->nid);
  $enabled = array_keys(array_filter(variable_get('uc_price_per_role_enabled', array())));
  $form['help'] = array(
    '#markup' => t('Leave any box blank to use the default price for the option.'),
  );
  foreach (uc_product_get_attributes($product->nid) as $aid => $attribute) {
    $form['attributes'][$aid]['name'] = array(
      '#markup' => $attribute->name,
    );
    $form['attributes'][$aid]['aid'] = array(
      '#type' => 'hidden',
      '#value' => $attribute->aid,
    );
    $form['attributes'][$aid]['ordering'] = array(
      '#type' => 'value',
      '#value' => $attribute->ordering,
    );
    $form['attributes'][$aid]['options'] = array(
      '#weight' => 2,
    );
    $base_attr = uc_attribute_load($attribute->aid);
    if ($base_attr->options) {
      $result = db_query("\n        SELECT ao.aid, ao.oid, ao.name, ao.price AS default_price, ao.ordering AS default_ordering, po.price, po.ordering, po.ordering IS NULL AS null_order FROM {uc_attribute_options} AS ao\n        LEFT JOIN {uc_product_options} AS po ON ao.oid = po.oid AND po.nid = :nid\n        WHERE aid = :aid ORDER BY null_order, po.ordering, default_ordering, ao.name", array(
        ':nid' => $product->nid,
        ':aid' => $attribute->aid,
      ));
      foreach ($result as $option) {
        $oid = $option->oid;
        $context['revision'] = 'themed';
        $context['subject']['option'] = $option;
        $price = is_null($option->price) ? $option->default_price : $option->price;
        $form['attributes'][$aid]['options'][$oid]['name'] = array(
          '#markup' => $option->name,
        );
        $form['attributes'][$aid]['options'][$oid]['price'] = array(
          '#markup' => uc_currency_format($price),
        );

        // Include unformatted original price to simplify form alteration.
        $form['attributes'][$aid]['options'][$oid]['price_value'] = array(
          '#type' => 'value',
          '#value' => $price,
        );
        foreach ($enabled as $rid) {
          $form['attributes'][$aid]['options'][$oid]['role_prices'][$rid] = array(
            '#type' => 'textfield',
            '#default_value' => isset($role_prices[$oid][$rid]) ? uc_store_format_price_field_value($role_prices[$oid][$rid]) : '',
            '#size' => 6,
          );
        }
      }
    }
    else {
      $form['attributes'][$aid]['default'] = array(
        '#value' => t('This attribute does not have any options.'),
      );
    }
  }
  if (!empty($form['attributes'])) {
    $form['attributes']['#tree'] = TRUE;
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Submit'),
      '#weight' => 10,
    );
  }
  $form['nid'] = array(
    '#type' => 'value',
    '#value' => $product->nid,
  );
  return $form;
}

/**
 * Display the option form.
 *
 * @ingroup themeable
 * @see uc_price_per_role_option_prices_form()
 */
function theme_uc_price_per_role_option_prices_form($variables) {
  $form = $variables['form'];
  $roles = user_roles();
  $enabled = array_keys(array_filter(variable_get('uc_price_per_role_enabled', array())));
  $header = array(
    t('Attribute'),
    t('Option'),
    t('Default price'),
  );
  foreach ($enabled as $rid) {
    $header[] = t('%role price', array(
      '%role' => $roles[$rid],
    ));
  }
  if (!empty($form['attributes'])) {
    foreach (element_children($form['attributes']) as $key) {
      $row = array();
      $row[] = array(
        'data' => drupal_render($form['attributes'][$key]['aid']) . drupal_render($form['attributes'][$key]['name']),
        'class' => 'attribute',
      );
      if (!empty($form['attributes'][$key]['options']) && ($children = element_children($form['attributes'][$key]['options']))) {
        foreach ($children as $oid) {
          $row[] = drupal_render($form['attributes'][$key]['options'][$oid]['name']);
          $row[] = drupal_render($form['attributes'][$key]['options'][$oid]['price']);
          foreach ($enabled as $rid) {
            $row[] = drupal_render($form['attributes'][$key]['options'][$oid]['role_prices'][$rid]);
          }
          $rows[] = $row;
          $row = array(
            '',
          );
        }
        unset($form['attributes'][$key]['default']);
      }
      else {
        $row[] = array(
          'data' => drupal_render($form['attributes'][$key]['default']),
          'colspan' => count($enabled) + 3,
        );
        $rows[] = $row;
      }
      $rows[] = array(
        array(
          'data' => '<hr />',
          'colspan' => count($enabled) + 3,
        ),
      );
    }
  }
  if (count($rows) == 0) {
    $rows[] = array(
      array(
        'data' => t('This product does not have any attributes.'),
        'colspan' => count($enabled) + 3,
      ),
    );
  }
  $output = drupal_render($form['help']) . theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'attributes' => array(
      'id' => 'product_attributes',
    ),
  )) . drupal_render_children($form);
  return $output;
}

/**
 * Form submit handler to save option prices.
 */
function uc_price_per_role_option_prices_form_submit($form_id, &$form_state) {
  foreach ($form_state['values']['attributes'] as $attribute) {
    if (is_array($attribute['options'])) {
      foreach ($attribute['options'] as $oid => $option) {
        db_query("DELETE FROM {uc_price_per_role_option_prices} WHERE nid = :nid AND oid = :oid", array(
          ':nid' => $form_state['values']['nid'],
          ':oid' => $oid,
        ));
        foreach ($option['role_prices'] as $rid => $price) {
          if (is_numeric($price)) {
            $data = array(
              'nid' => $form_state['values']['nid'],
              'oid' => $oid,
              'rid' => $rid,
              'price' => $price,
            );
            drupal_write_record('uc_price_per_role_option_prices', $data);
          }
        }
      }
    }
  }
  drupal_set_message(t('The option prices have been saved.'));
}

/**
 * Load per-role option price data for the supplied node ID.
 */
function uc_price_per_role_load_option_prices($nid) {
  $prices = array();
  $result = db_query("SELECT oid, rid, price FROM {uc_price_per_role_option_prices} WHERE nid = :nid", array(
    ':nid' => $nid,
  ));
  foreach ($result as $row) {
    $prices[$row->oid][$row->rid] = $row->price;
  }
  return $prices;
}

/**
 * Find the price for the current user from the supplied price array.
 *
 * Will return FALSE if no price was found.
 */
function uc_price_per_role_find_price($prices) {
  global $user;
  $enabled = variable_get('uc_price_per_role_enabled', array());
  $weights = variable_get('uc_price_per_role_weights', array());
  asort($weights);

  // Check for a chosen role in the price selection block first.
  if (user_access('access price selection block') && isset($_SESSION['price_role']) && isset($prices[$_SESSION['price_role']])) {
    return $prices[$_SESSION['price_role']];
  }

  // Otherwise, look for a matching role.
  foreach ($weights as $rid => $weight) {
    if (isset($user->roles[$rid]) && $enabled[$rid] && isset($prices[$rid])) {
      return $prices[$rid];
    }
  }
  return FALSE;
}

/**
 * Implements hook_block_info().
 */
function uc_price_per_role_block_info() {
  $blocks[0]['info'] = t('Pricing selection');
  return $blocks;
}

/**
 * Implements hook_block_view().
 */
function uc_price_per_role_block_view($delta = 0) {
  if ($delta == 0 && user_access('access price selection block')) {
    $block = array(
      'subject' => t('Pricing selection'),
      'content' => drupal_get_form('uc_price_per_role_switch_form'),
    );
    return $block;
  }
}

/**
 * Form to allow authorised users to select which role is used for pricing.
 */
function uc_price_per_role_switch_form() {
  $enabled = variable_get('uc_price_per_role_enabled', array());
  $weights = variable_get('uc_price_per_role_weights', array());
  $roles = user_roles();
  asort($weights);
  $options = array(
    '' => 'Default',
  );
  foreach ($weights as $rid => $weight) {
    if ($enabled[$rid]) {
      $options[$rid] = $roles[$rid];
    }
  }
  $form['role'] = array(
    '#type' => 'select',
    '#title' => 'Role',
    '#options' => $options,
    '#default_value' => isset($_SESSION['price_role']) ? $_SESSION['price_role'] : '',
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Select pricing role'),
  );
  return $form;
}

/**
 * Form submit handler to save price role selection.
 */
function uc_price_per_role_switch_form_submit($form_id, &$form_state) {
  if (user_access('access price selection block')) {
    $_SESSION['price_role'] = $form_state['values']['role'];
  }
}

/**
 * Implements of hook_migrate_api().
 */
function uc_price_per_role_migrate_api() {
  return array(
    'api' => 1,
  );
}

/**
 * Implements hook_user_role_delete().
 * 
 * Remove orphaned database entries and weights for deleted roles.
 */
function uc_price_per_role_user_role_delete($role) {

  // Remove deleted role from uc_price_per_role_weights variable.
  $weights = variable_get('uc_price_per_role_weights', array());
  unset($weights[$role->rid]);
  variable_set('uc_price_per_role_weights', $weights);

  // Remove deleted role from uc_price_per_role_enabled variable.
  $enabled = variable_get('uc_price_per_role_enabled', array());
  unset($enabled[$role->rid]);
  variable_set('uc_price_per_role_enabled', $enabled);

  // Remove data for deleted role from the {uc_price_per_role_prices} table.
  db_delete('uc_price_per_role_prices')
    ->condition('rid', $role->rid, '=')
    ->execute();

  // Remove deleted role from the {uc_price_per_role_option_prices} table.
  db_delete('uc_price_per_role_option_prices')
    ->condition('rid', $role->rid, '=')
    ->execute();
}

/**
 * Implements hook_help().
 */
function uc_price_per_role_help($path, $arg) {
  switch ($path) {
    case "admin/help#uc_price_per_role":
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('The Ubercart Price-Per-Role module allows Ubercart to charge different prices to different customers based on their roles.  It works with both base prices and option prices.') . '</p>';
      $output .= '<h3>' . t('Configuration') . '</h3>';
      $output .= '<p>' . t('For each class of customer that should get a different price, create a role on the ') . l(t('roles configuation page'), 'admin/people/permissions/roles') . '</p>';
      $output .= '<p>' . t('Assign roles to users ') . l(t('manually'), 'admin/people') . t(', via ') . l(t('Rules'), 'admin/config/workflow/rules') . t(' or otherwise.') . '</p>';
      $output .= '<p>' . t('Go to the ') . l(t('configuration page'), 'admin/store/settings/price_per_role') . t('.  Select which roles get special pricing and select which roles to use for users who have multiple maching roles.') . '</p>';
      $output .= '<p>' . t('Go to each product page that should receive special role pricing and enter the price for each role.  Role prices may also be entered for each attribute option on a per-product basis.');
      $output .= '<h3>' . t('Role selection block') . '</h3>';
      $output .= '<p>' . t('Administrators may use a price selection block.  This is handy for checking prices without needing to log in as a user with a particular role.  To use it:');
      $output .= '<ul><li>' . t('Go to the ') . l(t('permissions page'), 'admin/people/permissions#module-uc_price_per_role') . t(' and grant access to the roles that should use the block.') . '</li>';
      $output .= '<li>' . t('Go to the ') . l(t('blocks administration page'), 'admin/structure/block') . t(' and enable the block for whichever themes you wish, especially your administration theme.  The footer is a good region for it.') . '</li></ul>';
      $output .= '<p>' . t('Once the block is placed, administrators can use it to select role prices.') . '</p>';
      $output .= '<h3>' . t('Manually creating orders') . '</h3>';
      $output .= '<p>' . t('The ') . l(t('order creation form'), 'admin/store/orders/create') . t(' does not respect the role of the customer for whom the order is being created.  However, it does respect the roles of the current user and the price selection block.  To create an order using role pricing, use the price selection block as noted above to select the role of the customer, then create the order as usual.');
      return $output;
  }
}

Functions

Namesort descending Description
theme_uc_price_per_role_option_prices_form Display the option form.
theme_uc_price_per_role_product_prices Theme the role prices form area.
theme_uc_price_per_role_settings_form Theme the configuration settings form.
uc_price_per_role_admin_paths Implements hook_admin_paths().
uc_price_per_role_block_info Implements hook_block_info().
uc_price_per_role_block_view Implements hook_block_view().
uc_price_per_role_find_price Find the price for the current user from the supplied price array.
uc_price_per_role_form_alter Implements hook_form_alter().
uc_price_per_role_help Implements hook_help().
uc_price_per_role_load_option_prices Load per-role option price data for the supplied node ID.
uc_price_per_role_menu Implements hook_menu().
uc_price_per_role_menu_alter Implements hook_menu_alter().
uc_price_per_role_migrate_api Implements of hook_migrate_api().
uc_price_per_role_node_delete Implements hook_node_delete().
uc_price_per_role_node_insert Implements hook_node_insert().
uc_price_per_role_node_load Implements hook_node_load().
uc_price_per_role_node_prepare Implements hook_node_prepare().
uc_price_per_role_node_revision_delete Implements hook_node_revision_delete().
uc_price_per_role_node_update Implements hook_node_update().
uc_price_per_role_node_validate Implements hook_node_validate().
uc_price_per_role_option_prices_form Form definition to edit option prices.
uc_price_per_role_option_prices_form_submit Form submit handler to save option prices.
uc_price_per_role_permission Implements hook_permission().
uc_price_per_role_settings_form Configuration settings form.
uc_price_per_role_settings_form_submit Submit function for the setings form.
uc_price_per_role_switch_form Form to allow authorised users to select which role is used for pricing.
uc_price_per_role_switch_form_submit Form submit handler to save price role selection.
uc_price_per_role_theme Implements hook_theme().
uc_price_per_role_uc_product_alter Implements hook_uc_product_alter().
uc_price_per_role_user_role_delete Implements hook_user_role_delete().