You are here

function dc_ajax_add_cart_filter_commerce_line_item_by_commerce_product in Commerce Ajax Add to Cart 7.2

Filters line items by products.

Parameters

array $line_items: Line items to be filtered from.

Return value

array Filtered line items.

1 call to dc_ajax_add_cart_filter_commerce_line_item_by_commerce_product()
dc_ajax_add_cart_get_last_line_item_wrapper in ./dc_ajax_add_cart.module
Returns the last line item that was added to cart.

File

./dc_ajax_add_cart.module, line 920
Ajax add to cart module.

Code

function dc_ajax_add_cart_filter_commerce_line_item_by_commerce_product($line_items) {
  $product_types = array_keys(commerce_product_types());
  $filtered_line_items = array();
  foreach ($line_items as $line_item) {
    if (in_array($line_item->type, $product_types)) {
      $filtered_line_items[] = $line_item;
    }
  }
  return $filtered_line_items;
}