Drupal Commerce allows you to sell customizable products that require customer input when added to the cart. Use cases for this functionality include:
- Business cards that require contact information and a logo upload.
- Event registrations that require attendee information.
- Donations the allow the customer to specify a donation amount.
The core Line Item module accommodates these scenarios by letting you add any number of fields to the Product line item type and expose them to the Add to Cart form. However, sites that sell multiple types of customizable products or a mixture of customizable and non-customizable products need to define multiple line item types to handle the different configurations of fields. That's where this Customizable Products module comes in!
It gives you the ability to define new line item types on the fly at Administration > Store > Configuration > Line item types. This is functionally equivalent to defining the new line item type in code, which is still recommended if you are able (see below).
The module will be developed further to add features that support the creation and management of your customizable products. If you have any ideas to do so, please post them as feature requests in the issue queue.
Installation and configuration
This module only requires the core Line Item and Line Item UI modules to work. Browse to the line item types configuration page and create your new product line item type to begin adding fields to it. Be sure to click the checkbox to include your custom fields on the Add to Cart form or they will not show up.
Once your customizable product line item type has been created, you need to either update an existing product display node type or create a new one to use the custom product line item type. Do this through the settings form for the Add to Cart form display formatter of your node type's Product reference field. If the Add to Cart form is visible on multiple view modes, make sure you have updated them all to use the same line item type.
This module was featured in the Commerce Module Tuesday video series if you'd like to see a video walkthrough.
If you'd prefer to define your custom product line item type in code, it's quite simple through a basic implementation of hook_commerce_line_item_type_info(). You can see an example of this in the Commerce Examples module.
The main thing to remember in development is that the Line Item module will look for your custom line item type definition when your module is enabled, and if it finds it will add required default fields to it. If you add the line item type to a module that is already enabled on your site, this process will not be triggered and you will be responsible (perhaps through an update function) to ensure the commerce_line_item_configure_line_item_type() function is executed for your custom line item type.
Commerce Guys Marketplace
This module is designed for use with Drupal Commerce, and is maintained by Commerce Guys.
Lower the cost of integration, shorten time to market, and provide a better user experience and higher conversion rates with hundreds of the best Drupal Commerce modules.
Add Commerce Guys Marketplace functionality to your Drupal Commerce site with the Commerce Guys Marketplace Module.