drupal7 ubercart. Adapting block display of shopping cart

There is an article by Dylan Tack on:

Tiny Cart Block for Ubercart

on a Tiny Cart Block for Ubercart. It does exactly what I want but it is designed for drupal 6.
There is a comment asking the author if it works with drupal 7 and ubercart 3 (I have 7.x-3.3) but he has not produced a version for drupal 7.

I have tried:

1. Creating a folder in my sites/all/modules folder and called it tiny_cart
2. Have created a file called tiny_cart.module in this folder and copied this into it

<?php
/**
 * Implementation of hook_block().
 */
function tiny_cart_block($op = 'list', $delta = 0, $edit = array()) {
  switch ($op) {
    case 'list':
      $blocks[0] = array(
        'info' => t('Micro-sized cart block for page header.'),
        // This block cannot be cached, because anonymous
        // sessions can have differing cart contents.
        // To improve this, see drupal.org/project/uc_ajax_cart
        'cache' => BLOCK_NO_CACHE,
      );
      return $blocks;
    case 'view':
      if ($item_count = uc_cart_get_total_qty()) {
        $block = array();
        $block['subject'] = '';
        $block['content'] = theme('image',
          drupal_get_path('module', 'uc_cart') .'/images/cart-full.png');
        $block['content'] .= format_plural($item_count,
          'My cart: 1 item', 'My cart: @count items');
        $block['content'] = l($block['content'], 'cart', array('html' => TRUE));
        return $block;
      }
      break;
    }
}

but it doesn't appear in the list of blocks. Only the standard Shopping Cart appears. I assume if it worked if would appear as tiny_cart.
How can I get it to work?
bogormanAsked:
Who is Participating?
 
nanharbisonConnect With a Mentor Commented:
I am not sure you should put this module inside another module. Did you try putting it it in its own folder in the sites/all/modules folder?
This might help you, how to convert a D6 module to D7.
http://drupal.org/node/224333
0
 
nanharbisonCommented:
Did you create the tiny_cart.info file? That is the one that makes it show up in the list of modules. Look at the info file for another module to see how it is formed. It is similar to the theme.info file.You list the name of the module, and which core it goes with, a description, and which other modules it is dependent on, and the other files included in the module, etc.
0
 
bogormanAuthor Commented:
Hi nanharbison,
Have tried to follow your advice and have put the following in the info file:

name = Tiny Cart
description = Provides a mini shopping cart for navigation block
core = 7.x
package = Ubercart


but I have obviously not done it correctly as I get the following errors:


   
    Notice: Undefined index: name in system_sort_modules_by_info_name() (line 949 of /home/faithmov/public_html/drupal/modules/system/system.admin.inc).
    Notice: Undefined index: name in system_sort_modules_by_info_name() (line 949 of /home/faithmov/public_html/drupal/modules/system/system.admin.inc).
    Notice: Undefined index: name in system_sort_modules_by_info_name() (line 949 of /home/faithmov/public_html/drupal/modules/system/system.admin.inc).
    Notice: Undefined index: name in system_sort_modules_by_info_name() (line 949 of /home/faithmov/public_html/drupal/modules/system/system.admin.inc).
    Notice: Undefined index: name in system_sort_modules_by_info_name() (line 949 of /home/faithmov/public_html/drupal/modules/system/system.admin.inc).
    Notice: Undefined index: name in system_sort_modules_by_info_name() (line 949 of /home/faithmov/public_html/drupal/modules/system/system.admin.inc).
    Notice: Undefined index: name in system_sort_modules_by_info_name() (line 949 of /home/faithmov/public_html/drupal/modules/system/system.admin.inc).
    Notice: Undefined index: name in system_sort_modules_by_info_name() (line 949 of /home/faithmov/public_html/drupal/modules/system/system.admin.inc).
    Notice: Undefined index: name in system_sort_modules_by_info_name() (line 949 of /home/faithmov/public_html/drupal/modules/system/system.admin.inc).
    Notice: Undefined index: name in system_sort_modules_by_info_name() (line 949 of /home/faithmov/public_html/drupal/modules/system/system.admin.inc).
    Warning: uasort() [function.uasort]: Array was modified by the user comparison function in system_modules() (line 800 of /home/faithmov/public_html/drupal/modules/system/system.admin.inc).
    Notice: Undefined index: name in _system_modules_build_row() (line 982 of /home/faithmov/public_html/drupal/modules/system/system.admin.inc).


When I look at the modules list, it appears in a new section headed Ubercart but only the description shows. There is a box under Enabled but no description.

Where have I gone wrong?
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
nanharbisonCommented:
Did you set dependencies, like:
dependencies[] = ubercart
?
I am not sure what modules this code needs to work, but maybe that is the cause of the errors.
0
 
bogormanAuthor Commented:
Hi,
Thanks for help so far.
My info file reads:

name = Tiny Cart
description = Provides a mini shopping cart for navigation block
core = 7.x
package = Ubercart - core
dependencies[] = uc_order
dependencies[] = uc_product

and my module file:

<?php
/**
 * Implementation of hook_block().
 */
function tiny_cart_block($op = 'list', $delta = 0, $edit = array()) {
  switch ($op) {
    case 'list':
      $blocks[0] = array(
        'info' => t('Micro-sized cart block for page header.'),
        // This block cannot be cached, because anonymous
        // sessions can have differing cart contents.
        // To improve this, see drupal.org/project/uc_ajax_cart
        'cache' => BLOCK_NO_CACHE,
      );
      return $blocks;
    case 'view':
      if ($item_count = uc_cart_get_total_qty()) {
        $block = array();
        $block['subject'] = '';
        $block['content'] = theme('image',
          drupal_get_path('module', 'uc_cart') .'/images/cart-full.png');
        $block['content'] .= format_plural($item_count,
          'My cart: 1 item', 'My cart: @count items');
        $block['content'] = l($block['content'], 'cart', array('html' => TRUE));
        return $block;
      }
      break;
    }
}

I have installed the tiny_cart folder IN THE UBERCART FOLDER.

The module appears on the module page under Ubercart - core.  Have enabled it. It is not listed on the permissions page.

Problem is that it does not appear on the blocks page.  I assume that this is due to some differences in the code for drupal 7 and drupal 6, though there are no errors. Can you suggest how I can get it running.
Brian
0
 
bogormanAuthor Commented:
Thanks.
Have moved it to sites/all/modules but it still doesn't appear on the blocks page. Have run update.php and flushed the caches.
Thanks anyway, nanharbison. Will study the upgrade instructions but am beginning to think it might be easier to try and modify the existing shopping cart block. Have assigned the points.
Regards
Brian
0
 
nanharbisonCommented:
Don't you have to find the cart in site configuration, and create it and then it shows up in the blocks? that's how some other modules work that end up in blocks. Like the dynamic display block, you have to create an instance first and then it shows up in the blocks.
0
 
nanharbisonCommented:
Oh, and thanks for the points.
0
 
bogormanAuthor Commented:
It's not listed under Configuration. Am really not sure.
In fact the "standard" cart looks quite good and I will probably keep to that.
Sorry, have taken site offline for the time being until I get it right, otherwise I could show you.
0
 
nanharbisonCommented:
No problem, good luck with this project!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.