Skip to content

Instantly share code, notes, and snippets.

@samrose
Created June 21, 2014 12:47
Show Gist options
  • Save samrose/51a536e53cf3eac149c4 to your computer and use it in GitHub Desktop.
Save samrose/51a536e53cf3eac149c4 to your computer and use it in GitHub Desktop.
function hook_price_calc($wizard_data_array) {
$pricing_array = array();
$group_query = new EntityFieldQuery();
$group_query->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'group')
->propertyCondition('status', 1)
->fieldCondition('field_code','value',$wizard_data_array['subdomain'])//TODO ref this field correctly
$group_result = $group_query->execute();
if($wizard_data_array['primary']['age'] < 21){//TODO ref this correct
$primary_age = '0-20';
}elseif($wizard_data_array['primary']['age'] > 64){
$primary_age = '65+';
}else{
$primary_age = $wizard_data_array['primary']['age'];
}
$primary_price_query = new EntityFieldQuery();
$primary_price_query->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'pricing')
->propertyCondition('status', 1)
->fieldCondition('field_association_ref','value',$group_result['nid'])//TODO ref this field correctly
->fieldCondition('field_age_range','value','=',$primary_age)//TODO ref this field correctly
$primary_price_result = $primary_price_query->execute();
if(isset($wizard_data_array['primary']['age']) {//TODO ref this correct
$pricing_array['primary']['price'] = $primary_price_result['field_price'];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment