function commerce_coupon_line_item_title in Commerce Coupon 7
Returns an appropriate title for this line item.
File
- ./
commerce_coupon.module, line 906 - Coupon System for Drupal Commerce.
Code
function commerce_coupon_line_item_title($line_item) {
$line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);
$fields = $line_item_wrapper
->getPropertyInfo();
if (isset($fields['commerce_coupon_reference']) && isset($line_item_wrapper->commerce_coupon_reference)) {
$coupon_wrapper = $line_item_wrapper->commerce_coupon_reference;
$coupon = $coupon_wrapper
->value();
if (!empty($coupon)) {
$type = commerce_coupon_get_types($coupon_wrapper
->value()->type);
if (is_object($type)) {
return $type->label . ': ' . $coupon_wrapper->commerce_coupon_code
->value();
}
}
}
return t('Coupon');
}