Is it possible to change the coupon's line item label, so instead of reading "Percentage coupon" it would read "COUPON-CODE coupon" (where "COUPON-CODE is replaced by the actual code)? I know it's a tiny issue, but I think it would make for a more pleasant user experience.

Many thanks!

Members fund testing for the Drupal project. Drupal Association Learn more


pcambra’s picture

Weird, the label of the line item should be type + coupon code, not just the type.

I think all these issues would be solved by adding a label to coupon entities.

jonathan_hunt’s picture

I see code in commerce_coupon_line_item_new() that defines a line item label as

$line_item->line_item_label = $coupon_wrapper->type->label() . ': ' . $coupon_wrapper->commerce_coupon_code->value();

but it doesn't look like this label is used anywhere. All instances of Percentage coupon in cart and order simply appear as "Percentage coupon".

arbel’s picture

I don't see why type is important, I agree a label is a great option, but the user wouldn't normally care what technical type of coupon it is, as long as he gets the discount he expects.


ericaack’s picture

Actually, I think it's very important to show the coupon name in the admin order view. We need to be able to track which coupon was applied to which order. Some coupons, for example, are paid for out of one scholarship fund, some out of another. I would think that commercial sites would also want to be able to view this information easily.

Thanks for your work on this.

arbel’s picture

I agree that the copuon code or a label you use to identify the coupon should be displayed, but the type is just based on how the module is built and has nothing to do with the coupon. i

pcambra’s picture

Here's how the coupon line item title is generated:


Any improvements in that area are welcome

mglaman’s picture

mglaman’s picture

Scratch my previous statement, discover function was commerce_coupon_commerce_price_component_type_info(). Here is my patch, uses entity_metadata_wrapper() to get coupon code and use as display title.

Attached is my patch and before/after screenshots.

FiNeX’s picture

The patch works fine. Thanks.

loze’s picture

Issue summary: View changes

you can do this without a patch using hook_commerce_price_component_type_info_alter() in a custom module

function MYMODULE_commerce_price_component_type_info_alter(&$component_types) {
  foreach($component_types as $key => $value){
       $component_types[$key]['display_title'] = 'Coupon Code: '.$value['coupon_code']);