How TO Add Extra Field

Adding extra field on the vendor registration form in Dokan

I was getting a high request to write a blog to show how you can easily add an extra field on the vendor registration form and show that data on the user profile. It is really necessary for some marketplace to register vendor with their TAX ID or GST Number. Dokan does not provide any default field for that kind of data but you can easily add your own field.

How can I add?

You need a child-theme before doing this process. If you have installed a child theme already then you can override the seller registration form through it.

Please create a folder called dokan into your child-theme and then create another folder into dokan folder called global. Now, copy the seller-registration-form.php file from your wp-content/plugins/dokan-lite/templates/global folder and paste it to your child-theme like below –

Overriding template

You can read full details on how to override the template here.

Now, from your child-theme open the seller-registration-form.php file and add the extra field on your desire position like below –

Adding input field on registration form file

You can use this code if you want to just copy and paste (Field for GST Number) –

 <p class="form-row form-group form-row-wide">
        <label for="shop-phone"><?php esc_html_e( 'GST Number', 'dokan-custom-codes' ); ?><span class="required">*</span></label>
        <input type="text" class="input-text form-control" name="gst_id" id="gst_id" value="<?php if ( ! empty( $postdata['gst_id'] ) ) echo esc_attr($postdata['gst_id']); ?>" required="required" />
    </p>

After adding the input field you will be able to see the registration field on the vendor registration form-

Field added on registration form

Now, you have to save the field data and need to show on user profile.

How to save field value and show on backend user profile?

Just open your functions.php file and paste the below code –

If you want to change the field name or meta key then you have to change the meta key or field name accordingly on every place. On this code, I have used the meta key for the field as dokan_custom_gst_id and use the field id as gst_id

After saving the above code, you will be able to use vendor GST Number on his/her user profile –

By following this post you will be able to add multiple fields with different meta key.

You can also follow this video to show the above steps –

Share This Post

Share on facebook
Share on twitter
Share on linkedin

Related Post

