Commerce Line Item provides a "title" callback. Right now the product_discount line item type provided by Commerce Discount is falling back to commerce_product_line_item_title(). Commerce Discount should wrap around this to add a to the title for better styling of discounted line items.

An example would be using

.views-field-line-item-title .has-discount:after {
  content: ' (discounted)';
  display: block;
}

Comments

mglaman’s picture

Assigned: mglaman » Unassigned
Status: Active » Needs review
StatusFileSize
new937 bytes

Patch!

joelpittet’s picture

Status: Needs review » Needs work

While the example is not translatable, styling discount line item titles does sound appealing.

Thought for class name would be a bit more specific like ... .line-item-title--has-discount just in-case. What do you think?

  1. +++ b/commerce_discount.module
    @@ -648,6 +648,9 @@ function commerce_discount_commerce_line_item_type_info() {
    +        'title' => 'commerce_discount_product_line_item_title'
    

    comma at the end ;)

  2. +++ b/commerce_discount.module
    @@ -661,3 +664,13 @@ function commerce_discount_commerce_line_item_type_info() {
    + * Determine the product_discount's line item title.
    

    Should likely be "Wrap markup around discounted product line item title." or something to that effect?

I expect this shouldn't effect anybody that is using _alter hook that has already done this for themselves?

mglaman’s picture

Status: Needs work » Needs review
StatusFileSize
new1.08 KB
new936 bytes

Updated with reviews from #2. I made the class line-item-title-has-discount since BEM style "--" for modifiers are rampant in contrib (for D7)

mglaman’s picture

Issue tags: +Commerce Sprint
joelpittet’s picture

Status: Needs review » Fixed

Committed with BEM/CEM double hyphen. (discussed with mglaman on IRC)

  • joelpittet committed 01a202e on 7.x-1.x authored by mglaman
    Issue #2542250 by mglaman, joelpittet: Add <span> wrapper around product...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.