Many Drupal programmers, Drupal site admins and Drupal site users have encountered the
"Notice: Undefined variable" error message in their Drupal site. If you are facing the same situation in your Drupal site then read on to find out more.
"Notice: Undefined variable" error
A Drupal+Ubercart site with a store where users can purchase your products and no links to indicate the number of products anywhere in your site seems too annoying. It would be nice if there is a way to update the cart count as soon as a product is added to the cart.
Here is the code snippet to get the total number of contents in the cart:
<?php print count(uc_cart_get_contents()); ?>
You can theme the content accordingly to show the contents in style:
<?php print count(uc_cart_get_contents()); ?> items