hook_rules_condition_info() is used to create custom rules conditions.
/**
* Implements hook_rules_condition_info()
*/
function custom_rules_rules_condition_info() {
return array(
'custom_rules_default_condition_dealer_store' => array(
'label' => t('Dealer store'),
'group' => t('Domains'),
'parameter' => array(
'operator' => array(
'type' => 'text',
'label' => t('Show pricing enabled'),
'options list' => '__custom_rules_dealer_store_operators',
'default value' => '0'
)
)
),
);
}
/**
* Custom hook
* Test domain for matching
* @param string $operator
* @return bool
*/
function custom_rules_default_condition_dealer_store($operator) {
$domain_info = domain_get_domain();
// returns 0 or 1.
// 1 means current domain is dealer store.
// 0 means current domain is portal store.
$show_pricing = domain_conf_variable_get($domain_info['domain_id'], 'show_pricing');
switch ($operator) {
case '1':
return ($show_pricing == 1)?TRUE:FALSE;
case '0': default:
return ($show_pricing == 0)?TRUE:FALSE;
}
}
/**
* Get array comparsion operators
* @return array
*/
function __custom_rules_dealer_store_operators() {
return array(
'1' => t('Yes'),
'0' => t('No'),
);
}
Comments
Post a Comment