Add/Update Extra Product Meta Fields In Dokan.

DOKAN is no doubt the best front end multi-vendor marketplace on WordPress, powered by WooCommerce.Dokan is the fastest way to start eCommerce and earn through commissions with products ranging from digital, physical to variable products.

Some time we need to add some more information regarding product , for adding new fields to dokan form we have to customize new-product.php and new-product-single.php.

Example for adding html add input field.
<input type="text" name="info" >

Dokan provide hook for adding and update product fields.
For adding product field data dokan provide hook 'dokan_new_product_added'.
Hook runs after added any new product. Parameter ( $product_id, $post_data ).


add_action('dokan_new_product_added', 'AddExtraProductMeta', 11,2);
function AddExtraProductMeta($product_id, $post_data){
    add_post_meta( $product_id, 'info',$_POST['info']);
}

For Editing Meta From Dokan Form Is Also Can Be Done by Simple Editing Hook 'dokan_product_updated'

add_action('dokan_product_updated', 'UpdateExtraProductMeta', 11,2);
function UpdateExtraProductMeta($product_id, $post_data){
    update_post_meta( $product_id, 'info',$_POST['info']);
}

Enjoy

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top