Commit c9633171 authored by anthonylindsay's avatar anthonylindsay

Fixed undefined variable error if no products defined and adjusted settings page message to suit.

parent 98f78492
......@@ -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'];
......
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