I'm learning to build a woocommerce+dokan website. When a store owner signs into my platform, they can enter a product they wish to sell. One of the options I want the store owner to describe about their product is its condition as either Never used, Lightly used, Used, or Heavily used.
I am adding a new product attribute "Condition" as shown in the following screenshot:
Now when I sign in as a store owner, I see the option to save the Condition field with this user interface located at the bottom of the product add/edit page:
I want to replace this interface with a more intuitive control such as a
<select> menu that offers the four possible condition options.
I'm not comfortable enough with WordPress best practices to do this. So I was about to do the following:
- Create a child theme so that I have a place to override the default HTML with some custom HTML.
- Write an SQL statement that reads Condition taxonomy/terms directly from the appropriate
wp_term*tables and load terms into a php
array()which I will use to echo a
<select name="prod_condition">...</select>element in the child theme.
- For saving the product, create a custom plugin with this hook
add_action( 'dokan_store_profile_saved', 'save_condition_field', 15 );. This hook fires AFTER a product has been saved. In my hook, I will read from
$_POST['prod_condition'], then save the value by creating an SQL statement that writes directly to the
Is that the proper approach to creating a custom UI for saving advance custom fields in a woocommerce+dokan setup? Are there native wordpress/woocommerce/dokan functions or tools I should be leveraging? For example, are there html variable naming conventions I can follow that will circumvent the need for me to write my own SQL create/update statements? Or certain wordpress functions that can easily create a drop down menu that becomes part of the wordpress CRUD process?
My approach seems very brute right now.