function commerce_conditions_get_terms_list in Commerce Extra Rules Conditions 7
Takes the machine name of a Taxonomy reference field and retrieves the terms for the associated vocabulary.
Parameters
string $field_name: A string containing the machine name of a Taxonomy reference field.
Return value
An array containing the term names of the vocabulary tied to $field_name prefixed with a certain number of dashes(-) corresponding to the depth of the term. Term names are keyed by term id.
3 calls to commerce_conditions_get_terms_list()
- commerce_conditions_compare_termed_product_quantity_form_alter in ./
commerce_conditions.rules.inc - Alters the form for commerce_conditions_compare_termed_product_quantity so that we can require the term reference field be selected first so that the term_id list can be populated.
- commerce_conditions_rules_condition_has_terms_form_alter in ./
commerce_conditions.rules.inc - Alters the form for commerce_conditions_rules_condition_has_terms so that we can require the term reference field be selected first so that the term_ids list can be populated.
- commerce_conditions_rules_condition_has_term_form_alter in ./
commerce_conditions.rules.inc - Alters the form for commerce_conditions_rules_condition_has_term so that we can require the term reference field be selected first so that the term_id list can be populated.
File
- ./
commerce_conditions.module, line 231 - Defines functions used for building and processing Rules conditions.
Code
function commerce_conditions_get_terms_list($field_name) {
$field = field_read_field($field_name);
$vocabulary = taxonomy_vocabulary_machine_name_load($field['settings']['allowed_values'][0]['vocabulary']);
$terms = taxonomy_get_tree($vocabulary->vid);
$term_list = array();
if (!empty($terms)) {
foreach ($terms as $term) {
$term_list[$term->tid] = str_repeat('-', $term->depth) . $term->name;
}
}
return $term_list;
}