diff -u b/modules/cart/commerce_cart.module b/modules/cart/commerce_cart.module --- b/modules/cart/commerce_cart.module +++ b/modules/cart/commerce_cart.module @@ -654,18 +654,17 @@ // Default to an empty cart block message. $content = theme('commerce_cart_empty_block'); - // First check to ensure there are products in the shopping cart. - if (!commerce_cart_is_cart_empty()) { - $order = commerce_cart_order_load($user->uid); - - // Build the variables array to send to the cart block template. - $variables = array( - 'order' => $order, - 'contents_view' => commerce_embed_view('commerce_cart_block', 'default', array($order->order_id), $_GET['q']), - ); - - $content = theme('commerce_cart_block', $variables); - } + $order = commerce_cart_order_load($user->uid); + // If there are one or more products in the cart... + if (!commerce_cart_is_cart_empty($order)) { + // Build the variables array to send to the cart block template. + $variables = array( + 'order' => $order, + 'contents_view' => commerce_embed_view('commerce_cart_block', 'default', array($order->order_id), $_GET['q']), + ); + + $content = theme('commerce_cart_block', $variables); + } return array('subject' => t('Shopping cart'), 'content' => $content); } @@ -674,13 +673,17 @@ /** * Checks if the current user has items in their cart. * + * @param $order + * Optional: The cart order to check. + * * @return * Boolean indicating whether or not the shopping cart is empty. */ -function commerce_cart_is_cart_empty() { +function commerce_cart_is_cart_empty($order = null) { global $user; - if ($order = commerce_cart_order_load($user->uid)) { + $order = (!$order) ? commerce_cart_order_load($user->uid) : $order; + if ($order) { $wrapper = entity_metadata_wrapper('commerce_order', $order); // If there are one or more products in the cart... @@ -692,7 +695,7 @@ return TRUE; } - /** +/** * Checks if a cart order should be refreshed based on the shopping cart refresh * settings on the order settings form. *