function commerce_order_contains_products_configure in Commerce Discount 7
Configuration callback for commerce_order_contains_products.
Parameters
array $settings: Values for the form element.
Return value
array Return a form element.
1 string reference to 'commerce_order_contains_products_configure'
File
- ./
commerce_discount.inline_conditions.inc, line 338 - Provides Inline Conditions integration for the Commerce Discount module.
Code
function commerce_order_contains_products_configure($settings) {
// Ensure we've default settings set.
$settings += array(
'products' => array(),
);
// Get values from $settings.
$default_value = '';
foreach ($settings['products'] as $delta => $product_id) {
$product = commerce_product_load(reset($product_id));
$default_value .= $product->sku;
if ($product_id !== end($settings['products'])) {
$default_value .= ', ';
}
}
$form = array();
$form['operator'] = array(
'#type' => 'select',
'#title' => t('Operator'),
'#title_display' => 'invisible',
'#options' => array(
'any' => t('any of'),
'all' => t('all of'),
'exactly' => t('exactly'),
'only' => t('only any of'),
),
'#default_value' => !empty($settings['operator']) ? $settings['operator'] : 'only',
);
$form['products'] = array(
'#type' => 'textfield',
'#title' => t('SKUs'),
'#title_display' => 'invisible',
'#default_value' => $default_value,
'#required' => TRUE,
'#maxlength' => 4096,
'#autocomplete_path' => 'commerce_product/autocomplete/commerce_product/0/0',
'#element_validate' => array(
'commerce_product_reference_autocomplete_validate',
),
'#suffix' => '<div class="condition-instructions">' . t('Select products when ordered make discount active. Conditions:<br><strong>Any of</strong> the products are in the order (can include other products).<br><strong>All of</strong> the products listed are in the order (can include other products).<br><strong>Exactly</strong> the products listed are in the order (cannot contain other products).<br><strong>Only any of</strong> the products are in the order (cannot include other products).') . '</div>',
'#attributes' => array(
'placeholder' => array(
t('enter product name'),
),
),
);
return $form;
}