--- sites/all/modules/ubercart/uc_cart/uc_cart.pages.inc	2010-10-28 18:57:12.000000000 +0400
+++ sites/all/modules/ubercart/uc_cart/uc_cart.pages.inc	2010-10-28 19:11:06.000000000 +0400
@@ -27,6 +27,24 @@ function uc_cart_view() {
   // Load the array of shopping cart items.
   $items = uc_cart_get_contents();
 
+  // Remove items from the cart that have become unpublished since they were added to the cart
+  $refresh_cart = 0;
+  foreach ($items as $index => $item) {
+    $status = node_load($item->nid);
+    $status = $status->status;
+    if(!$status){
+      // Rebuild the cart if something's changed
+      $refresh_cart = 1;
+      // Remove the item
+      module_invoke($item->module, 'update_cart_item', $item->nid, $item->data, 0); 
+      // Tell user something's been removed
+      drupal_set_message(t('One or more of the items in your cart are no longer available, and have automatically been removed.'));
+    }
+  }
+  
+  // Refresh the items if something was removed
+  if ($refresh_cart) $items = uc_cart_get_contents(NULL, 'rebuild');
+  
   // Display the empty cart page if there are no items in the cart.
   if (empty($items)) {
     return theme('uc_empty_cart');
