An experience enhancement would be to include a field on the product_discount line item that allows the display of a "discount message." An example would be providing this same field on the "free products" offer type. When a user is awarded the discount, the shopping cart views can then display the message (since its on the line item) to explain the discount.

Incoming patch which adds the field to the line item, and to the free products offer. I think it'd be too much to alter the cart views for users and place this automatically, leaving it as an implementation item on the user's end.

Edit screen

Modified cart

Comments

mglaman’s picture

Assigned: mglaman » Unassigned
Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new3.05 KB
new77.25 KB
new21.09 KB

Patch. Here is description on message field, giving notice to implementation (probably needs better placement...)

You will need to add this field to your shopping cart form and shopping cart summary views

Updated summary to include screenshots.

joelpittet’s picture

What about applying this field to all offer types and doing a drupal_set_message?

mglaman’s picture

Updated patch which tests field on line item instance

mglaman’s picture

StatusFileSize
new7.1 KB
new7.1 KB

Here is updated patch

  • Changes field name to be more generic
  • Adds message field to all offer types
  • Includes Rules Action to drupal_set_message a discount's offer's message if set
  • Includes disabled rule to run above on order refresh (discounts applied)

Status: Needs review » Needs work

The last submitted patch, 4: add_discount_message-2542284-4.patch, failed testing.

mglaman’s picture

Status: Needs work » Needs review
StatusFileSize
new7.41 KB
new460 bytes

Update import test

Status: Needs review » Needs work

The last submitted patch, 6: add_discount_message-2542284-6.patch, failed testing.

mglaman’s picture

Status: Needs work » Needs review
StatusFileSize
new7.42 KB
new553 bytes

Whoops :/ this should be right way to do test.

Status: Needs review » Needs work

The last submitted patch, 8: add_discount_message-2542284-8.patch, failed testing.

mglaman’s picture

Status: Needs work » Needs review
StatusFileSize
new7.43 KB

JSON formatting is killing me, here.

joelpittet’s picture

Issue tags: +Needs manual testing

I think this looks great, but I'll let someone else take a stab at reviewing it first before committing.

rszrama’s picture

Shoot, dude. I had no clue you wrote this patch. I had a similar requirement. However, instead of adding the discount message field to the offer type I made it to the discount bundles themselves. Since it's a 1:1 relationship between discounts and offers, I'm not sure why the field needs to be on the offer.

Re: placing the message, I also used a custom Views field handler to find and display relevant discount messages inline with line items. Works like a charm! Would just require the site to edit the cart (or any other) View to add the field.

Let me get a diff out of that project so we can compare if you're amenable.

rszrama’s picture

Status: Needs review » Needs work

So, turns out I may have asked Matt to write this patch and then promptly forgotten about doing so. Regardless of the approach, we'll need an update function, so setting to needs work for now.

mglaman’s picture

Why does this need an update function?

/**
 * Implements hook_flush_caches().
 */
function commerce_discount_flush_caches() {
  module_load_install('commerce_discount');
  commerce_discount_install_helper();
}

So we force people to flush caches?