i'm going to rewrite the following function. It seems a function in d6, so the hook_field function in d7 doesn't run, but i didn't find any hook_field function in d7, anyone knows what is the relative function of hook_field in d7?

function codeless_discounts_field_field($op, &$node, $field, &$items, $teaser, $page) {
  switch ($op) {
    case "sanitize":
    case "view":
      //If items is empty, generate value by getting discounts that apply to this product
      if (empty($items)) {
        $item = array();
        $item["codeless_discounts"] = theme("codeless_discounts_field_get_codeless_discount_html_for_product", $node);
        $items[] = $item;
      }
      break;
  }
}

Comments

The field API is documented

The field API is documented here: http://api.drupal.org/api/drupal/modules!field!field.module/group/field/7

The developers module includes an example field definition.