I can't find anything on hook_product_feature in the API docs.

Comments

tr’s picture

Category: bug » task

I suggest you contribute to the documentation pages on ubercart.org by adding that hook to the list of hooks and by starting a page documenting what it does. Any authenticated user has the ability to edit the documentation.

joachim’s picture

I don't know what it does, hence the need for documentation. It really is more productive if someone who wrote the code writes at least the basics of the code docs, as they know what the code does and don't have to spend time unpicking it. Hence we collectively gain Drupal development time.

tr’s picture

I didn't write the code either, and I can't do all the work myself, that's why I asked you to pitch in and try to help.

tr’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev

Let's get this in 7.x-3.x first, then we can backport it.

tr’s picture

Issue tags: +Novice

Tagging.

chishah92’s picture

Issue summary: View changes

FYI , Documentation for this hook exists on Ubercart website

URL : http://www.ubercart.org/comment/49527

tr’s picture

Title: no docs for hook_product_feature » no docs for hook_uc_product_feature
Version: 7.x-3.x-dev » 8.x-4.x-dev

The text from http://www.ubercart.org/comment/49527 that @chishah92 mentioned can be found on wayback.com, as ubercart.org is not maintained. I've reproduced it below with only minor changes.

The original text was provided by https://www.drupal.org/u/bsenftner

hook_uc_product_feature()

Define a product 'feature' and callbacks supporting the feature.

(opinion)
Where Ubercart supports 'classes' for different types of products, 'attributes' for variations in products, and 'options' for the specific values within an attribute... a 'product feature' is an algorithmically generated aspect of a product - sort of like an 'attribute', but requiring custom logic to support. For example, downloadable files, membership subscriptions, and recurring charges are all examples of a 'product feature'. They need to be 'features', rather than 'attributes', because the purchase of these products cause changes to the account status of the purchaser. When a downloadable file is purchased, the purchaser is granted the role of an individual with access to download the file they've purchased. Likewise, when a membership product is purchased, the purchaser is granted the role of 'site member'. Further, these 'features' can support additional logic that maintains the status of the granted roles - such as a recurring fee associated with the membership product.
I have no idea if this description is correct, but that's what it seems to be after several days of research online and in the Ubercart code. Please correct me if any of this is incorrect.
(end opinion)

Note that if your site does not activate any modules that implement product features (via implementing hook_uc_product_feature()), your product's editing nodes will not contain any 'product features' tab.

Example:

function uc_roles_uc_product_feature() {
  $features[] = array(
    'id' => 'role',
    'title' => t('Role assignment'),
    'callback' => 'uc_roles_feature_form',
    'delete' => 'uc_roles_feature_delete',
    'settings' => 'uc_roles_feature_settings',
  );

  return $features;
}

where the hook is expected to return an associative array with the following keys:

  • 'id' - a unique identifier used to identify the feature being implemented
  • 'title' - a string displayed to users as the name of this feature
  • 'callback' - a function implementing a form for specifying and modifying the feature for specific products, the form as generated is passed to uc_product_feature_form() and the return value from that is the return value of this callback
  • 'delete' - a function implementing any logic to delete this feature from the environment
  • 'settings' - a function implementing a form for creating instances of this feature; function returns form array

The parameter signatures of the callback and settings forms appear non-standard, and are what I'm currently researching.

I suggest looking at the source of uc_file.module, uc_roles.module, uc_recurring.module and uc_userpoints_product.module for example logic.

I hope this helps someone!