Check if certain line item type exists I am using Commerce Userpoints to award points based on purchases and then customers can use those rewards on future purchases for a discount.

I'd like to customize the checkout pane if the user has already applied a discount. Commerce Userpoints Discount creates a line item type of userpoints. My initial idea was to check if the current order contains a line item of type userpoints, but I'm not sure how to do that. Any help would be appreciated!
You can check for a certain type of line item on an order using one of the two following methods.

Given an order, let's look for a shipping line item.

// Load your order.
$order = commerce_order_load(/* Order ID */);


Without Metadata Wrappers

if (!empty($order-&gt;commerce_line_items)) {
  // Iterate over the line items.
  foreach ($order-&gt;commerce_line_items[LANGUAGE_NONE] as $line_item_data) {
    $line_item = commerce_line_item_load($line_item_data['line_item_id']);
    // Check the type.
    if ($line_item-&gt;type == 'shipping') {
      // Shipping line item found. Do the things.
    }
  }
}


With Wrappers

$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
// Iteration is a bit simpler here.
foreach ($order_wrapper-&gt;commerce_line_items as $line_item) {
  // We have to access it using -&gt;value().
  if ($line_item-&gt;type-&gt;value() == 'shipping') {
    // Shipping line item found. Do the things.
  }
}