-
-
Save nayemDevs/b629d4b1c27c794bdfb729ce6927069e to your computer and use it in GitHub Desktop.
/*Extra field on the seller settings and show the value on the store banner -Dokan*/ | |
// Add extra field in seller settings | |
add_filter( 'dokan_settings_form_bottom', 'extra_fields', 10, 2); | |
function extra_fields( $current_user, $profile_info ){ | |
$seller_url= isset( $profile_info['seller_url'] ) ? $profile_info['seller_url'] : ''; | |
?> | |
<div class="gregcustom dokan-form-group"> | |
<label class="dokan-w3 dokan-control-label" for="setting_address"> | |
<?php _e( 'Website', 'dokan' ); ?> | |
</label> | |
<div class="dokan-w5"> | |
<input type="text" class="dokan-form-control input-md valid" name="seller_url" id="reg_seller_url" value="<?php echo $seller_url; ?>" /> | |
</div> | |
</div> | |
<?php | |
} | |
//save the field value | |
add_action( 'dokan_store_profile_saved', 'save_extra_fields', 15 ); | |
function save_extra_fields( $store_id ) { | |
$dokan_settings = dokan_get_store_info($store_id); | |
if ( isset( $_POST['seller_url'] ) ) { | |
$dokan_settings['seller_url'] = $_POST['seller_url']; | |
} | |
update_user_meta( $store_id, 'dokan_profile_settings', $dokan_settings ); | |
} | |
// show on the store page | |
add_action( 'dokan_store_header_info_fields', 'save_seller_url', 10); | |
function save_seller_url($store_user){ | |
$store_info = dokan_get_store_info( $store_user); | |
?> | |
<?php if ( isset( $store_info['seller_url'] ) && !empty( $store_info['seller_url'] ) ) { ?> | |
<i class="fa fa-globe"></i> | |
<a href="<?php echo esc_html( $store_info['seller_url'] ); ?>"><?php echo esc_html( $store_info['seller_url'] ); ?></a> | |
<?php } ?> | |
<?php | |
} |
I have checked and it is working fine for me. So, please make sure that there is no conflict with your theme :)
@itsachalsingh, Code updated! Can you check now?
Hey how can i add the same field in the admin backend also ? In the Users > Profile area.... this same field ? Can you please tell me ? I have been trying hard with my code here on my gist using some of your code
https://github.com/geekysihag/dokan-custom-registration-fields/blob/master/funtions.php
This is some super useful code, I really appreciate the effort and time you have saved people, thank you. I do have one question though... I have implemented this code into my child theme function.php file and everything appears to work from the back end, though when I have a look at the store page the web address isn't showing up in the store information section for some reason? Could the code be not functional with newer versions of Dokan? I am running the latest version of Dokan Pro Business for my site, any ideas why this may be happening?
Also, is it possible to use a similar code string to create a second advertising banner that can be added to the store template as a widget in elementor (like the original store banner can be), or is this a lot more complex? I've tried to find the original banner upload code snippet to have a look, but can't find it anywhere.
Again, really appreciate your help and skills and thanks again for being so open with your code.
This is some super useful code, I really appreciate the effort and time you have saved people, thank you. I do have one question though... I have implemented this code into my child theme function.php file and everything appears to work from the back end, though when I have a look at the store page the web address isn't showing up in the store information section for some reason? Could the code be not functional with newer versions of Dokan? I am running the latest version of Dokan Pro Business for my site, any ideas why this may be happening?
Also, is it possible to use a similar code string to create a second advertising banner that can be added to the store template as a widget in elementor (like the original store banner can be), or is this a lot more complex? I've tried to find the original banner upload code snippet to have a look, but can't find it anywhere.
Again, really appreciate your help and skills and thanks again for being so open with your code.
Same here - Would be an amazing edition but I can't seem to get it to show on the front end. I wonder if this is due to me using Elementor Pro?
Can anyone let me know how to add a filed for adding media and images in the same page
ok...
it's actually not nice, but if you check the doc for available hooks & filters
https://wedevs.com/docs/dokan/developer-documentation/action-hooks/
apparently dokan_store_header_info_fields doesn't exist (which can explain why it doesn't appear)
instead there is a
dokan_store_profile_frame_after
and that hook actually displays the data, though not in the desired area... but below
and there are these two hooks too
add_action( 'dokan_sidebar_store_before', 'show_extra_seller_data_frontend1', 10);
add_action( 'dokan_sidebar_store_after', 'show_extra_seller_data_frontend2', 10);
but they are showing the data above and below the sidebar
Same here. Doesnt display on front end.
Are the hooks different for dokan lite and other versions?
Please note that the code is working 100% correctly. The problem is - If you are using any theme which has override store-header.php and removed the hook dokan_store_header_info_fields
then this code wont work. I have no control over that if the theme author removed that hook.
In that case, you can modify the store-header.php file inside your theme and add the hook manually or ask your theme author not to delete - do_action( 'dokan_store_header_info_fields', $store_user->get_id() );
It has not worked for me, to add any field, really what I want is to put the description of the seller in their profile. Is this achieved with the paid version? or is there any way to do it in the lite version?
Hi, thanks for sharing this code, I have got it working under the store options but website is not displaying on the store page. I believe this may be because of elementor because no way to tick show website under the element options.
Hello,
I want to add multiple fields for vendors. But I don't know how to edit the code. How can I edit the code for each new field? I need 4 different fields.
Thank you
Hello, I would like to add extra fields as shown in the attachment. I'm using Dokan Pro, and I want sellers to be able to add custom extra prices and options they define themselves on their product submission pages, just like in the image. For example, if it's a restaurant selling hamburgers, I want them to be able to add options like extra ketchup, hot sauce, etc., along with their respective prices. If you could assist me on how to achieve this, I would appreciate it. https://tinypic.host/images/2023/08/28/IMG_3722.png
It is not working now. when I use this unable to save the payment profile.