Hi Adrien,
I have a feature request to enable category-specific product fields, so depending on the particular product category that a user select in vmvendor add-product or edit-product pages, different vm custom fields will be displayed and data submitted. For example, if the selected category is "dresses", then "color" and "size" custom fields will be applicable. However if the selected category is "perfumes" then "scent" and "volume" custom fields will be applicable.
I did some initial investigation on VM database structure and thought of a possible solution to implement this, please see below, let me know your thoughts?
Feature request: To have category-specific product fields (vm custom fields) in vmvendor add-product and edit-product pages.
Related files:
./components/com_vmvendor/views/addproduct/tmpl/default.php
./components/com_vmvendor/views/editproduct/tmpl/default.php
A possible solution:
1) Use the native vm custom field description field to indicate the product category ID that the field applies to. E.g., a custom field name = "Color" may have the Custom Field Description = "15, 20, 22" indicating that this field applies to product categories with ID 15, 20, and 22.
2) Add an if statement in the for loop in default.php (line 1161 of addproduct php file, line 1050 for editproduct php file) to check that the product category ID that the user has selected matches one of the comma-separated list of IDs in the particular vm custom field description.
3) Other items:
- To simplify, can assume that each product belongs only to one category, i.e., for category selector = Single Multistep and Classic, but not Multicat.
- For addproduct and editproduct, the for loop that populate the vm custom field list (line 1161 and 1050) need to be re-executed every time a category selection is made or changed to refresh the list of custom fields. Custom fields that may already have input values but no longer apply to the new category selection need to be deleted to ensure there is no incorrect custom field entry.
- It seems that the native vm Custom Field Description field is not used anywhere in vmvendor or vm in general. Need to confirm this.
Thank you