function uc_attribute_option_ajax in Ubercart 7.3
Same name and namespace in other branches
- 8.4 uc_attribute/uc_attribute.module \uc_attribute_option_ajax()
Ajax callback for attribute selection form elements.
1 string reference to 'uc_attribute_option_ajax'
- _uc_attribute_alter_form in uc_attribute/
uc_attribute.module - Helper function for uc_attribute_form_alter().
File
- uc_attribute/
uc_attribute.module, line 1256 - Ubercart Attribute module.
Code
function uc_attribute_option_ajax($form, $form_state) {
$parents = $form_state['triggering_element']['#array_parents'];
$wrapper = '#' . $form_state['triggering_element']['#ajax']['wrapper'];
while ($key = array_pop($parents)) {
if ($key == 'attributes') {
array_push($parents, $key);
$element = drupal_array_get_nested_value($form, $parents);
$commands[] = ajax_command_replace($wrapper, drupal_render($element));
break;
}
}
if (strpos($form['#form_id'], 'add_to_cart_form') !== FALSE) {
$commands = array_merge($commands, uc_product_view_ajax_commands($form_state, array(
'display_price',
'weight',
'cost',
)));
}
$commands[] = ajax_command_prepend($wrapper, theme('status_messages'));
return array(
'#type' => 'ajax',
'#commands' => $commands,
);
}