Problem/Motivation

We cannot override commerce_line_item_manager theme to add custom rows because everything is set in theme function which return markup generated in function.
This is painful if we need to add custom values by line items in back-office (example, a delivery date by line item).

Proposed resolution

I suggest to switch this function to a preprocess + template so it will be overridable by drupal processes.

CommentFileSizeAuthor
#2 commerce-line-item-manager-2834739-2.patch3.09 KBGoZ
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

GoZ created an issue. See original summary.

GoZ’s picture

Status: Active » Needs review
FileSize
3.09 KB
rszrama’s picture

Hmm, my only worry is backwards compatibility. This shouldn't break any current overrides, right? Since the theme function itself would be overridden in total?

GoZ’s picture

The only way to currently override theme function is to override $theme_registry['commerce_line_item_manager']['function'] in hook_theme_registry_alter() with something like that :

function MYMODULE_theme_registry_alter($theme_registry) {
  if (isset($theme_registry['commerce_line_item_manager'])) {
    $theme_registry['commerce_line_item_manager']['theme path'] = drupal_get_path('module', 'MYMODULE');
    $theme_registry['commerce_line_item_manager']['function'] = 'MYMODULE_commerce_line_item_manager';
  }
}

Patch add a way to override theme with preprocess + template, which remove the current $theme_registry['commerce_line_item_manager']['function'] ( = 'theme_commerce_line_item_manager') entry from $theme_registry.

But if your previous hook_theme_registry_alter() previously added your custom function, this function will still be called as final result and will not take care of processed preprocess functions since it will return something.

function MYMODULE_commerce_line_item_manager(&$variables) {
  // This function si called thanks to MYMODULE_theme_registry_alter() override in hook and will
  // display string returned, nothing else.
  return 'Display this thing only. No preprocess, no template';
}

So i don't think patch will break existing overrides.