function commerce_views_display_plugin_style_add_to_cart_form::options_form in Commerce Views Display 7
Options form
Overrides views_plugin_style::options_form
File
- includes/
views/ plugins/ commerce_views_display_plugin_style_add_to_cart_form.inc, line 53 - Contains the views ui tabs style plugin.
Class
- commerce_views_display_plugin_style_add_to_cart_form
- Style plugin to render each item in an add to cart form
Code
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$form['show_quantity'] = array(
'#type' => 'checkbox',
'#title' => t('Display a textfield quantity widget on the add to cart form.'),
'#default_value' => $this->options['show_quantity'],
);
$form['default_quantity'] = array(
'#type' => 'textfield',
'#title' => t('Default quantity'),
'#default_value' => $this->options['default_quantity'] <= 0 ? 1 : $this->options['default_quantity'],
'#element_validate' => array(
'commerce_cart_field_formatter_settings_form_quantity_validate',
),
'#size' => 16,
);
$form['combine'] = array(
'#type' => 'checkbox',
'#title' => t('Attempt to combine like products on the same line item in the cart.'),
'#description' => t('The line item type, referenced product, and data from fields exposed on the Add to Cart form must all match to combine.'),
'#default_value' => $this->options['combine'],
);
$form['show_single_product_attributes'] = array(
'#type' => 'checkbox',
'#title' => t('Show attribute widgets even if the Add to Cart form only represents one product.'),
'#description' => t('If enabled, attribute widgets will be shown on the form with the only available options selected.'),
'#default_value' => $this->options['show_single_product_attributes'],
);
// Add a conditionally visible line item type element.
$types = commerce_product_line_item_types();
if (count($types) > 1) {
$form['line_item_type'] = array(
'#type' => 'select',
'#title' => t('Add to Cart line item type'),
'#options' => array_intersect_key(commerce_line_item_type_get_name(), drupal_map_assoc($types)),
'#default_value' => !empty($this->options['line_item_type']) ? $this->options['line_item_type'] : 'product',
);
}
else {
$form['line_item_type'] = array(
'#type' => 'hidden',
'#value' => key($types),
);
}
$form['display_path'] = array(
'#type' => 'checkbox',
'#title' => t("Link products added to the cart from this View to this View's path if displayed as a page."),
'#default_value' => $this->options['display_path'],
);
$entity_info = entity_get_info('commerce_product');
$view_mode_options = array();
$default_view_mode = !empty($this->options['default_view_mode']) ? $this->options['default_view_mode'] : 'line_item';
if (!empty($entity_info['view modes'])) {
foreach ($entity_info['view modes'] as $view_mode => $view_mode_data) {
$view_mode_options[$view_mode] = isset($view_mode_data['label']) ? $view_mode_data['label'] : $view_mode;
}
if (count($view_mode_options) > 1) {
$form['default_view_mode'] = array(
'#type' => 'select',
'#title' => t('Fallback view mode'),
'#options' => array_map('check_plain', $view_mode_options),
'#default_value' => $default_view_mode,
);
}
else {
$form['default_view_mode'] = array(
'#type' => 'hidden',
'#value' => key($view_mode_options),
);
}
}
else {
$form['default_view_mode'] = array(
'#type' => 'hidden',
'#value' => $default_view_mode,
);
}
$form['force_pager_none'] = array(
'#type' => 'checkbox',
'#title' => t('Override pager and render add to cart form with all items.'),
'#default_value' => $this->options['force_pager_none'],
);
}