diff --git a/commerce_popular_products.module b/commerce_popular_products.module index 4df68ce24ab136213ff800481320be5149044d27..f3c42267e198e09ce65b3b58ea4e09c0bb623ece 100644 --- a/commerce_popular_products.module +++ b/commerce_popular_products.module @@ -199,12 +199,20 @@ function commerce_popular_products_settings_form($form, &$form_state) { '#description' => t('The title of the "popular products" block as shown to users.'), '#default_value' => $title, ); - $form['product_types'] = array( - '#type' => 'checkboxes', - '#title' => t('Product Types.'), - '#description' => t('Product nodes to include in the popularity check.'), - '#default_value' => $products, - ); + if (isset($products)) { + $form['product_types'] = array( + '#type' => 'checkboxes', + '#title' => t('Product Types.'), + '#description' => t('Product nodes to include in the popularity check.'), + '#default_value' => $products, + ); + } + else { + $form['product_types'] = array( + '#title' => t('Product Types.'), + '#markup' => t('

Product types

You have not defined any product types. You need to define some first.

'), + ); + } $product_types = commerce_popular_products_get_product_types(); $options = array(); foreach ($product_types as $type) { @@ -260,6 +268,7 @@ function commerce_popular_products_settings_form_submit($form, &$form_state) { * A simple query to return all the Commerce product types in the database. */ function commerce_popular_products_get_product_types() { + $names = array(); $products = commerce_product_types(); foreach ($products as $item) { $names[] = $item['name'];