Commit 7361150d authored by anthonylindsay's avatar anthonylindsay

Initialised products array when settings empty and removed bad bock region.

parent 26bfb65c
......@@ -136,7 +136,6 @@ function commerce_popular_products_block_info() {
// A block To display a popular product.
$blocks['popular-product-block'] = array(
'info' => t('Commerce Popular Products display block'),
'region' => array('Content'),
'weight' => '-50',
);
return $blocks;
......@@ -193,6 +192,19 @@ function commerce_popular_products_settings_form($form, &$form_state) {
$number = variable_get('commerce_popular_products_number', $default = '1');
$products = variable_get('commerce_popular_products_products');
$title = variable_get('commerce_popular_products_title', 'Popular Products This Month');
$product_types = commerce_popular_products_get_product_types();
$options = array();
foreach ($product_types as $type) {
$options[$type] = $type;
}
if (!isset($products)) {
$product_array = array();
foreach ($product_types as $type) {
$product_array[$type] = 0;
}
$products = $product_array;
}
$form['block_title'] = array(
'#type' => 'textfield',
'#title' => t('Block title.'),
......@@ -205,11 +217,7 @@ function commerce_popular_products_settings_form($form, &$form_state) {
'#description' => t('Product nodes to include in the popularity check.'),
'#default_value' => $products,
);
$product_types = commerce_popular_products_get_product_types();
$options = array();
foreach ($product_types as $type) {
$options[$type] = $type;
}
$form['product_types']['#options'] = $options;
$form['time_period'] = array(
'#type' => 'radios',
......@@ -236,7 +244,7 @@ function commerce_popular_products_settings_form($form, &$form_state) {
),
'#default_value' => $number,
);
$form['submit'] = array('#type' => 'submit', '#value' => t('Save'));;
$form['submit'] = array('#type' => 'submit', '#value' => t('Save'));
return $form;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment