diff --git a/shipping/uc_quote/uc_quote.module b/shipping/uc_quote/uc_quote.module
index 96468cb..528074e 100644
--- a/shipping/uc_quote/uc_quote.module
+++ b/shipping/uc_quote/uc_quote.module
@@ -528,8 +528,7 @@ function uc_quote_get_default_shipping_address($nid) {
 function uc_cart_pane_quotes($form, &$form_state, $items) {
   global $user;
 
-  $order = new UcOrder();
-  $order->uid = $user->uid;
+  $order = new UcOrder($user->uid);
   $order->delivery_country = isset($form_state['values']['delivery_country']) ? $form_state['values']['delivery_country'] : uc_store_default_country();
   $order->delivery_zone = isset($form_state['values']['delivery_zone']) ? $form_state['values']['delivery_zone'] : '';
   $order->delivery_postal_code = isset($form_state['values']['delivery_postal_code']) ? $form_state['values']['delivery_postal_code'] : '';
diff --git a/uc_cart/uc_cart.module b/uc_cart/uc_cart.module
index 0a78f50..6de185b 100644
--- a/uc_cart/uc_cart.module
+++ b/uc_cart/uc_cart.module
@@ -1290,15 +1290,9 @@ function uc_cart_get_contents($cid = NULL, $action = NULL) {
         ->execute();
       if (!empty($result['uc_cart_item'])) {
         $items[$cid] = entity_load('uc_cart_item', array_keys($result['uc_cart_item']), NULL, TRUE);
+
         // Create a bare order and attach it to each item as context.
-        $order = new UcOrder();
-        $order->uid = $cid;
-        if ($account = user_load($cid)) {
-          $order->primary_email = $account->mail;
-        }
-        $order->order_status = uc_order_state_default('in_checkout');
-        $order->created = REQUEST_TIME;
-        $order->modified = REQUEST_TIME;
+        $order = new UcOrder($cid);
         foreach ($items[$cid] as $item) {
           $item->order = $order;
         }
diff --git a/uc_order/uc_order.module b/uc_order/uc_order.module
index 292665d..5cd5ec4 100644
--- a/uc_order/uc_order.module
+++ b/uc_order/uc_order.module
@@ -55,11 +55,30 @@ class UcOrder {
   public $modified = 0;
   public $currency = '';
 
-  function __construct() {
-    $this->order_status = uc_order_state_default('in_checkout');
+  /**
+   * Order object constructor.
+   *
+   * @param $uid
+   *   The user ID that owns the order, or a cart ID. Cart IDs are integer
+   *   user IDs for authenticated users, or are strings of 22 characters
+   *   or more for anonymous users.
+   * @param $state
+   *   The initial order state.
+   */
+  function __construct($uid = 0, $state = 'in_checkout') {
+    if (strlen($uid) < 22 && $uid > 0) {
+      $this->uid = $uid;
+      if ($account = user_load($uid)) {
+        $order->primary_email = $account->mail;
+      }
+    }
+
+    $this->order_status = uc_order_state_default($state);
     $this->currency = variable_get('uc_currency_code', 'USD');
     $this->billing_country = variable_get('uc_store_country', 840);
     $this->delivery_country = variable_get('uc_store_country', 840);
+    $this->created = REQUEST_TIME;
+    $this->modified = REQUEST_TIME;
   }
 
 }
@@ -851,18 +870,7 @@ function uc_order_order_entity_access($op, $order = NULL, $account = NULL) {
  * Generates a new order for user $uid.
  */
 function uc_order_new($uid = 0, $state = 'in_checkout') {
-  $order = new UcOrder();
-
-  if ($uid > 0) {
-    $user = user_load($uid);
-    $email = $user->mail;
-    $order->primary_email = $email;
-  }
-
-  $order->uid = $uid;
-  $order->order_status = uc_order_state_default($state);
-  $order->created = REQUEST_TIME;
-  $order->modified = REQUEST_TIME;
+  $order = new UcOrder($uid, $state);
 
   drupal_write_record('uc_orders', $order);
 
