The big idea
The aim of this project is to provide a dynamic way to add new customer profile types for the Commerce module using a UI. This will mean that anyone wanting another customer profile type other then the default billing pane that comes with Commerce can easily add new ones.
This module also adds a new widget (Dynamic profile form manager) for commerce customer profile reference fields that allows admins to enable/disable customer profiles on the order edit form using some checkboxes and some slick ajaxiness.
The widget settings include options to wrap the customer profile panes in collapsible fieldsets. This becomes especially useful if you have many customer profile types that clutter the order edit form. The same settings are also added to the default customer profile manager widget that ships with commerce.
Creating new Customer Profiles
After enabling the module you will most likely want to clear all caches so that the new menu items, etc appear.
- Click the new 'Add customer profile type' button on the profile types page. It will also be available in the admin menu: store > profiles > add customer profile type
- Fill out the form and click save.
- Click manage fields or display to add fields to your new customer profile type and control how it is displayed.
- Finally go to the order configuration page and drag/drop the new profiles into the order checkout regions you want them to appear in.
Dynamically disable profile panes using rules
This module will also attempt to add a new rule event and actions that will allow for the dynamic disabling of customer profile panes during the checkout process.
New rule event: 'Before customer profile panes are displayed'
New rule actions:
- 'Disable all customer profile panes' - disables all customer profile panes on the order
- 'Disable a customer profile pane' - allows you to select a specific customer profile type to disable.
- 'Enable a customer profile pane' - allows you to select a specific customer profile type to enable.
How to enable/disable customer profile panes
During checkout
By default all customer profile panes that have been placed in checkout regions will be enabled and appear in the checkout process. You can enable/disable them using the rules module in the following way:
- Create a new rule that is triggered on the 'Before customer profile panes are displayed' event
- Add in some conditions. One particular use case is for a membership system where different membership types require different customer profile fields. So my conditions involve the order's products.
- Add as many 'Disable/Enable a customer profile pane' actions as panes you wish to disable. By default all panes are enabled. I tend to use the 'disable all' action and then follow it by enable actions for the panes I want to display.
On the order edit page
By default all customer profile forms will be displayed on the order edit page regardless whether they were enabled during checkout or if a profile of that type has even been created for the order yet. (Commerce assumes you want to fill out these forms, however this is not always the case.)
- For customer profile panes that you do not always want displayed for every order change the widget for that profile reference field on the order's manage fields page (admin/commerce/config/order/fields). Select the 'dynamic profile form manager' widget from the options.
- To toggle the collapsed/collapsible state of each customer profile form on the order edit page, edit the respective field. Change the 'Field form wrapper' setting to your preference. This setting also appears on the default 'customer profile manager' widget.