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.
- Enjoy!
Automating Bundle Group Creation
If you have many bundles you want to create, you can automate the process of creating the groups using Rules and Views Bulk Operations. Here is a brief overview of how it works.
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.
Hope these tips are helpful! Please share any feedback in the comments, and put suggestions for Commerce Bundle into the Commerce Bundle Issue Queue.
Comments
Few questions/problems regarding this blog.
First of all thanks a lot for this great module, this blog and a video on youtube to demonstrate the usage of this module. However, I had some problems while following this blog. Maybe I am being a bit silly, but please help me out to clear my understanding of this blog.
The problems are :
1,) In the section where you asked to import the view, in point no. 4 you said to "Edit the widget the product field and then click Field settings.". I just didn't understood this point. What edit/change should we do to "product field's widget".
2.) The rules 1 and 3, i.e; [copy_product_to_bundle.json] and [vbo_action_create_bundle.json] are not getting imported. On trying to import rule 1 I am getting the following error :
Integrity check for the imported configuration failed. Error message: Missing configuration for parameter <em class="placeholder">param_commerce_stock</em>..
And on trying to import rule 3 I am getting the following error :
Integrity check for the imported configuration failed. Error message: Unknown action <em class="placeholder">component_rules_copy_product_to_a_bunde</em>..
Please help me out as soon as possible. Thanks you.