I was happy with Ubercart 2.3 introducing the hook 'hook_checkout_pane_alter()' (see #603264: Allow modules to alter panes definition).
I had assumed a hook to alter order panes should be there as well, but I found out this wasn't the case.
The patch I'm posting adds the hook hook_order_pane_alter() and updates the hook documentation.

MegaChriz

P.S. I had posted about this issue before in #878628: Hooks to alter order panes and address, but I realized I was talking about two different issues at once, so that's why I opened a new issue.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

longwave’s picture

Perhaps move the drupal_alter() call after the enabled and weight values are set, similar to the request in #964232: Allow users to drupal_alter a checkout pane's enabled field?

MegaChriz’s picture

@longwave Yes, that's okay. It doesn't give problems for the module I'm developing.

Posting a new patch, the altering now happens after 'enabled' and 'weight' are set.

longwave’s picture

Status: Needs review » Reviewed & tested by the community

Looks good, patch works for me.

EvanDonovan’s picture

Looks good on the code, haven't tested yet.

arski’s picture

nice nice, that's the stuff ;)

Sivaji_Ganesh_Jojodae’s picture

+1 to commit this patch. It works great here.

arski’s picture

Status: Reviewed & tested by the community » Needs review

Just wondering, does this patch address places where ubercart might be using variable_get(..pane_enabled/weight) instead of the 'enabled/weight' attributes of the actual pane. That was something that was happening with the checkout panes basically resulting in whatever you "altered" being ignored.

And the other way around - if you change the enabled/weight fields of the panes in the _alter call, it should have no effect on the panes list in the admin interface - i.e. you would still want to have the full list of panes there, even if some of them have been disabled or something by the alter call (that should be reflected in the orders, not in the admin view).

Hope you get what I mean.. :)

Feel free to switch back to rtbc if there are no such issues in this case.

MegaChriz’s picture

Yes, I realized I probably needed to update this after I had reviewed your patch in #964232: Allow users to drupal_alter a checkout pane's enabled field.

I'll look into it later. :)

arski’s picture

Status: Needs review » Needs work

hehe, sorry for delaying this process mate ;) I'll mark the issue as "needs work" for you.

MegaChriz’s picture

Status: Needs work » Needs review

I've looked into it a few times, but it seems altering the enabling or weight value via the hook will have no effect on the administration page for order panes (which is the desired behaviour).
admin/store/settings/orders/edit/panes

The only thing that has effect on the order pane admin page is when the 'show' array is altered by a custom module. This array tells on which pages (view, edit, invoice, customer) the order pane will be available. With the current patch, a custom module would have a chance to change this value and this has effect on the order pane admin page too. But I think that won't be much of a problem.

Let's say for example a custom module add support to let an existing order pane show up on a page it originally couldn't be on. The user would still have control to enable/disable the pane on that page on the order pane admin page, because this change would show up there.

I can't think of a use case where altering the show-array would be useful, though. I need this only to be able to change the callback of an order pane. An other useful use case is that the title of an order pane can be changed without using string overrides.

Do you agree with me that a possible change of the show-array by a custom module that affects the order pane admin page won't be much of a problem?

mattcasey’s picture

has this patch been applied yet? I would like this feature

TR’s picture

@mattwad: Please read up on how to use the issue queue. The status "needs review" means there is a proposed patch and it needs community members to apply the patch and comment (in detail) on if the patch works, if it breaks something else, and to ask for issues to be addressed. Once it has be thoroughly reviewed, it can be marked RBTC, and then it's up to the maintainers to either apply the patch or bump it back to a previous state.

So if you'd like to see this feature become part of Ubercart, apply the patch and report back (in detail) how it worked for you.

cigotete’s picture

Hi, I am newbie, I implemented the patch but I can not find the way to change the place of the fileds. ¿somebody can give me some light?

MegaChriz’s picture

@cigotete
The patch doesn't make any visible changes in the user interface. The patch introduces a hook to alter the order panes. A hook can be implemented by other modules. With the patch applied, other modules have a chance to change information/content of an order pane.

See also:
http://api.drupal.org/api/drupal/includes--module.inc/group/hooks

MegaChriz’s picture

Patch can be found in #2.
Please verify if things stated in #10 are an issue or not.

longwave’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev
Status: Needs review » Patch (to be ported)

Committed to 6.x, as I can't anything in #10 being a problem. Needs porting to 7.x.

longwave’s picture

Status: Patch (to be ported) » Fixed

Hook renamed to hook_uc_order_pane_alter() in 7.x for consistency, and committed: http://drupalcode.org/project/ubercart.git/commitdiff/da31d6c

MegaChriz’s picture

Great!
Thanks, longwave.

Status: Fixed » Closed (fixed)
Issue tags: -hooks (duplicate)

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