diff --git a/modules/cart/includes/commerce_cart.pages.inc b/modules/cart/includes/commerce_cart.pages.inc index 5466bae..f1309d7 100644 --- a/modules/cart/includes/commerce_cart.pages.inc +++ b/modules/cart/includes/commerce_cart.pages.inc @@ -13,14 +13,12 @@ function commerce_cart_checkout_router() { global $user; // Load the shopping cart order. - if ($order = commerce_cart_order_load($user->uid)) { - $wrapper = entity_metadata_wrapper('commerce_order', $order); - } + $order = commerce_cart_order_load($user->uid); // If no shopping cart order could be found, redirect away from checkout. // TODO: Redirect to the cart page instead which would then appear as an // empty shopping cart page. - if (empty($order) || commerce_line_items_quantity($wrapper->commerce_line_items, commerce_product_line_item_types()) == 0) { + if (empty($order) || commerce_cart_is_cart_empty($order)) { drupal_set_message(t('Add some items to your cart and then try checking out.')); drupal_goto(variable_get('commerce_checkout_empty_redirect', '')); } @@ -36,10 +34,9 @@ function commerce_cart_view() { // First check to make sure we have a valid order. if ($order = commerce_cart_order_load($user->uid)) { - $wrapper = entity_metadata_wrapper('commerce_order', $order); // Only show the cart form if we found product line items. - if (commerce_line_items_quantity($wrapper->commerce_line_items, commerce_product_line_item_types()) > 0) { + if (!commerce_cart_is_cart_empty($order)) { // Add the form for editing the cart contents. $content = commerce_embed_view('commerce_cart_form', 'default', array($order->order_id), 'cart'); diff --git a/modules/checkout/commerce_checkout.api.php b/modules/checkout/commerce_checkout.api.php index 1e0d1a7..66c405d 100644 --- a/modules/checkout/commerce_checkout.api.php +++ b/modules/checkout/commerce_checkout.api.php @@ -59,7 +59,7 @@ function hook_commerce_checkout_order_can_checkout($order) { // If there are no line items on the order, redirect away. $wrapper = entity_metadata_wrapper('commerce_order', $order); - if (commerce_line_items_quantity($wrapper->commerce_line_items, commerce_product_line_item_types()) > 0) { + if (!commerce_cart_is_cart_empty($order)) { return TRUE; } } diff --git a/modules/product_reference/commerce_product_reference.module b/modules/product_reference/commerce_product_reference.module index 23cef3e..cea3f9f 100644 --- a/modules/product_reference/commerce_product_reference.module +++ b/modules/product_reference/commerce_product_reference.module @@ -1468,9 +1468,7 @@ function commerce_product_line_item_types() { function commerce_product_reference_commerce_checkout_order_can_checkout($order) { // Allow orders with one or more product line items to proceed to checkout. // If there are no line items on the order, redirect away. - $wrapper = entity_metadata_wrapper('commerce_order', $order); - - if (commerce_line_items_quantity($wrapper->commerce_line_items, commerce_product_line_item_types()) > 0) { + if (!commerce_cart_is_cart_empty($order)) { return TRUE; } }