summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnthony Lindsay2012-08-24 12:59:59 (GMT)
committerAnthony Lindsay2012-08-24 12:59:59 (GMT)
commitc963317166a61c977cab241d91c252fd45591e3e (patch)
treeb916290fae7547c4559bbfad37578f6300c9119f
parent98f78492392612de7760180e80664a1044843bbe (diff)
Fixed undefined variable error if no products defined and adjusted settings page message to suit.
-rw-r--r--commerce_popular_products.module21
1 files changed, 15 insertions, 6 deletions
diff --git a/commerce_popular_products.module b/commerce_popular_products.module
index 4df68ce..f3c4226 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('<h4>Product types</h4><p>You have not defined any product types. You need to define some first.</p>'),
+ );
+ }
$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'];