Home Forums Theme Support Dokan Adding custom field(s) to product-edit.php requires editing wc-funcitons.php too

This topic is: resolved

This topic contains 2 replies, has 3 voices, and was last updated by  Sk 5 years ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #19424

    Simon
    Member
    Post count: 58

    So I want to add some custom fields to the product-edit page, but doing this requires me to also edit the wc-functions.php file because of the function “dokan_process_product_meta”.

    I had to add my fields inside that function in order for them to update properly. Is there a better way to do this? I'm using a child theme and do not want to have to worry about overwriting the wc-functions.php file when I upgrade?

    #19918

    Mohd Ghufran
    Member
    Post count: 25

    I also need an update on this.Please response

    #20274

    Sk
    Moderator
    Post count: 371

    hello Simon

    sorry for late response.

    create a new function file with necessary changes in your child theme.

    find includes() function in dokan/functions.php file.

    replace wc-functions.php with your file.

    if ( is_child_theme() && file_exists( get_stylesheet_directory() . '/your-path/your-file.php' ) ) {
         require_once get_stylesheet_directory() . '/your-path/your-file.php';
     } else {
         require_once $inc_dir . 'wc-functions.php';
     }

    or you could easily use an add_action to your functions.php page

    there is a do_action in wc-functions.php page
    do_action( 'dokan_process_product_meta', $post_id );
    this action returns a parameter $post_id. you could add your custom meta by this action.

    thank you.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Adding custom field(s) to product-edit.php requires editing wc-funcitons.php too’ is closed to new replies.