Alerts are thrown into the log if commerce_discounts is enabled on a site that does not have the 'full_html' or 'filtered_html' text formats. This may not be the common occurrence for many sites especially if they install Drupal using the standard install profile, however I have a few custom sites and there are some distributions that create their own text formats and don't use the out of the box text formats.

View: commerce_discount_overview

$handler->display->display_options['footer']['area']['content'] = 'Access to <a href="/admin/config/workflow/rules?event=0&tag=Commerce+Discount">promotion rules</a>';
$handler->display->display_options['footer']['area']['format'] = 'full_html';
$handler->display->display_options['empty']['area']['content'] = 'No discounts found.';
$handler->display->display_options['empty']['area']['format'] = 'filtered_html';

Comments

grahamvalue’s picture

StatusFileSize
new111.73 KB

Getting a similar alert in the log:

Type filter
Date Friday, October 3, 2014 - 11:09
User Serenity
Location http://www.serenitystocks.com/admin/commerce/orders/carts
Referrer http://www.serenitystocks.com/admin/commerce/orders
Message Missing text format: plain_text.
Severity alert
Hostname 117.192.148.64
Operations

Screenshot attached.

Thanks!

grahamvalue’s picture

Please note:

1. Site was upgraded from Drupal 6.
Text format machine names are stored as numbers, not as names.

2. Site does not have Commerce Discount module installed.
But the error/alert is the same so logging it here for reference.

Thanks a lot!

ralt’s picture

StatusFileSize
new2.18 KB
new21.67 KB

I tried to use the attached patch, but it raises another issue: the link to promotion is in plain text. See attached picture.

What should be done? Should the module force these text formats to exist?

Another thing to note is that the patch modifies a bit of featured code (the exported view): it shouldn't do that. The patch is just there for the sake of the example.

caschbre’s picture

Hmm... maybe we don't put the link in the View? And add it off of the navigation? Or we would have to write a View plugin that can render the text instead of adding it to the footer.

ralt’s picture

I don't see how we can not show the link. It's a feature.

I thought about it for a while, and the best solution I could come up with was to use variable_get('...', 'full_html'). It'd allow websites with default formats to keep working normally, and users with special setups could configure this. What do you think?

caschbre’s picture

yeah, I don't mean to remove the link... was just thinking if we could put it somewhere else that doesn't rely on the text format.

Not sure if we need a variable. I think if a module/site needs to change the view to work around a missing format they can just use hook_views_default_views_alter. I was hoping to avoid that for something like a text format but that seems like the only option unless we move the link elsewhere.

What if we added a hook_menu that throws up the "Promotion Rules" as a tab (redirect) on the admin/commerce/store/discounts page? That would put "Promotion Rules" as a tab and when the user clicks on it, it just redirects them to the actual link needed?

ralt’s picture

I like that idea. The other text format doesn't have a link in it, so it's not very important to keep it as such. I'll see if I can do it during the day.

ralt’s picture

Status: Active » Needs review
StatusFileSize
new2.72 KB

There we go! The following patch adds a new tab "Promotion rules" that redirects to the rules page.

ralt’s picture

Fixes styling and removes unneeded code.

caschbre’s picture

Looks good! Thanks Ralt!

caschbre’s picture

Status: Needs review » Reviewed & tested by the community

@Ralt... I'm using this patch and it looks good. I haven't seen the warnings anymore.

rsvelko’s picture

+++ b/includes/commerce_discount.admin.inc
@@ -76,6 +76,24 @@ class CommerceDiscountUIController extends EntityDefaultUIController {
+            'tag' => 'Commerce+Discount',

This is wrong.
Should be with a space and not "+"

RIGHT :
+ 'tag' => 'Commerce Discount',

So I attach the newest patch.

I also think the "Promotion rules" title should say something more intuitive like:
"Rules with tag: Commerce Discount"
or
"Commerce Discount Rules"
or
"Discount Rules"

Anyway please commit whatever asap. I've not changed the wording in my attached patch.

rsvelko’s picture

btw, I am applying for a co-maintainer so I can commit several fixes myself. Wish me luck.

  • bojanz committed 4cc1c8e on 7.x-1.x
    Issue #2257297 by Ralt, serenitystocks.com, rsvelko: Missing text format...
bojanz’s picture

Status: Reviewed & tested by the community » Fixed

Renamed the tab to "Discount rules", it's weird that the word Promotion was used when it's "Discount" everywhere else in the module. Also moved the tab to be last.
In the future I'd like to make that tab less prominent, maybe move it under Settings. In any case, this patch was a step in the right direction.

Thanks for testing, everyone.

EDIT: Hm, looks like d.o didn't recognize Ralt's authorship :(

Status: Fixed » Closed (fixed)

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