This will be the most awaited blog post for Dokan users. Dokan powered marketplaces are advanced and its users are building different kinds of a marketplace with unique requirements. To meet the marketplace requirements, sometimes it is necessary to modify the plugin. One of the common modification is adding a new field on the product upload form of Dokan.
It is easy to add a new field on the backend WooCommerce with ACF but Dokan does not populate that field automatically. To add a new field, you might need to add a little bit of code. So, I thought to write a full blog with code example so that it can save users time and money.
How to add a new field?
If you are trying to read my post and add a field then install a child-theme on your website. I have done the code in 4 steps –
- Added a field on product upload form (With pop-up or without pop-up)
- Saved and updated field value while saving the product
- Showing the extra field on product edit page
- Also, showing the extra field data on single product page 🙂
Now, open your child-theme functions.php and paste the below code –
Now, check the product upload form where you will get the new field after that TAG field –
Please note that I have used this action to add the field after the tag field – dokan_new_product_after_product_tags which will add the field after the tag. If you want multiple fields then you can add multiple
Now, you can fill the form and create your product which will redirect you to the product edit page with the new custom field value –
I have used these actions to save and update product meta – dokan_new_product_added & dokan_new_product_added
To show the field on the edit product page, I just used this action – dokan_product_edit_after_product_tags
The last part of the code is to show new field data on single product page. To show on the single product page, I have used this action- woocommerce_single_product_summary
If you need to change the field type or need to add more fields, then you can follow my above code and write your one.
Check my another video to add new field on the vendor registration form –