The module currently uses form alter to forcefully inject the product selection widget in to node forms.

Instead, the Field API should be used (via hook_field_extra_fields()) so that admins can decide where on the form it appears, etc.

On top of that, having a centralized widget type means that other modules, especially the 'expire' submodule, can easily replicate this widget without having to manually create it.

As what was done so far in the patch in issue #1975592: Fixes for commerce_node_checkout_expire, I recommend that the select list include the prices.

Patch coming to take care of all of this. I will then alter the patch in #1975592: Fixes for commerce_node_checkout_expire to take advantage of this new functionality.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mstef’s picture

Here's a patch that does the following:

- No longer add to the node form via hook_form_alter().
- Implement hook_field_extra_fields() to provide the product selection widget on the Manage fields UI.
- Implement hook_field_attach_form() to add the product selection widget to the form.
- Implement hook_element_info() to provide a custom form element that supplies to product selection.
- Added a helper function to provide the options on the form widget, which also include the price of each product.
- Added a checkbox for admins when viewing the product selection form so that they can optionally skip adding the node to checkout. This is better than hiding the form completely because 1) it seems to be confusing new module users, 2) admins may want to practice the checkout, etc.
- Implement hook_permission() to add a permission to have access to the checkbox previously mentioned.

mstef’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 1: commerce_node_checkout-use_field_api-2261333-1.patch, failed testing.

  • Commit 998f0c8 on 7.x-1.x by mstef:
    Use the Field API to provide the node product selection form element(s...
mstef’s picture

Status: Needs work » Fixed
mstef’s picture

Title: The production selection widget on nodes should be added via the Field API » The product selection widget on nodes should be added via the Field API

Status: Fixed » Closed (fixed)

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