42 thoughts on “Adding extra field on the vendor registration form in Dokan

  1. Hi Nayem this is fantastic.
    How can the GST field be made visible on the vendor store page on the frontend of vendor settings

  2. Wrong :– This Location “wp-content/plugins/dokan-lite/templates/global ”
    Right Loction Is :– dokan-lite/account/vendor-registration.php Please change this

    1. I am sorry, it was not wrong. I added the field on the registration form of my-account but the file location you have provided is for the separate registration form.

  3. Thanks for this information. I was looking for this.
    But this process is same in all theme or we have to install dokan theme only?

    And is it important to use both child and parents theme?

  4. How can I get the phone number of a store so that the buyer can send a message with a button? Im trying with shortcode and snippet, but i cant do it.

  5. How can i add brand dropdown list in vendor product upload form? i want my vendor can select brand of their product from dropdown field.

    1. Hello,

      Dokan paid version has Brand features. You have to install Yith brand plugin to allow the vendor to select brand ๐Ÿ™‚

  6. Hi, Nazmul Hassan
    I want to add a dropdown selector to the single product page as a required field which vendors can input choices for the customer to select. Many of my vendors have several pick-up points, one of which would be the customer’s preference. No shipping, local pick-up only. I don’t want it as a product variation and only want vendors to create a single product. The selected location would have to be included int the customers order details. Thanks for any ideas, Peter.

  7. I followed all the steps. The website crashed (child theme failure). I had to rebuild entire website from scratch. Why Dokan does not add seller GST number field in registration form?

  8. I had added separate functions to add additional field that were visible for both customer and vendor registration. It works fine. However the first/last name and phone fields were being duplicated in customer and vendor registration. This blog post helped me understand that vendor registration form separately and now I can add customized fields only for vendor registration. Thank you.

    I have added the code you provided in this post and the new additional custom field is visible in vendor registration. I replaced gst_id with new customer field ID (sell_items). I also managed to remove duplicate fields.

    However I think somewhere this code is probably clashing with the other code I have to add additional field for customer and vendor registration. Now while a new customer is being registered and added to the site, new vendor registration is not going through.

    Do you think you can point me on how to fix this?

    Code I had added: https://www.cloudways.com/blog/add-woocommerce-registration-form-fields/

    Plus code you listed in this post to add a new field only visible to vendors.

  9. Hi Nazmul,

    Great post. Solved one of my big problem. I have one more query. I am using the Dokan Invoice module and I want to display the seller GST that we just added on the invoice. How can we go about adding that in the PDF invoice please.

    Thanks

  10. hello sir i make a new gst field with help of your code but i just want another field i copy my old code change the id and filed name all from all the place but now its not working

    1. Please do not copy the same code twice if you do not have a development idea. You can not use the same function name multiple times. So, try a unique function name.

  11. Hello Very useful Article to add custom field.
    I want to add and update social url like facebook and instagram in vendor registration form. which meta key i should used ?

  12. Hi i try to Add an image Field On The Vendor Registration Form In Dokan.
    does anyone have solution please.

  13. Sir, I followed each step very carefully. It was ok till I added frontend field. but when i added the backend code on function.php it shows a critical error on my site and the site get crushed. [N.B. I didn’t put or remove any single character in your code.}
    Can you please give me the solution?

        1. Hi Nayem
          Thanks for your reply and update. I have entered the new code in my child functions.php file and now it doesn’t cause a critical error, but the backend field is still not showing up. Thanks for your help.
          Jo

  14. Hi! I tried this solution but I get a strange result. The new custom fields are greyed out (inactive), and can’t be interacted with. I even tried a different way pasting this exact solution without customizing anything. Do you know what could cause that?

  15. Hello Nayem,

    Thank you so much for such an amazing post.

    I have two questions:

    1) I am using dokan-vendor-registration but on a different page. so the seller-registration.php goes into same folder?

    2) I want to add also file upload on registration form and save it on backend. I used the same method but input type file. But unfortunately I cannot achieve this. How can I achieve this goal can you please help.

    Thank you

  16. HI,

    I HAVE ADDED TWO FIELDS IN REGISTRATION FORM GST AND PAN NUMBER , I HAVE APPLIED THE CODE BUT IT SHOWS ONLY GST DATA.

    WHAT SHOULD I DO TO SEE PAN NUMER IN MY BACKEND USER PROFILE.

  17. Many thanks for sharing this. Really appreciate it.

    I seem to have the most common issue, in that the data registers in the user profile but won’t display on the header of the store page. I get that my theme may be blocking this, so I will accept defeat.

    Is there an easy way to add this data to a sidebar widget so I can get it to display on the vendor page?

    Thanks
    P

  18. Hi! Thank you for amazing post.
    Are you intentionally using “” again, or should there be a new label? Because that same label already exists for the vendor phone number. I am not sure if this can cause errors?

    Will it work also for existing vendors, so that admin can store them the new data just on backend? I’m wondering this because I can add text data to invoice and store page, but I cannot show the value of that new variable in neither. Would I need to make some new function to Vendor.php for example?

      1. Oh great, thanks Nayem, good to know the label does not hurt.

        I would really love to have a tip on how to print this to invoice.. I added the necessary set, get and initializing methods to Vendor.php and Manager.php but calling my new methods just bring empty string (which is stored nicely to the database). Would I need to populate the Vendor fields again..

        I cannot use: get_user_meta ( $user->ID, ‘dokan_custom_gst_id’, true ); as you suggested, because $user can be also the customer.

        I tried using same method as for Store name:

        $store_name = $vendor->get_shop_name();
        $store_name = ! empty( $store_name ) ? $store_name : __( ‘store_info’, ‘dokan-invoice’ );

        so I added:
        $bus_id = $vendor->get_bus(); ////I have this method there ///
        $bus_id = ! empty( $bus_id ) ? $bus_id : __( ‘dokan_custom_bus_id’, ‘dokan-invoice’ );

        so I have no errors on the code, but cannot return that new field value.

        All tips are greatly appreciated!

  19. Sure I can post it, maybe someone can help me to make the code better, since I’m no pro in PHP?

    Please note that I used “bus” instead of “gst”, just for business.

    I made a new function to functions.php:

    function dokan_get_bus( $seller_id ) {

    return get_user_meta( $seller_id, ‘dokan_custom_bus_id’, true );
    }

    printing the value to store-header.php, you can select a spot you like, I added it just before the address (I guess class is not important for my theme..)


    get_id() ) ); ?>

    couple of functions to Vendor.php (I guess you cannot override these following ones in your child theme?)

    public function get_bus() {
    return $this->get_info_part( ‘dokan_custom_bus_id’ );
    }

    public function set_bus( $value ) {
    $this->set_prop( ‘dokan_custom_bus_id’, wc_clean( $value ) );
    }

    to Manager.php:

    row 169:
    ‘dokan_custom_bus_id’ => ! empty( $data[‘dokan_custom_bus_id’] ) ? $data[‘dokan_custom_bus_id’] : ”,

    row 320:
    if ( ! empty( $data[‘dokan_custom_bus_id’] ) ) {
    $vendor->set_bus( $data[‘dokan_custom_bus_id’] );
    }

    dokan-invoice.php (not sure if first row is needed)

    $bus_id = “undefined”;
    $bus_id = wp_kses_post( dokan_get_bus( $vendor_id ) );
    return $shop_name . ‘Seller: ‘ . $store_name . ‘ Business ID: ‘ . $bus_id ;

    the same to be repeated in couple of places

    and did also some other modifications – I took away marketplace address and added business id’s of vendors to invoice if it is multivendor and so on.

    for multivendor-part of loops I had to use other function because $vendor-id was not available, this did the trick when anyway $vendor was:

    $bus_id = wp_kses_post( dokan_get_bus( $vendor->get_id() ) );

    if someone has info how to add new variables to .pot file – please inform me ๐Ÿ™‚ would like to make this multilingual.

  20. sorry, store-header had some html..did now show on this page of course.. ๐Ÿ˜€
    here without:

    php echo ‘Business-ID: ‘ . wp_kses_post( dokan_get_bus( $store_user->get_id() ) );

Leave a Reply

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

%d bloggers like this: