array( '#entity' => 'uc_order', '#title' => t('Order'), ), ); $conditions['node_taxonomy_comparison'] = array( '#title' => t('Compare an order\'s taxonomy value'), '#description' => t('Returns TRUE if one of the order\'s products has the taxonomy term specified below.'), '#category' => t('Order: Product'), '#callback' => 'ca_taxonomy_condition_node_taxonomy_comparison', '#arguments' => $args, ); return $conditions; } /** * Configuration form for the node_taxonomy condition. */ function ca_taxonomy_condition_node_taxonomy_comparison_form($form_state, $settings = array()) { $form = array(); $form['term'] = array( '#type' => 'select', '#title' => t('Term'), '#options' => taxonomy_form_all(), '#description' => t('Select a term to compare to the node\'s terms. Keep in mind that the selected product node type must have the selected vocabulary enabled.'), '#default_value' => $settings['term'], ); return $form; } /** * Verify if the current order has products/nodes which contain the requested * term. */ function ca_taxonomy_condition_node_taxonomy_comparison($order, $settings) { // Loop over the products. foreach ($order->products as $product) { // Loop over the terms. foreach ($product->taxonomy as $term) { // If the term matches, we're good to go. if ($term->tid == $settings['term']) { return TRUE; } } } // If we get this far then there's no match. return FALSE; }