You are here

function commerce_cart_order_is_cart in Commerce Core 7

Determines whether or not the given order is a shopping cart order.

8 calls to commerce_cart_order_is_cart()
CommerceBaseTestCase::assertProductAddedToCart in tests/commerce_base.test
Asserts that a product has been added to the cart.
CommerceBaseTesterTestCase::testTestCreateDummyOrder in tests/commerce_base.test
Test the createDummyOrder function.
CommerceCartTestCaseMultiProducts::testCommerceCartOrder in modules/cart/tests/commerce_cart.test
Test if the product is present in the order stored in db.
CommerceCartTestCaseSimpleProduct::testCommerceCartOrder in modules/cart/tests/commerce_cart.test
Test if the product is present in the order stored in db.
commerce_cart_commerce_order_load in modules/cart/commerce_cart.module
Implements hook_commerce_order_load().

... See full list

File

modules/cart/commerce_cart.module, line 968
Implements the shopping cart system and add to cart features.

Code

function commerce_cart_order_is_cart($order) {

  // If the order is in a shopping cart order status, assume it is a cart.
  $is_cart = array_key_exists($order->status, commerce_order_statuses(array(
    'cart' => TRUE,
  )));

  // Allow other modules to make the judgment based on some other criteria.
  foreach (module_implements('commerce_cart_order_is_cart') as $module) {
    $function = $module . '_commerce_cart_order_is_cart';

    // As of Drupal Commerce 1.2, $is_cart should be accepted by reference and
    // manipulated directly, but we still check for a return value to preserve
    // backward compatibility with the hook. In future versions, we will
    // deprecate hook_commerce_cart_order_is_cart() and force modules to update
    // to hook_commerce_cart_order_is_cart_alter().
    if ($function($order, $is_cart) === FALSE) {
      $is_cart = FALSE;
    }
  }
  drupal_alter('commerce_cart_order_is_cart', $is_cart, $order);
  return $is_cart;
}