Dynamically Disabling Customer Profile panes
Hi I am writing a contrib module called Customer Profile Types UI through which I would like to provide a mechanism for disabling certain customer profile panes on checkout.
My purpose is for creating a drupal native CRM so that different types of membership application will have separate customer profile forms to fill out. On completion of the checkout and payment process the data from a specific for referenced through the order's reference fields will be copied using rules to a custom membership entity. The awesomeness of drupal 7 sometimes astounds me! :) Regardless the piece I am missing is the ability to control the appearance of these customer profile panes in drupal commerce.
I have created an initial method for doing this using a new event that is fired from hook_commerce_checkout_pane_info_alter that just sets enabled=false on the pane I want to disable. This works for checkout, however it does not work for after the fact when editing the order. There is also the problem that the above mentioned hook does not provide any sort of context as to which order you are working with. If I had that it would make the process much easier. I am using commerce_cart_order_load() to get the context, but that obviously only works during the checkout process and not when editing an order. Also, if I am editing order commerce_cart_order_load() will give me an improper context since it will be referencing an order that may or may not be in the cart as opposed to the one I am editing.
Ok so that is the background story, here are some questions:
Are there any methods you can suggest that might work better then this?
Are there other ways to get the proper order context?
Are there events or hooks that fire before displaying the order's edit page aside from hook_form_alter.