Posted by droid19 on February 19, 2011 at 4:18pm
I am very new to the rules api and thought I have a go by supplying some simple ubercart integrations. However I can not seem to find a way to get a hold of the event arguments in my condition. Is there anybody that can shine some light on this for me?
Below is my code so far.
function uc_rules_rules_event_info(){
return array(
'uc_rules_event_order_state' => array(
'label' => t('Order state changes'),
'module' => 'Ubercart',
'arguments' => array(
'order' => array('type' => 'order', 'label' => 'order'),
'old_status' => array('type' => 'string', 'label' => 'Old order status'),
'new_status' => array('type' => 'string', 'label' => 'New order status'),
),
),
);
}
function uc_rules_rules_condition_info(){
return array(
'uc_rules_condition_order_status' => array(
'label' => t('Order status'),
'arguments' => array(
'order' => array('type' => 'order', 'label' => 'order'),
'old_status' => array('type' => 'string', 'label' => t('Old status')),
'new_status' => array('type' => 'string', 'label' => t('New status')),
),
'module' => 'ubercart',
),
);
}
function uc_rules_condition_order_status($order, $old_status, $new_status, $settings){
watchdog('old_status', var_export($old_status, TRUE));
watchdog('new_status', var_export($new_status, TRUE));
watchdog('order', var_export($order, TRUE));
watchdog('settings', var_export($settings, TRUE));
}
function uc_rules_condition_order_status_form($settings = array(), &$form){
$form['settings']['old_status'] = array(
'#type' => 'select',
'#title' => t('Old status'),
'#required' => TRUE,
);
$form['settings']['new_status'] = array(
'#type' => 'select',
'#title' => t('New status'),
'#required' => TRUE,
);
$form['settings']['old_status']['#default_value'] = $settings['old_status'];
$form['settings']['new_status']['#default_value'] = $settings['new_status'];
foreach(uc_order_status_list() as $state){
$form['settings']['old_status']['#options'][$state['id']] = $state['title'];
$form['settings']['new_status']['#options'][$state['id']] = $state['title'];
}
}
Comments
Apologies
Posted in the wrong place.