Improving the Experience of Commerce Bundles
Commerce Bundles, while very powerful, isn’t exactly the most user-friendly from a UI standpoint. However, it is very customizable and there are a few things we can do really easily to improve the overall experience:
Using a View for the Bundle Item Autocomplete
Out of the box, Commerce Bundle’s Bundle Item Autocomplete looks solely at the title. This doesn’t scale really well if you give all of your products in a set (e.g. S-XXL shirts) the same name, which is pretty common. So instead, we can modify the widget to use a custom view to load and search for autocomplete suggestions. To enable:
- Grab the view export @ Github and import it (admin/structure/views/import).
- Head over to Administration → Store Settings → Bundle Item Types (admin/commerce/config/bundle-items).
- Click on manage fields (admin/commerce/config/bundle-items/bundle-item/fields).
- Edit the widget the product field and then click Field settings.
- Change the Mode to “Views: Filter by an entity reference view”.
- Under Views used to select the entities, chose the view you imported in step 1.
Automating Bundle Group Creation
The “Create Bundle form a Product Display” creates the bundle group. In it, there is a loop which creates a bundle item for each product reference that exists in the node that was passed into the rule. The “Create Budnle Item from Product” rule creates the Bundle Item entity and returns the new item’s ID back to the calling rule so that it can add it to the entity reference of the bundle group. Finally, the “Copy into Bundle” rule exists so that View Bulk Operations can make the action available to end users.
- Grab a copy of the export Rules and import the rules.
- Customize to your liking.
- Enable in VBO.
To enable in Commmerce Kickstart, or if you are using the Commerce Backoffice Products, edit the “Commerce Backoffice: Products (Content)” (admin/structure/views/view/commerce_backoffice_products/edit) view and click on the “Bulk operations: Content” field link. Under “Selected bulk operations” check the “Copy into Bundle” checkbox. Save and enjoy.
If you aren’t using the above modules, then you will have to create a view that shows content, add the “Bulk operations: Content” field, and set it up manually. The view will need to show Content, and not products since it operations on nodes and not the individual products.