Skip to content

Instantly share code, notes, and snippets.

@nayemDevs
Last active September 19, 2023 16:10
Show Gist options
  • Save nayemDevs/b629d4b1c27c794bdfb729ce6927069e to your computer and use it in GitHub Desktop.
Save nayemDevs/b629d4b1c27c794bdfb729ce6927069e to your computer and use it in GitHub Desktop.
Add extra field on vendor settings area and show the field value on the store banner
/*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
}
@leotinoco
Copy link

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?

@guy01992
Copy link

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.

@tniron
Copy link

tniron commented Dec 6, 2021

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

@Erhangk2023
Copy link

Erhangk2023 commented Aug 28, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment