You are here

function commerce_shipping_line_item_title in Commerce Shipping 7.2

Same name and namespace in other branches
  1. 7 commerce_shipping.module \commerce_shipping_line_item_title()

Returns the title of a shipping line item's related shipping service.

1 call to commerce_shipping_line_item_title()
commerce_shipping_service_rate_options in ./commerce_shipping.module
Turns an array of shipping rates into a form element options array.

File

./commerce_shipping.module, line 798
Defines a system for calculating shipping costs associated with an order.

Code

function commerce_shipping_line_item_title($line_item) {
  $line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);

  // First try to get the title from the line item's data array.
  if (!empty($line_item->data['shipping_service']['display_title'])) {
    return $line_item->data['shipping_service']['display_title'];
  }
  elseif ($line_item_wrapper->commerce_shipping_service
    ->value() != NULL && ($title = commerce_shipping_service_get_title($line_item_wrapper->commerce_shipping_service
    ->value(), 'display_title'))) {
    return $title;
  }

  // Fallback to the line item label.
  return $line_item->line_item_label;
}