First of all sorry for my poor English.
– I use ACF to create products via acf form. The form has a first ‘Brand’ field (selector) and, according to the choice made, a ‘Models’ field (selector) containing the models corresponding to the brand is displayed.
– The ‘Brand’ field contains a list of 200 brands, and there are as many ‘Models’ conditional fields as there are brands
– In parallel, product categories (WooCommerce) have been created which include the brands (200). These categories are child categories of the parent category ‘Motorcycles’
When submitting the form, I would like the product created to be included in the category corresponding to the choice made in the ‘Brand’ field and unregistered from uncategorized category.
I don’t want to use the Taxonomy field of ACF because with conditional logic we cannot use ‘Value is equal to’. In addition, I do not want the parent category ‘Motorcycles’ to be visible in the ‘Brand’ selector.
Hoping that my explanation is clear.
Thanks so much for helping me
You need to create an acf/save_post filter https://www.advancedcustomfields.com/resources/acf-save_post/
In this filter you need to get the value from the field and then find the correct “category”. I don’t know what this field contains but you should be able to get the term in some way. Then when you have that you use https://developer.wordpress.org/reference/functions/wp_set_post_terms/ to place the post in the category.